Gossamer Forum
Home : Products : Links 2.0 : Customization :

Span Editor's Picks and Bookmarklet

Quote Reply
Span Editor's Picks and Bookmarklet
Does anyone know what happened to the mod for spanning editor's picks? The link is broken in Resources. I found a few threads about it in here, but nothing with enough information to piece something together--just gives a couple steps of the instructions.

Also, has anyone come up with a bookmark for add.cgi? I've been playing around with John Gotze's old Bookmarklet for Contributors but can't get it to work - though his bookmark for editor's (admin.cgi) works like a dream.

Kathy
Quote Reply
Re: [KM] Span Editor's Picks and Bookmarklet In reply to
I found this in add.cgi. Could this be the reason I can't use the Bookmarklet to add links to add.cgi? Sorry if this is a dumb question, I'm not really very good with perl.

# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Auto submission is not allowed in this directory. Please visit the site to add your entry.");
return;
}
}

Thanks,
Kathty
Quote Reply
Re: [KM] Span Editor's Picks and Bookmarklet In reply to
In links.cfg there is a field to enter what URLs (or IPs) can use the add.cgi; if you left that field blank, then it is not being used, and your add page can be accessed directly (example, by entering it's URL un the browser). If you entered your URL info, then only pages referred by (linking from) that URL can use the add.cgi (example, by clicking the 'Add Resource' button on your home page).

Pointy being, if the field is empty, then it cannot be effecting the Bookmarklet. I have not used those mods, so I am not familiar with them.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Span Editor's Picks and Bookmarklet In reply to
I see. Well, it was a thin chance that I'd found the problem. Sigh. I would like to turn my directory into a sort of open directory project, so am looking for a bookmarklet-like script that allows people to add sites to add.cgi. All the "editor" mods I've seen use admin.cgi, which seems daring to me. I'm just not comfortable with the idea of letting people have access to admin. By having editors submit to add.cgi, the submissions will still have to go through validation and editors won't have access to modify, delete or other records.

Has anyone else built anything like this? Or can you point me in the right direction to find one? I'm not looking for a whole editors program mod, just a bookmark-like method for adding sites to add.cgi.

Thanks,
Kathy
Quote Reply
Re: [KM] Span Editor's Picks and Bookmarklet In reply to
Well, I finally decided to have a go at it. Using the bits of info on the thread http://www.gossamer-threads.com/...orum.cgi?post=148165, I managed to redo the spanning editor's picks mod. I'm still in disbelief, but it actually works. For anyone who is using editor's picks, this is what I did:

In nph-build.cgi replace the build_pick_page subroutine with the following codes:

sub build_pick_page {
# --------------------------------------------------------
# Creates spanned "Editor's Pick" pages.
local ($total, $link_results, $title_linked, $title, $next, $prev);
my (%link_output, $category_clean, $url, $page_num, $prev_page, $next_page, $numlinks);
if ($build_pick_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
$numlinks = 0;
CATEGORY: foreach $category (sort keys %pick_links) {
LINK: for ($i = 0; $i < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$pick_links{$category}});
}
}
$numlinks = $total;
$title_linked = &build_linked_title ("Pick");
open (PICK, ">$build_pick_path/$build_index") or cgierr ("unable to open picks page: $build_pick_path/$build_index. Reason: $!");
print "\tEditor's Picks: $total\n";
close PICK;
$url = $build_pick_url;
$next = $prev = $link_results = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$total_pages=(int($numlinks/$build_links_per_page));
if ($total_pages < $numlinks/$build_links_per_page) {$total_pages++}
$next .= "<b>1</b>"; # new added
for $j(2..($total_pages)){
$next .= qq~ <a href="more$j$build_extension">$j</a>~;
} # end of for #added
$page_num = 2;
$next .= qq~ <a href="more$page_num$build_extension">[Next >>]</a>~;
$p = 1;
$t = 0;
$i = 0;
$r = 0;
foreach $category (sort keys %pick_links) {
$category_clean = &build_clean ($category);
if ($i < $build_links_per_page) {
LINK: for ($q = 0; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
$i++;
}
else {
$r--;
$t = $q;
last; }
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
$r++;
}
}
$p++;
$numlinks = $numlinks - $i;
}
# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
else {
foreach $category (sort keys %pick_links) {
$category_clean = &build_clean ($category);
LINK: for ($q = 0; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
}
}
# Create the main page.
open (PICK, ">$build_pick_path/$build_index") or &cgierr ("unable to open editor's pick page: $build_pick_path/$build_index. Reason: $!");
print PICK &site_html_pick(@pick_links);
close PICK;
# Then we go through the list of links and build on the remaining pages.
while ($next && $build_span_pages) {
if ($numlinks > $build_links_per_page) {
$prev=$next=$next_page=$prev_page="";
$next_page = $page_num+1;
$prev_page = $page_num-1;
if ($page_num == 2){
$prev .= qq~ <a href="$url">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url"> 1</a> ~;}
else {$prev .= qq~ <a href="more$prev_page$build_extension">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url">1</a> ~;
for $k(2..$prev_page){$prev .= qq~ <a href="more$k$build_extension">$k</a>~;}}
$next .= qq~ <b>$page_num</b> ~;
for $m($next_page..$total_pages){$next .= qq~ <a href="more$m$build_extension">$m</a>~;}
$next .= qq~ <a href="more$next_page$build_extension">[Next >>]</a>~;
} # end of if
else {
if ($page_num == $total_pages) {
$prev = $next = $next_page = $prev_page= "";
$prev_page=$total_pages-1;
if ($page_num == 2){
$prev .= qq~ <a href="$url">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url"> 1</a> ~;}
else {$prev .= qq~ <a href="more$prev_page$build_extension">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url">1</a> ~;
for $k(2..$prev_page){$prev .= qq~ <a href="more$k$build_extension">$k</a>~;}
} # end of else
$prev .= qq~ <b>$page_num</b> ~;
} # end of if
} # end of else
$link_results = "";
$i = 0;
$s = 1;
foreach $category (sort keys %pick_links) {
if (($s > $r) && ($i < $build_links_per_page)) {
$category_clean = &build_clean ($category);
$link_output{$category} = "";
LINK: for ($q = $t; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
$i++;
$t = 0;
}
else {
$r--;
$t = $q;
last; }
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
$r++;
}
$s++;
}
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");
$use_html ?
print qq|\tSubpage : <A HREF="|, $url, qq|more$page_num$build_extension" TARGET="_blank">$build_pick_path/more$page_num$build_extension</A>\n| :
print qq|\tSubpage : $build_pick_path/more$page_num$build_extension\n|;

open (PICK, ">$build_pick_path/more$page_num$build_extension") or &cgierr ("unable to open editor's pick page: $build_pick_path/index$page_num$build_extension. Reason: $!");
print PICK &site_html_pick(@pick_links);
close PICK;
$p++;
$numlinks = $numlinks - $i;
if ($page_num == $total_pages) { last; }
else { $page_num++; }
}
print "\n";
}




The rest is given in the other thread, below:



Add these codes to your pick.html template:
Code:
<%if prev%>
<%prev%>
<%endif%>

<%if next%>
<%next%>
<%endif%>
and the following to sub site_html_pick in site_html_templates.pl:
Code:
prev => $prev,
next => $next,
Whoosh. I'm glad that's done.Kathy

Last edited by:

KM: Nov 22, 2004, 2:54 AM