📄 list.pm
字号:
push @freematch, [$_, $obj]; } } my (@pretext, @text); foreach my $match (@freematch) { my ($type, $obj) = @{$match}; if ($type eq 'tag') { my @users = $obj->users; my $mine = $report_my_tag->($obj, \@users); my $linked = $report_linked_tag->($obj); my $global = $report_global_tag->($obj, \@users); push @pretext, grep(defined $_, $mine, $linked); push @text, grep(defined $_, $global); } else { push @text, join(' ', $obj->noun, $make_link->($obj, $type, 'global')); } } return '' unless @pretext || @text; my @note = ('Note: Your search term matches'); if (@pretext) { my $first = shift @pretext; # only use one, push rest to @text push @note, $first.'.'; push @text, @pretext; push @note, 'It also matches' if @text; } if (@text) { push @note, Bibliotech::Util::speech_join(and => @text).'.'; } return $cgi->div({id => 'freematch'}, @note);}sub html_content_status_line { my ($self) = @_; my $bibliotech = $self->bibliotech; my $command = $bibliotech->command; my $query = $bibliotech->query; my $cgi = $bibliotech->cgi; my $location = $bibliotech->location; my $start = $query->start || 0; my $num = $query->num; return undef unless $start > 0 or defined $num; my $max = $query->lastcount; my $newstart = $start - $num; $newstart = 0 if $newstart < 0; my $newnum = $num; $newnum = $start if $newstart + $newnum > $start; my $prevtext = $cgi->escapeHTML("<< Prev $newnum"); my $prevlink; if ($newstart != $start and $newnum > 0) { my $href = $command->canonical_uri($location, {start => [set => $newstart ? $newstart : undef]}); $prevlink = $cgi->a({href => $href}, $prevtext); } else { $prevlink = $prevtext; } $newstart = $start + $num; $newstart = $max if $newstart > $max; $newnum = $num; $newnum = $max - $newstart if $newstart + $newnum > $max; my $nexttext = $cgi->escapeHTML("Next $newnum >>"); my $nextlink; if ($newstart != $start and $newnum > 0) { my $href = $command->canonical_uri($location, {start => [set => $newstart ? $newstart : undef]}); $nextlink = $cgi->a({href => $href}, $nexttext); } else { $nextlink = $nexttext; } my $first = $start + 1; my $last = $start + $num; $last = $max if $last > $max; $first = 0 if $last == 0; my $status = join(' ', 'Showing entries', $first, 'to', $last, 'of', $max, 'total'); my $spacing = ' ' x 4; return $cgi->br.$cgi->div({id => 'status'}, $prevlink, $spacing, $status, $spacing, $nextlink);}sub html_content_heading { my ($self, $main) = @_; die 'specify main as true or false' unless defined $main; my $bibliotech = $self->bibliotech; my $command = $bibliotech->command; my $cgi = $bibliotech->cgi; my $location = $bibliotech->location; my $heading_dynamic = $self->heading_dynamic($main); my $rss = $command->rss_href($location); return $cgi->div({id => 'mybookmark-title'}, $heading_dynamic) unless $main and $rss; return $cgi->div({id => 'mybookmark-title'}, $cgi->div({id => 'mybookmarkrss'}, $cgi->a({href => $command->ris_href($location)}, $cgi->img({src => $location.'exportlist_button.gif', alt => 'EXPORT LIST', title => 'Export this list to a local reference manager', class => 'rssicon'})) . ' ' . $cgi->a({href => $command->rss_href($location)}, $cgi->img({src => $location.'rss_button.gif', alt => 'RSS', title => 'RSS', class => 'rssicon'})), $cgi->a({href => $location.'guide#rss'}, $cgi->img({src => $location.'help_button.gif', alt => '?', title => 'What are these ?', class => 'helpicon'}))), $cgi->div({id => 'mybookmarktitle'}, $heading_dynamic));}sub html_content_memory_scores_javascript { my ($self, $memory_scores_ref) = @_; return undef unless $memory_scores_ref; my @memory_scores = @{$memory_scores_ref}; return undef unless @memory_scores; my $javascript_block .= 'var tags = {'; my $count = 0; $javascript_block .= join(', ', map { my $label = $_->[0]; $label =~ s/\'/\\\'/g; $count++; "\'$label\':$count"; } sort {$b->[1] <=> $a->[1]} @memory_scores ); $javascript_block .= "};\n"; $javascript_block .= 'var tagids = {'; $javascript_block .= join(', ', map { my $label = $_->[0]; $label =~ s/\'/\\\'/g; my $id = $_->[2]; "\'$label\':\'$id\'"; } @memory_scores ); $javascript_block .= "};\n"; @memory_scores = (); $javascript_block .= <<'EOJ';function usageorder(a, b) { return tags[a] - tags[b];}function alphaorder(a, b) { var al = a.toLowerCase(); var bl = b.toLowerCase(); return ((al < bl) ? -1 : ((al > bl) ? 1 : 0));}function reorder(order) { var list = new Array(); for (var i in tags) { list.push(i); } if (order == 'usage') { list.sort(usageorder); } else { list.sort(alphaorder); } var numtags = list.length; var temp = new Array(); for (var i = 0; i < numtags; i++) { temp.push(document.getElementById(tagids[list[i]]).cloneNode(true)); } var n = document.getElementById('sidetags_cabinet'); for (var i = 0; i < numtags; i++) { n.removeChild(document.getElementById(tagids[list[i]])); } for (var i = 0; i < numtags; i++) { n.appendChild(temp[i]); }}EOJ return $javascript_block;}sub html_content_annotations { my ($self) = @_; my $bibliotech = $self->bibliotech; my $command = $bibliotech->command; my $cgi = $bibliotech->cgi; my @users = $command->user_flun; my @tags = $command->tag_flun; if (@users and @tags) { my @user_tag_annotations; foreach my $user_tag_annotation (Bibliotech::User_Tag_Annotation->by_users_and_tags([map($_->obj, @users)], [map($_->obj, @tags)])) { push @user_tag_annotations, $user_tag_annotation->html_content($bibliotech, 'annotation', 1, 1); } return @user_tag_annotations ? $cgi->div({class => 'user_tag_annotations'}, @user_tag_annotations) : undef; } elsif (!defined($bibliotech->user) and !$command->start and (my @filters = $command->filters_used) == 1) { if ($command->filters_used_only_single(@filters)) { my $register = $self->pleaseregister; my $text; if (@tags) { my $obj = $tags[0]->obj; $text = $obj->standard_annotation_text($bibliotech, $register) if $obj; } elsif (@users) { my $obj = $users[0]->obj; $text = $obj->standard_annotation_text($bibliotech, $register) if $obj; } elsif (my @gangs = $command->gang_flun) { my $obj = $gangs[0]->obj; $text = $obj->standard_annotation_text($bibliotech, $register) if $obj; } elsif (my @dates = $command->date_flun) { my $obj = $dates[0]->obj; $text = $obj->standard_annotation_text($bibliotech, $register) if $obj; } elsif (my @bookmarks = $command->bookmark_flun) { my $obj = $bookmarks[0]->obj; $text = $obj->standard_annotation_text($bibliotech, $register) if $obj; } if ($text) { my $html = Bibliotech::Annotation->standard_annotation_html_content($bibliotech, 'annotation', 1, 1, $text); return $html ? $cgi->div({class => 'standard_annotations'}, $html) : undef; } } } return undef;}sub html_content { my ($self, $class, $verbose, $main) = @_; $main ||= 0; # couple places where undef is not as good my $bibliotech = $self->bibliotech; my $command = $bibliotech->command; my @users = $command->user_flun; $bibliotech->has_rss(1) if $main; # do this before caching so it gets set even when output is sent from cache my $cache_user_id = $self->last_updated_basis_includes_login ? undef : 'anyone'; my ($viewed_user, $viewed_user_id); @users == 1 and $viewed_user = $users[0]->obj and $viewed_user_id = $viewed_user->user_id; my $openurl = 'noopenurl'; if (my $activeuser = $bibliotech->user) { $openurl = defined $activeuser ? $activeuser->openurl_resolver.'/'.$activeuser->openurl_name : 'noopenurl'; } my $cached = $self->memcache_check($bibliotech, class => ref($self), method => 'html_content', ($viewed_user_id ? (id => $viewed_user_id, effective => [undef, $viewed_user]) : (user => $cache_user_id)), ($main ? (path => undef) : (path_without_args => undef)), id => $openurl, options => $self->parts, options => $self->options, options => {class => $class, verbose => $verbose, main => $main}); return $cached if defined $cached; my @list = $self->list(main => $main); my $cgi = $bibliotech->cgi; my $location = $bibliotech->location; my $query = $bibliotech->query; my $heading = $self->heading; my %output; my $javascript_block = ''; my $section = 'main'; my @nonmain; my $href_type; my $add = sub { push @{$output{$section}}, grep(defined $_, @_); }; my $add_main = sub { push @{$output{main}}, grep(defined $_, @_); }; my $add_main_top = sub { unshift @{$output{main}}, grep(defined $_, @_); }; my $add_main_nonmain = sub { $add_main->(map(@{$output{$_}}, @nonmain)); }; if ($main) { my $any_filters = $query->any_filters; my $freematch = $query->freematch; my $geocount = $query->geocount; $add->($self->html_content_annotations); $add->($self->html_content_geoinfo) if $any_filters and $geocount; $add->($self->html_content_freematch_notes($freematch)) if $freematch; $add->($self->html_content_num_options) if $any_filters or $freematch; } my @tags = $command->tag_flun; my @memory_scores; my $create_memory_scores; foreach (@list) { if (!ref $_) { $create_memory_scores = 0; my $text = $_; my $links; if ($text eq 'Cabinet') { if ($heading eq 'Tags') { if (@users) { # created above $text = $command->description_filter(\@users, [['Tags', 0, undef], [undef, 1, "\'s tags"], ['Tags for ', 1, undef]]); } else { my @gangs = $command->gang_flun; $text = $command->description_filter(\@gangs, [['Tags', 0, undef], ['Group ', 1, "\'s tags"], ['Tags for groups ', 1, undef]]); } # $links = $cgi->div({class => 'tagtoggle', id => 'alphatoggle'}, $cgi->a({href => "javascript:reorder(\'alpha\')", class => 'actionlink'}, 'A – Z')) . $cgi->div({class => 'tagtoggle', id => 'usagetoggle'}, $cgi->a({href => "javascript:reorder(\'usage\')", class => 'actionlink'}, 'By Usage')); $links = $cgi->div({ id => 'alphatoggle' }, $cgi->div({ class => 'alphatoggleborder' }, $cgi->div({ class => 'togglewrap' }, $cgi->a({href => "javascript:reorder(\'alpha\')", class => 'actionlink'}, 'A – Z') ) ) ) . $cgi->div({ id => 'usagetoggle' }, $cgi->div({ class => 'usagetoggleborder' }, $cgi->div({ class => 'togglewrap' }, $cgi->a({href => "javascript:reorder(\'usage\')", class => 'actionlink'}, 'By Usage') ) ) ); $create_memory_scores = 1; } elsif ($heading eq 'Users') { if (@tags) { # created above $text = $command->description_filter(\@tags, [['Users', 0, undef], ['Users who used ', 1, undef], ['Users who used ', 1, undef]]); } else { my @gangs = $command->gang_flun; $text = $command->description_filter(\@tags, [['Users', 0, undef], ['Users in group ', 1, undef], ['Users in groups ', 1, undef]]); } } elsif ($heading eq 'Groups') { # @users created above $text = $command->description_filter(\@users, [['Groups', 0, undef], [undef, 1, "\'s groups"], ["Groups for ", 1, undef]]); } $href_type = 'href_search_replacitive'; push @nonmain, $section = 'cabinet'; } elsif ($text eq 'Query') { $text = 'Current view'; $href_type = 'href_search_replacitive'; push @nonmain, $section = 'query'; } elsif ($text eq 'Linked') { if ($heading eq 'Tags') { $text = 'Tags describing these bookmarks'; } elsif ($heading eq 'Users') { $text = 'Users who posted these bookmarks'; } else { $text = 'Linked '.lc($heading); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -