summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2005-11-10 17:57:01 +0000
committerdakkar <dakkar@luxion>2005-11-10 17:57:01 +0000
commitdb8feb39b618eca0ab6bb0000f1d7ed3d6678a7a (patch)
tree0092ed285e1ea4992e0e2af43e3ef8fe5ea29679
parentfatto stile per la lista di link, messo il JS in file (diff)
downloadBookmarks-db8feb39b618eca0ab6bb0000f1d7ed3d6678a7a.tar.gz
Bookmarks-db8feb39b618eca0ab6bb0000f1d7ed3d6678a7a.tar.bz2
Bookmarks-db8feb39b618eca0ab6bb0000f1d7ed3d6678a7a.zip
* cambiato ordinamento dei tag (ora è sempre alfabetico)
* riordinata e migliorata la form di add * stile per la form di add * corretto il caricamento delle favicon * corretta la pulitura tags
-rw-r--r--lib/Bookmarks/C/Main.pm18
-rw-r--r--lib/Bookmarks/M/DB/Tags.pm20
-rw-r--r--lib/Bookmarks/Utils.pm6
-rw-r--r--root/add_form22
-rw-r--r--root/links2
-rw-r--r--root/style.css24
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{<link
\s+
(?:
- rel="shortcut\ icon"
+ rel="(?:shortcut\ +)?icon"
\s+
href="(.*?)"
)|(?:
href="(.*?)"
\s+
- rel="shortcut\ icon"
- )}smx);
+ rel="(?:shortcut\ +)?icon"
+ )}ismx);
if (!$favicon) {
$favicon='/favicon.ico';
}
diff --git a/root/add_form b/root/add_form
index b403a3d..d6a32d6 100644
--- a/root/add_form
+++ b/root/add_form
@@ -7,28 +7,36 @@
</head>
<body>
<form action="[% href.add_action() %]" method="post">
+
<p>
<label for="url">Link:</label>
- <input id="url" name="url" type="text" value="[% link.url %]" />
+ <input id="url" name="url" type="text" size="30" value="[% link.url %]" />
</p>
+
<p>
<label for="title">Title:</label>
- <input id="title" name="title" type="text" value="[% link.title %]" />
- </p>
- <p>
- <label for="descr">Description:</label>
- <input id="descr" name="descr" type="text" value="[% link.descr %]" />
+ <input id="title" name="title" type="text" size="30" value="[% link.title %]" />
</p>
+
<p>
<label for="tag_field">Tags:</label>
- <input autocomplete="off" id="tag_field" name="tag" type="text" value="[% tags.join(' ') %]" />
+ <input autocomplete="off" id="tag_field" name="tag" type="text" size="30" value="[% tags.join(' ') %]" />
</p>
<div id="tag_field_auto_complete" class="auto_complete"></div>
<script type="text/javascript">new Ajax.Autocompleter('tag_field', 'tag_field_auto_complete', '[% href.tag_autocomplete() %]', { tokens: ' ' })</script>
+
+ <p>
+ <label for="descr">Description:</label>
+ <textarea id="descr" name="descr" cols="30" rows="4">
+ [%- link.descr -%]
+ </textarea>
+ </p>
+
<input type="submit" name="add" value="Submit" />
[% IF mode=='edit' -%]
<input type="submit" name="delete" value="Delete" />
[%- END %]
+ <input type="hidden" name="close" value="[% close %]" />
</form>
</body>
</html> \ 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 %]
<li>
<span class="tag name">
- <a href="[% href.tag_info(tag) %]" target="_self">[% tag.name %]</a>
+ <a href="[% href.to_tag(tag) %]" target="_self">[% tag.name %]</a>
</span>
[% IF tagset.size() > 1 %]
<span class="tag remove">
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