From db8feb39b618eca0ab6bb0000f1d7ed3d6678a7a Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 10 Nov 2005 17:57:01 +0000 Subject: =?UTF-8?q?=20*=20cambiato=20ordinamento=20dei=20tag=20(ora=20?= =?UTF-8?q?=C3=A8=20sempre=20alfabetico)=20=20*=20riordinata=20e=20miglior?= =?UTF-8?q?ata=20la=20form=20di=20add=20=20*=20stile=20per=20la=20form=20d?= =?UTF-8?q?i=20add=20=20*=20corretto=20il=20caricamento=20delle=20favicon?= =?UTF-8?q?=20=20*=20corretta=20la=20pulitura=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Bookmarks/C/Main.pm | 18 +++++++++++++----- lib/Bookmarks/M/DB/Tags.pm | 20 ++++++++++++++++---- lib/Bookmarks/Utils.pm | 6 +++--- root/add_form | 22 +++++++++++++++------- root/links | 2 +- root/style.css | 24 +++++++++++++++++++++++- 6 files changed, 71 insertions(+), 21 deletions(-) diff --git a/lib/Bookmarks/C/Main.pm b/lib/Bookmarks/C/Main.pm index 1e2bf54..d957c5d 100644 --- a/lib/Bookmarks/C/Main.pm +++ b/lib/Bookmarks/C/Main.pm @@ -4,6 +4,7 @@ use strict; use base 'Catalyst::Base'; use Bookmarks::Utils; use File::Slurp; +use List::MoreUtils qw(uniq); =head1 NAME @@ -34,7 +35,7 @@ sub auto : Private { sub tags : Global { my ( $self, $c ) = @_; $c->stash->{template}='tags'; - $c->stash->{tags}=[Bookmarks::M::DB::Tags->get_all_tags_by_popularity()]; + $c->stash->{tags}=[Bookmarks::M::DB::Tags->get_all_tags_by_name()]; } sub tag : Regex('^tag/(.*)$') { @@ -87,21 +88,28 @@ sub add : Global { my ( $self, $c ) = @_; my %pre_link=(); - for my $i (qw(url title descr)) { - $pre_link{$i}=$c->req->param($i); + for my $field (qw(url title descr)) { + $pre_link{$field}=$c->req->param($field); } my @tags=split /[ +]/,($c->req->param('tag')||''); + my ($dblink)=Bookmarks::M::DB::Links->search({url=>$pre_link{url}}); # GET: prepare the form from the URL params if ($c->req->method eq 'GET') { $c->stash->{link}=\%pre_link; $c->stash->{tags}=\@tags; + if (defined $dblink) { + for my $field (qw(url title descr)) { + $c->stash->{link}{$field}||=$dblink->$field(); + } + my @dbtags=map { $_->name() } $dblink->tags(); + $c->stash->{tags}=[ uniq(@tags,@dbtags) ]; + } $c->stash->{template}='add_form'; + $c->stash->{close}=$c->req->param('close'); } # POST: accept data and create link+tags elsif ($c->req->method eq 'POST') { - my ($dblink)=Bookmarks::M::DB::Links->search({url=>$pre_link{url}}); - if (defined $dblink) { Bookmarks::M::DB::LinksTags->search({ link => $dblink->pk() diff --git a/lib/Bookmarks/M/DB/Tags.pm b/lib/Bookmarks/M/DB/Tags.pm index 4ca832a..56ec4fa 100644 --- a/lib/Bookmarks/M/DB/Tags.pm +++ b/lib/Bookmarks/M/DB/Tags.pm @@ -4,20 +4,28 @@ use strict; __PACKAGE__->has_many( links => ['Bookmarks::M::DB::LinksTags' => 'link'] ); -# magari ordiniamoli per popolrità __PACKAGE__->set_sql('related_tags', <<'END_SQL'); -SELECT DISTINCT tags.pk +SELECT DISTINCT tags.pk, tags.name FROM tags, links_tags lt1, links_tags lt2 WHERE tags.pk = lt1.tag AND lt1.link = lt2.link AND lt2.tag = ? AND lt1.tag != lt2.tag +ORDER BY tags.name +END_SQL + +__PACKAGE__->set_sql('name', <<'END_SQL'); +SELECT tags.pk, tags.name, COUNT(links_tags.link) AS how_many + FROM tags LEFT JOIN links_tags + ON tags.pk = links_tags.tag +GROUP BY tags.pk +ORDER BY tags.name END_SQL __PACKAGE__->set_sql('popularity', <<'END_SQL'); SELECT tags.pk, COUNT(links_tags.link) AS how_many - FROM tags, links_tags - WHERE tags.pk = links_tags.tag + FROM tags LEFT JOIN links_tags + ON tags.pk = links_tags.tag GROUP BY tags.pk ORDER BY how_many DESC END_SQL @@ -39,6 +47,10 @@ sub get_all_tags_by_popularity { return $_[0]->search_popularity(); } +sub get_all_tags_by_name { + return $_[0]->search_name(); +} + sub links_sorter($$) { return ($_[1]->access_count || 0) diff --git a/lib/Bookmarks/Utils.pm b/lib/Bookmarks/Utils.pm index b9fec9c..b65b707 100644 --- a/lib/Bookmarks/Utils.pm +++ b/lib/Bookmarks/Utils.pm @@ -28,14 +28,14 @@ sub get_site_icon { m{
+

- +

+

- -

-

- - +

+

- +

+ +

+ + +

+ [% IF mode=='edit' -%] [%- END %] +
\ No newline at end of file diff --git a/root/links b/root/links index c2fa4db..ee07953 100644 --- a/root/links +++ b/root/links @@ -35,7 +35,7 @@ [% FOR tag IN tagset.tags %]
  • - [% tag.name %] + [% tag.name %] [% IF tagset.size() > 1 %] diff --git a/root/style.css b/root/style.css index d7c9dfe..ff8aa36 100644 --- a/root/style.css +++ b/root/style.css @@ -48,6 +48,7 @@ div#related width: 49%; height: 80px; border: solid thin black; background-color: white; + z-index: 2; } div#tagset h2, div#related h2 @@ -129,13 +130,17 @@ div#links ol > li position: relative; display: block; } +div#links ol > li:hover +{ + background-color: rgb(180,180,180); +} div#links ol > li div.link.head span.link.appear { display: block; position: absolute;bottom:0;right:1px; text-align: right; background-color: red; - width: 15px; + width: 15px;height: 100%; text-align: center; } div#links ol > li div.link.details span.link.edit @@ -154,4 +159,21 @@ div#links ol > li div.link.details ul li display: inline; padding:0;margin:0;border:0; padding-left: 5px; margin-left: 5px; border-left: solid thin black; +} + +/* add form */ +label { + display: block; +} +input[type=text], +textarea +{ + width: 100%; + border: none; + border-bottom: solid thin black; +} +input[type=submit] +{ + border: none; + background-color: red; } \ No newline at end of file -- cgit v1.2.3