From 5bea1a4d310e468d6ea1b71de36bdb4a53b8c57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:02:15 +0100 Subject: [PATCH 01/11] [add] function to get tags by entry --- inc/poche/Database.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index c233eda..86907e5 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -249,4 +249,15 @@ class Database { public function getLastId($column = '') { return $this->getHandle()->lastInsertId($column); } + + public function retrieveTagsByEntry($entry_id) { + $sql = + "SELECT * FROM tags + LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id + WHERE tags_entries.entry_id = ?"; + $query = $this->executeQuery($sql, array($entry_id)); + $tags = $query->fetchAll(); + + return $tags; + } } From 7b171c73400ff2c0b8f3634e35d186b22176759b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:02:38 +0100 Subject: [PATCH 02/11] [add] send tags to article view --- inc/poche/Poche.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d45d0c4..c9fb638 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -443,12 +443,16 @@ class Poche # flattr checking $flattr = new FlattrItem(); - $flattr->checkItem($entry['url'],$entry['id']); + $flattr->checkItem($entry['url'], $entry['id']); + + # tags + $tags = $this->store->retrieveTagsByEntry($entry['id']); $tpl_vars = array( - 'entry' => $entry, - 'content' => $content, - 'flattr' => $flattr + 'entry' => $entry, + 'content' => $content, + 'flattr' => $flattr, + 'tags' => $tags ); } else { From 68e20616663e048d47297ff251f64081b1d1fe3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:02:58 +0100 Subject: [PATCH 03/11] [add] tags displaying --- themes/default/css/style.css | 6 ++++++ themes/default/view.twig | 3 +++ 2 files changed, 9 insertions(+) diff --git a/themes/default/css/style.css b/themes/default/css/style.css index 670eb50..2088ee2 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -176,6 +176,12 @@ a:visited { text-decoration: none; } +#article .tags { + font-size: 0.8em; + color: #888; + padding-bottom: 5px; +} + .backhome { display: inline; } diff --git a/themes/default/view.twig b/themes/default/view.twig index 1e54ae3..5a7c916 100644 --- a/themes/default/view.twig +++ b/themes/default/view.twig @@ -20,6 +20,9 @@

{{ entry.title|raw }}

+
{{ content | raw }}
From 2e2ebe5ec767dcbee90394d12b03298592c87805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:15:06 +0100 Subject: [PATCH 04/11] [add] create tags page --- inc/poche/Database.class.php | 14 +++++++++++--- inc/poche/Poche.class.php | 6 ++++++ inc/poche/Tools.class.php | 5 +++-- themes/default/_menu.twig | 1 + themes/default/tags.twig | 8 ++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 themes/default/tags.twig diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 86907e5..8e9ee0b 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -250,13 +250,21 @@ class Database { return $this->getHandle()->lastInsertId($column); } + public function retrieveAllTags() { + $sql = "SELECT * FROM tags"; + $query = $this->executeQuery($sql, array()); + $tags = $query->fetchAll(); + + return $tags; + } + public function retrieveTagsByEntry($entry_id) { - $sql = + $sql = "SELECT * FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags_entries.entry_id = ?"; - $query = $this->executeQuery($sql, array($entry_id)); - $tags = $query->fetchAll(); + $query = $this->executeQuery($sql, array($entry_id)); + $tags = $query->fetchAll(); return $tags; } diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c9fb638..802ec54 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -430,6 +430,12 @@ class Poche ); Tools::logm('config view'); break; + case 'tags': + $tags = $this->store->retrieveAllTags(); + $tpl_vars = array( + 'tags' => $tags, + ); + break; case 'view': $entry = $this->store->retrieveOneById($id, $this->user->getId()); if ($entry != NULL) { diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 750553f..5bb65fe 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -103,14 +103,15 @@ class Tools case 'config': $tpl_file = 'config.twig'; break; + case 'tags': + $tpl_file = 'tags.twig'; + break; case 'view': $tpl_file = 'view.twig'; break; - case 'login': $tpl_file = 'login.twig'; break; - case 'error': $tpl_file = 'error.twig'; break; diff --git a/themes/default/_menu.twig b/themes/default/_menu.twig index 699d6a0..02bec1d 100644 --- a/themes/default/_menu.twig +++ b/themes/default/_menu.twig @@ -2,6 +2,7 @@
  • {% trans "home" %}
  • {% trans "favorites" %}
  • {% trans "archive" %}
  • +
  • {% trans "tags" %}
  • {% trans "config" %}
  • {% trans "logout" %}
  • \ No newline at end of file diff --git a/themes/default/tags.twig b/themes/default/tags.twig new file mode 100644 index 0000000..9421fe3 --- /dev/null +++ b/themes/default/tags.twig @@ -0,0 +1,8 @@ +{% extends "layout.twig" %} +{% block title %}tags{% endblock %} +{% block menu %} +{% include '_menu.twig' %} +{% endblock %} +{% block content %} +{% for tag in tags %}{{ tag.value }} {% endfor %} +{% endblock %} \ No newline at end of file From 6cab59c3409f4edc9b309b76295cb4061bff3fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:03:14 +0100 Subject: [PATCH 05/11] [add] edit tags page --- inc/poche/Poche.class.php | 7 +++++++ inc/poche/Tools.class.php | 3 +++ themes/default/edit-tags.twig | 18 ++++++++++++++++++ themes/default/view.twig | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 themes/default/edit-tags.twig diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 802ec54..5d36884 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -430,6 +430,13 @@ class Poche ); Tools::logm('config view'); break; + case 'edit-tags': + # tags + $tags = $this->store->retrieveTagsByEntry($id); + $tpl_vars = array( + 'tags' => $tags, + ); + break; case 'tags': $tags = $this->store->retrieveAllTags(); $tpl_vars = array( diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 5bb65fe..9d91169 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -106,6 +106,9 @@ class Tools case 'tags': $tpl_file = 'tags.twig'; break; + case 'edit-tags': + $tpl_file = 'edit-tags.twig'; + break; case 'view': $tpl_file = 'view.twig'; break; diff --git a/themes/default/edit-tags.twig b/themes/default/edit-tags.twig new file mode 100644 index 0000000..0bd1aba --- /dev/null +++ b/themes/default/edit-tags.twig @@ -0,0 +1,18 @@ +{% extends "layout.twig" %} +{% block title %}edit tags{% endblock %} +{% block menu %} +{% include '_menu.twig' %} +{% endblock %} +{% block content %} +{% if tags is empty %} +no tags +{% endif %} +
      +{% for tag in tags %}
    • {{ tag.value }}
    • {% endfor %} +
    +
    + + {% trans "you can type several tags, separated by comma" %}
    + +
    +{% endblock %} \ No newline at end of file diff --git a/themes/default/view.twig b/themes/default/view.twig index 5a7c916..9f9e23c 100644 --- a/themes/default/view.twig +++ b/themes/default/view.twig @@ -21,7 +21,7 @@

    {{ entry.title|raw }}

    {{ content | raw }} From 74ec445a662aa31f713bc50e74c9366da336538a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:07:00 +0100 Subject: [PATCH 06/11] [change] simplify Tools::getTplFile --- inc/poche/Tools.class.php | 45 ++++++++------------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 9d91169..b0ef55f 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -88,43 +88,16 @@ class Tools public static function getTplFile($view) { - $default_tpl = 'home.twig'; - - switch ($view) { - case 'install': - $tpl_file = 'install.twig'; - break; - case 'import'; - $tpl_file = 'import.twig'; - break; - case 'export': - $tpl_file = 'export.twig'; - break; - case 'config': - $tpl_file = 'config.twig'; - break; - case 'tags': - $tpl_file = 'tags.twig'; - break; - case 'edit-tags': - $tpl_file = 'edit-tags.twig'; - break; - case 'view': - $tpl_file = 'view.twig'; - break; - case 'login': - $tpl_file = 'login.twig'; - break; - case 'error': - $tpl_file = 'error.twig'; - break; - - default: - $tpl_file = $default_tpl; - break; + $views = array( + 'install', 'import', 'export', 'config', 'tags', + 'edit-tags', 'view', 'login', 'error' + ); + + if (in_array($view, $views)) { + return $view . '.twig'; } - - return $tpl_file; + + return 'home.twig'; } public static function getFile($url) From 4886ed6d3637df0b3e16e672d58d4ef8f17dc432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:22:29 +0100 Subject: [PATCH 07/11] [add] page which lists entries for a tag --- inc/poche/Database.class.php | 21 +++++++++++++++++++++ inc/poche/Poche.class.php | 8 ++++++++ inc/poche/Tools.class.php | 2 +- themes/default/tag.twig | 33 +++++++++++++++++++++++++++++++++ themes/default/tags.twig | 2 +- themes/default/view.twig | 2 +- 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 themes/default/tag.twig diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 8e9ee0b..a89bce4 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -258,6 +258,27 @@ class Database { return $tags; } + public function retrieveTag($id) { + $tag = NULL; + $sql = "SELECT * FROM tags WHERE id=?"; + $params = array(intval($id)); + $query = $this->executeQuery($sql, $params); + $tag = $query->fetchAll(); + + return isset($tag[0]) ? $tag[0] : null; + } + + public function retrieveEntriesByTag($tag_id) { + $sql = + "SELECT * FROM entries + LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id + WHERE tags_entries.tag_id = ?"; + $query = $this->executeQuery($sql, array($tag_id)); + $entries = $query->fetchAll(); + + return $entries; + } + public function retrieveTagsByEntry($entry_id) { $sql = "SELECT * FROM tags diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5d36884..fefbb02 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -437,6 +437,14 @@ class Poche 'tags' => $tags, ); break; + case 'tag': + $entries = $this->store->retrieveEntriesByTag($id); + $tag = $this->store->retrieveTag($id); + $tpl_vars = array( + 'tag' => $tag, + 'entries' => $entries, + ); + break; case 'tags': $tags = $this->store->retrieveAllTags(); $tpl_vars = array( diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index b0ef55f..6da5302 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -90,7 +90,7 @@ class Tools { $views = array( 'install', 'import', 'export', 'config', 'tags', - 'edit-tags', 'view', 'login', 'error' + 'edit-tags', 'view', 'login', 'error', 'tag' ); if (in_array($view, $views)) { diff --git a/themes/default/tag.twig b/themes/default/tag.twig new file mode 100644 index 0000000..364c7cd --- /dev/null +++ b/themes/default/tag.twig @@ -0,0 +1,33 @@ +{% extends "layout.twig" %} +{% block title %}tag {% endblock %} +{% block menu %} +{% include '_menu.twig' %} +{% endblock %} +{% block content %} +

    {% trans "Tag" %} {{ tag.value }}

    + {% if entries is empty %} +

    {% trans "No link available here!" %}

    + {% else %} + {% block pager %} + {% if nb_results > 1 %} +
    +
    {{ nb_results }} {% trans "results" %}
    + {{ page_links | raw }} +
    + {% endif %} + {% endblock %} + {% for entry in entries %} +
    +

    {{ entry.title|raw }}

    + +

    {{ entry.content|striptags|slice(0, 300) }}...

    +
    + {% endfor %} + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/themes/default/tags.twig b/themes/default/tags.twig index 9421fe3..e179143 100644 --- a/themes/default/tags.twig +++ b/themes/default/tags.twig @@ -4,5 +4,5 @@ {% include '_menu.twig' %} {% endblock %} {% block content %} -{% for tag in tags %}{{ tag.value }} {% endfor %} +{% for tag in tags %}{{ tag.value }} {% endfor %} {% endblock %} \ No newline at end of file diff --git a/themes/default/view.twig b/themes/default/view.twig index 9f9e23c..7e096a9 100644 --- a/themes/default/view.twig +++ b/themes/default/view.twig @@ -21,7 +21,7 @@

    {{ entry.title|raw }}

    {{ content | raw }} From f778e47283c9691d2992045e0fbcdfc6685f157f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:37:42 +0100 Subject: [PATCH 08/11] [add] rss for tag --- inc/poche/Poche.class.php | 15 ++++++++++++--- index.php | 3 ++- themes/default/img/default/rss.png | Bin 0 -> 288 bytes themes/default/tags.twig | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 themes/default/img/default/rss.png diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index fefbb02..68f56d6 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -446,8 +446,11 @@ class Poche ); break; case 'tags': + $token = $this->user->getConfigValue('token'); $tags = $this->store->retrieveAllTags(); $tpl_vars = array( + 'token' => $token, + 'user_id' => $this->user->getId(), 'tags' => $tags, ); break; @@ -884,9 +887,9 @@ class Poche $_SESSION['poche_user']->setConfig($currentConfig); } - public function generateFeeds($token, $user_id, $type = 'home') + public function generateFeeds($token, $user_id, $tag_id, $type = 'home') { - $allowed_types = array('home', 'fav', 'archive'); + $allowed_types = array('home', 'fav', 'archive', 'tag'); $config = $this->store->getConfigUser($user_id); if (!in_array($type, $allowed_types) || @@ -901,7 +904,13 @@ class Poche $feed->setChannelElement('updated', date(DATE_RSS , time())); $feed->setChannelElement('author', 'poche'); - $entries = $this->store->getEntriesByView($type, $user_id); + if ($type == 'tag') { + $entries = $this->store->retrieveEntriesByTag($tag_id); + } + else { + $entries = $this->store->getEntriesByView($type, $user_id); + } + if (count($entries) > 0) { foreach ($entries as $entry) { $newItem = $feed->createNewItem(); diff --git a/index.php b/index.php index 96f28a7..836730b 100644 --- a/index.php +++ b/index.php @@ -75,7 +75,8 @@ if (isset($_GET['login'])) { $poche->generateToken(); } else { - $poche->generateFeeds($_GET['token'], $_GET['user_id'], $_GET['type']); + $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); + $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']); } } diff --git a/themes/default/img/default/rss.png b/themes/default/img/default/rss.png new file mode 100644 index 0000000000000000000000000000000000000000..21bad1a174bf152563552aff0e1a397fee05a82b GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt^vJzX3_ zEPBsgF!XW`6li_u-9N+;K)*BZpl-y?R7O3=4IFw-8+chZalBq4=(BL@)Ega1 zyC$q?{eJL+$D_?g%m)&8-vX5;);}d*q9%;X1w!LziDT>u$o#d_? zI?N{v+PLqCI{Y=7z@xq*iFtVi|Af<_r$4e4^9Zfz^?c>OaX-(77i|7FoYlYN)pZy2 z6-G$>IQehFAMI_^8T$%bWbd?FgvPLDD93k%=O%Ut@)gLY&8pzpy!B6Dq~LS2zij6# iG=H>CRh{}ZJK+9#5j$t+{{ tag.value }} {% endfor %} +{% for tag in tags %}{{ tag.value }} {% if token != '' %}{% endif %} {% endfor %} {% endblock %} \ No newline at end of file From c432fa1674fbe2b190cf0d0bab2e90302a61e98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 15:07:51 +0100 Subject: [PATCH 09/11] [add] assign and remove a tag to an entry --- inc/poche/Database.class.php | 31 +++++++++++++++++++++++++++++++ inc/poche/Poche.class.php | 31 +++++++++++++++++++++++++++++++ themes/default/edit-tags.twig | 8 +++++--- themes/default/view.twig | 2 +- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index a89bce4..d95b9b8 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -289,4 +289,35 @@ class Database { return $tags; } + + public function removeTagForEntry($entry_id, $tag_id) { + $sql_action = "DELETE FROM tags_entries WHERE tag_id=? AND entry_id=?"; + $params_action = array($tag_id, $entry_id); + $query = $this->executeQuery($sql_action, $params_action); + return $query; + } + + public function retrieveTagByValue($value) { + $tag = NULL; + $sql = "SELECT * FROM tags WHERE value=?"; + $params = array($value); + $query = $this->executeQuery($sql, $params); + $tag = $query->fetchAll(); + + return isset($tag[0]) ? $tag[0] : null; + } + + public function createTag($value) { + $sql_action = 'INSERT INTO tags ( value ) VALUES (?)'; + $params_action = array($value); + $query = $this->executeQuery($sql_action, $params_action); + return $query; + } + + public function setTagToEntry($tag_id, $entry_id) { + $sql_action = 'INSERT INTO tags_entries ( tag_id, entry_id ) VALUES (?, ?)'; + $params_action = array($tag_id, $entry_id); + $query = $this->executeQuery($sql_action, $params_action); + return $query; + } } diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 68f56d6..d415dd0 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -397,6 +397,36 @@ class Poche Tools::redirect(); } break; + case 'add_tag' : + $tags = explode(',', $_POST['value']); + $entry_id = $_POST['entry_id']; + foreach($tags as $key => $tag_value) { + $value = trim($tag_value); + $tag = $this->store->retrieveTagByValue($value); + + if (is_null($tag)) { + # we create the tag + $tag = $this->store->createTag($value); + $sequence = ''; + if (STORAGE == 'postgres') { + $sequence = 'tags_id_seq'; + } + $tag_id = $this->store->getLastId($sequence); + } + else { + $tag_id = $tag['id']; + } + + # we assign the tag to the article + $this->store->setTagToEntry($tag_id, $entry_id); + } + Tools::redirect(); + break; + case 'remove_tag' : + $tag_id = $_GET['tag_id']; + $this->store->removeTagForEntry($id, $tag_id); + Tools::redirect(); + break; default: break; } @@ -434,6 +464,7 @@ class Poche # tags $tags = $this->store->retrieveTagsByEntry($id); $tpl_vars = array( + 'entry_id' => $id, 'tags' => $tags, ); break; diff --git a/themes/default/edit-tags.twig b/themes/default/edit-tags.twig index 0bd1aba..7116bba 100644 --- a/themes/default/edit-tags.twig +++ b/themes/default/edit-tags.twig @@ -8,11 +8,13 @@ no tags {% endif %}
      -{% for tag in tags %}
    • {{ tag.value }}
    • {% endfor %} +{% for tag in tags %}
    • {{ tag.value }}
    • {% endfor %}
    -
    + - {% trans "you can type several tags, separated by comma" %}
    +

    {% trans "you can type several tags, separated by comma" %}

    +
    +{% trans "back to the article" %} {% endblock %} \ No newline at end of file diff --git a/themes/default/view.twig b/themes/default/view.twig index 7e096a9..64672b6 100644 --- a/themes/default/view.twig +++ b/themes/default/view.twig @@ -21,7 +21,7 @@

    {{ entry.title|raw }}

    {{ content | raw }} From f014856424c3a1d790a7de3ca6b75568b417137f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 15:11:08 +0100 Subject: [PATCH 10/11] [add] tags and tags_entries tables in poche.sqlite --- install/poche.sqlite | Bin 360448 -> 393216 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/install/poche.sqlite b/install/poche.sqlite index 7abf1f62ddbed441a90d283e9236a9bb3011ae84..b911f2720a34def149c1154bf75f591080a5dbe5 100755 GIT binary patch delta 727 zcmZo@5Nl|Vm>@04!@$4*!Z08-QO8)Bhe7v|CT~qG19xRHL*0Yg?E2h#hw2m6{#EB{ zHq_cx7S}D`*!Zy`pecf%U0hX_v8A{qF)1gtBr&}>J~gkTC^Ho(fMBya2e~?ixGID= zI{CONAj>Fda48^x$pY14^$L!mA^x6zKs~;$ejy5e{y-e+GFI!Pzm`+0g~f8OVk~ECm|{GYRBl?8d-7qgl@b4#`Hx&DX1zGcu<$7*A}} zwy8~LU}@y$WfvC}Wo)d32QtV&CX7I(G%(8&b4pVcLR=$45YAHPV-vR)Wn{?AOG&LL zF3ia+NsUh|Ey)M-<3a9-Hw2N)wf}%F6<}ul?kGNkG-vdsjY#zt$_sqGN(97 From 6bf4702608e4f32d66a9840ec93461f653315a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 15:16:02 +0100 Subject: [PATCH 11/11] [add] tags and tags_entries for mysql & postgresql --- install/mysql.sql | 15 +++++++++++++++ install/postgres.sql | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/install/mysql.sql b/install/mysql.sql index 9b01e32..66c4bb3 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -31,4 +31,19 @@ CREATE TABLE IF NOT EXISTS `users_config` ( `name` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE tags ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `value` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE tags_entries ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `entry_id` int(11) NOT NULL, + `tag_id` int(11) NOT NULL, + FOREIGN KEY(entry_id) REFERENCES entries(id) ON DELETE CASCADE, + FOREIGN KEY(tag_id) REFERENCES tags(id) ON DELETE CASCADE, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/install/postgres.sql b/install/postgres.sql index 9e0e827..fe8f559 100644 --- a/install/postgres.sql +++ b/install/postgres.sql @@ -27,4 +27,15 @@ CREATE TABLE users_config ( user_id integer NOT NULL, name varchar(255) NOT NULL, value varchar(255) NOT NULL -); \ No newline at end of file +); + +CREATE TABLE tags ( + id bigserial primary key, + value varchar(255) NOT NULL +); + +CREATE TABLE tags_entries ( + id bigserial primary key, + entry_id integer NOT NULL, + tag_id integer NOT NULL +) \ No newline at end of file