summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-09-30 16:53:52 +0200
committerYorhel <git@yorhel.nl>2020-09-30 16:56:29 +0200
commit6c3f5cd16cdf55f0cb8a52cbdb350af337f44445 (patch)
treef4f00f550e725dc31b9087c6daabde1133293a92
parent15b0e76e478a54fb08dee248b4b5efe829bbfbf5 (diff)
refactoring: Merge Tags/ and Traits/ into TT/
There ended up being more code reuse than I had expected. The only functionality that's still missing is the main tag/trait pages themselves, but I think they're similar enough to share code as well. (I might even be able to merge TagEdit & TraitEdit, but that'll be a more involved change)
-rw-r--r--lib/VNWeb/TT/Elm.pm (renamed from lib/VNWeb/Traits/Elm.pm)22
-rw-r--r--lib/VNWeb/TT/Index.pm (renamed from lib/VNWeb/Tags/Index.pm)4
-rw-r--r--lib/VNWeb/TT/Lib.pm (renamed from lib/VNWeb/Tags/Lib.pm)2
-rw-r--r--lib/VNWeb/TT/List.pm (renamed from lib/VNWeb/Tags/List.pm)6
-rw-r--r--lib/VNWeb/TT/TagEdit.pm (renamed from lib/VNWeb/Tags/Edit.pm)2
-rw-r--r--lib/VNWeb/TT/TagLinks.pm (renamed from lib/VNWeb/Tags/Links.pm)4
-rw-r--r--lib/VNWeb/TT/TraitEdit.pm (renamed from lib/VNWeb/Traits/Edit.pm)2
-rw-r--r--lib/VNWeb/Tags/Elm.pm24
-rw-r--r--lib/VNWeb/VN/Tagmod.pm1
9 files changed, 30 insertions, 37 deletions
diff --git a/lib/VNWeb/Traits/Elm.pm b/lib/VNWeb/TT/Elm.pm
index fc0d0207..f109dadd 100644
--- a/lib/VNWeb/Traits/Elm.pm
+++ b/lib/VNWeb/TT/Elm.pm
@@ -1,7 +1,27 @@
-package VNWeb::Traits::Elm;
+package VNWeb::TT::Elm;
use VNWeb::Prelude;
+elm_api Tags => undef, { search => {} }, sub {
+ my $q = shift->{search};
+ my $qs = sql_like $q;
+
+ elm_TagResult tuwf->dbPagei({ results => 15, page => 1 },
+ 'SELECT t.id, t.name, t.searchable, t.applicable, t.state
+ FROM (',
+ sql_join('UNION ALL',
+ $q =~ /^$RE{gid}$/ ? sql('SELECT 1, id FROM tags WHERE id =', \"$+{id}") : (),
+ sql('SELECT 1+substr_score(lower(name),', \$qs, '), id FROM tags WHERE name ILIKE', \"%$qs%"),
+ sql('SELECT 10+substr_score(lower(alias),', \$qs, '), tag FROM tags_aliases WHERE alias ILIKE', \"%$qs%"),
+ ), ') x (prio, id)
+ JOIN tags t ON t.id = x.id
+ WHERE t.state <> 1
+ GROUP BY t.id, t.name, t.searchable, t.applicable, t.state
+ ORDER BY MIN(x.prio), t.name
+ ')
+};
+
+
elm_api Traits => undef, { search => {} }, sub {
my $q = shift->{search};
my $qs = sql_like $q;
diff --git a/lib/VNWeb/Tags/Index.pm b/lib/VNWeb/TT/Index.pm
index b883aae2..16d5076a 100644
--- a/lib/VNWeb/Tags/Index.pm
+++ b/lib/VNWeb/TT/Index.pm
@@ -1,7 +1,7 @@
-package VNWeb::Tags::Index;
+package VNWeb::TT::Index;
use VNWeb::Prelude;
-use VNWeb::Tags::Lib 'enrich_group';
+use VNWeb::TT::Lib 'enrich_group';
sub tree_ {
diff --git a/lib/VNWeb/Tags/Lib.pm b/lib/VNWeb/TT/Lib.pm
index e9935629..7521b4f0 100644
--- a/lib/VNWeb/Tags/Lib.pm
+++ b/lib/VNWeb/TT/Lib.pm
@@ -1,4 +1,4 @@
-package VNWeb::Tags::Lib;
+package VNWeb::TT::Lib;
use VNWeb::Prelude;
use Exporter 'import';
diff --git a/lib/VNWeb/Tags/List.pm b/lib/VNWeb/TT/List.pm
index 54da1f86..8cabc773 100644
--- a/lib/VNWeb/Tags/List.pm
+++ b/lib/VNWeb/TT/List.pm
@@ -1,9 +1,7 @@
-# XXX: Also used for the trait listing
-
-package VNWeb::Tags::List;
+package VNWeb::TT::List;
use VNWeb::Prelude;
-use VNWeb::Tags::Lib 'enrich_group';
+use VNWeb::TT::Lib 'enrich_group';
sub listing_ {
diff --git a/lib/VNWeb/Tags/Edit.pm b/lib/VNWeb/TT/TagEdit.pm
index d8e02506..87013d41 100644
--- a/lib/VNWeb/Tags/Edit.pm
+++ b/lib/VNWeb/TT/TagEdit.pm
@@ -1,4 +1,4 @@
-package VNWeb::Tags::Edit;
+package VNWeb::TT::TagEdit;
use VNWeb::Prelude;
diff --git a/lib/VNWeb/Tags/Links.pm b/lib/VNWeb/TT/TagLinks.pm
index e3294520..0948a309 100644
--- a/lib/VNWeb/Tags/Links.pm
+++ b/lib/VNWeb/TT/TagLinks.pm
@@ -1,7 +1,7 @@
-package VNWeb::Tags::Links;
+package VNWeb::TT::TagLinks;
use VNWeb::Prelude;
-use VNWeb::Tags::Lib;
+use VNWeb::TT::Lib;
sub listing_ {
diff --git a/lib/VNWeb/Traits/Edit.pm b/lib/VNWeb/TT/TraitEdit.pm
index afb44fa4..11320a7e 100644
--- a/lib/VNWeb/Traits/Edit.pm
+++ b/lib/VNWeb/TT/TraitEdit.pm
@@ -1,4 +1,4 @@
-package VNWeb::Traits::Edit;
+package VNWeb::TT::TraitEdit;
use VNWeb::Prelude;
diff --git a/lib/VNWeb/Tags/Elm.pm b/lib/VNWeb/Tags/Elm.pm
deleted file mode 100644
index 089487d7..00000000
--- a/lib/VNWeb/Tags/Elm.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-package VNWeb::Tags::Elm;
-
-use VNWeb::Prelude;
-
-elm_api Tags => undef, { search => {} }, sub {
- my $q = shift->{search};
- my $qs = sql_like $q;
-
- elm_TagResult tuwf->dbPagei({ results => 15, page => 1 },
- 'SELECT t.id, t.name, t.searchable, t.applicable, t.state
- FROM (',
- sql_join('UNION ALL',
- $q =~ /^$RE{gid}$/ ? sql('SELECT 1, id FROM tags WHERE id =', \"$+{id}") : (),
- sql('SELECT 1+substr_score(lower(name),', \$qs, '), id FROM tags WHERE name ILIKE', \"%$qs%"),
- sql('SELECT 10+substr_score(lower(alias),', \$qs, '), tag FROM tags_aliases WHERE alias ILIKE', \"%$qs%"),
- ), ') x (prio, id)
- JOIN tags t ON t.id = x.id
- WHERE t.state <> 1
- GROUP BY t.id, t.name, t.searchable, t.applicable, t.state
- ORDER BY MIN(x.prio), t.name
- ')
-};
-
-1;
diff --git a/lib/VNWeb/VN/Tagmod.pm b/lib/VNWeb/VN/Tagmod.pm
index 70c82970..c6af98c4 100644
--- a/lib/VNWeb/VN/Tagmod.pm
+++ b/lib/VNWeb/VN/Tagmod.pm
@@ -1,7 +1,6 @@
package VNWeb::VN::Tagmod;
use VNWeb::Prelude;
-use VNWeb::Tags::Lib;
my $FORM = {