#!/usr/bin/perl # Sean Forman # sf@sports-reference.com # $Date: 2017-03-01 13:42:54 -0500 (Wed, 01 Mar 2017) $ # $Author: sean $ # $Rev: 49518 $ # $HeadURL: http://svn.sports-reference.com/svn/br_repos/SR/trunk/stow_server_www/aaall_www/linker/index.cgi $ # Copyright 2000-2016, SPORTS REFERENCE, LLC All rights reserved. # Get the site lib directory. use FindBin qw($Bin); use lib "$Bin/../../"; use lib "$Bin/../lib"; use JSON; print STDERR "### Bin:$Bin\n"; use Data::Dumper; # Include other modules. use Carp; #use strict; use warnings; # Include our local and global SR modules. use SR::Defaults; use SR::Formatting; use SR::Unicode; use SRlocal::DB; use SRlocal::Constants; use SRlocal::Linker; use SRlocal::Templates; no strict 'refs'; chomp($0); #### [] Starting: "$Bin/$0 " . join(' ',@ARGV) MAIN: { # Get the db handle and a reference to a hash of site params our $site_params_ref = get_site_params($Bin); our $srtemplates = new SRlocal::Templates; our $dbh = get_site_db_connection($Bin); # Get each of the files with a listed stub. my %model = (); # Define the site header values within a hash and send the hash to the # header script. # Build the model for generating the page my $title = 'How to Use the Sports Reference Linker'; my @page_yah; push( @page_yah, qq{Linker How-To} ); my $you_are_here = generate_you_are_here( \@page_yah ); $model{id} = 'linker'; $model{header} = { page_title => $title, page_label => $title, page_url => $SRlocal::Constants::SITE_URL . '/linker/', you_are_here => $you_are_here, qi_section => '/linker/', include_gcs => $FALSE, use_default_keywords => $TRUE, page_description => qq{Use the Sports Reference linker to link player names in your articles and we'll link back to you from those player pages.}, reading_format => $TRUE, }; $model{suppress_inpage_nav} = $TRUE; my $content_ref; $content_ref->{srtemplates} = $srtemplates; $content_ref->{suppress_section_heading_text} = $TRUE; $content_ref->{suppress_inpage_nav} = $TRUE; $content_ref->{suppress_section_heading_text} = $TRUE; $content_ref->{title} = $EMPTY_STR; $content_ref->{section_content} = <<"END_HTML";

Add your blog to our player newsfeeds

This tool allows you to automatically (via just a single click):

You just need to add our bookmarklet and then click it whenever you want to link to our Sports Reference pages. Javascript bookmarklets are like bookmarks, but slightly different. A bookmark contains an address for a webpage and clicking on it sends you to that page. A bookmarklet is a set of javascript instructions for the browser and when you click on it, your browser runs the javascript. Sometimes this will send you to a different page, but often it may just change what you see on the current page. Ours adds links to players on Sports Reference sites to the articles you are writing.

Note: that due to a request from Google we are now adding nofollow attributes to both the links we put on your pages and also the links that appear from our sites to your site. The links still work, but Google no longer considers them for search result purposes. END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); $content_ref->{title} = "Video Explanation of the Process"; $content_ref->{section_content} = <<"END_HTML";

Sports Reference Linker Launch Blog Post

END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); $content_ref->{title} = "Add the Bookmarklet"; my $custom = qq{

Create a custom bookmarklet below

\n}; if ( $SRlocal::Constants::SITE_ID =~ /(cbb|cfb)/ ) { $custom = $EMPTY_STR; } $content_ref->{section_content} = <<"END_HTML"; $custom

$SRlocal::Linker::SITE_HOSTNAME_ABBREV Linker Bookmarklet

To add to your browser you need to do one of the two following things.

  1. Click on, hold, and then drag the link above to your bookmarks or bookmark bar (works in FireFox, Safari, and Chrome). Note that your bookmark bar must be visible (under View or Bookmarks in Chrome, View -> Toolbars in Firefox or View -> Favorites bar in Safari), or
  2. Right Click on the link above and add to favorites or bookmarks (doesn't work for Chrome). Internet Explorer will ask you if you really want to do this. It asks this for all cases where you create a javascript bookmarklet since there is the possibility of security issues from untrustworthy sites.

To make sure you've done it right you can test it with player names. If it doesn't work, you can edit the bookmark url which should appear like the following. Note that there are encoded symbols (necessary for the bookmarklet in some browsers) listed below that may not appear when clicking edit. These are of the form %X or %XX).

END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); if ( $SRlocal::Constants::SITE_ID !~ /(cbb|cfb)/ ) { $content_ref->{title} = "Customize the Bookmarklet"; $content_ref->{section_content} = <<"END_HTML";
$SRlocal::Linker::LINKER_MINORS_PLAYERS_CHOICE
Boldface links
Yes
No

$SRlocal::Linker::SITE_HOSTNAME_ABBREV Linker Bookmarklet

To add to your browser, see instructions above.

To make sure you've done it right, if you edit the bookmark, the url should appear like the following. Note that there are encoded symbols (necessary for the bookmarklet in some browsers) listed below that may not appear when clicking edit. These are of the form %X or %XX).

END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); } else { $content_ref->{title} = "Linker Limitations"; $content_ref->{section_content} = <<"END_HTML";

Due to the large number of players on our college sites, we are restricting to the 12,000 or so most popular players on the site. This list updates daily, and is calculate both for long-term and short-term popularity.

If a backup linebacker or a punter isn't getting linked this is why. You can always add these by hand and we will still pick them up in our parsing of your rss feed. END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); } $content_ref->{title} = "How to Use this with Blogs or Bulletin Boards"; $content_ref->{section_content} = <<"END_HTML";

See a list of supported blog software below.

PLEASE SAVE ANY WORK prior to using the bookmarklet. While we have made a serious effort to never lose any of your content, we can not make any guarantees.

Generally, the easiest way to use the tool is to just write up your post in the blog text box and click the bookmarklet in your brower. The tool grabs the text you wrote, runs it through our player linker and returns the text with links enclosed.

When using with blogs or bulletin boards for adding links to posts while composing, you must click the bookmarklet while using the "Edit Html" or "Html" view rather than the "Visual", "Rich Text", or "Compose" View. You can switch back and forth from the two views, so you can write in the Visual view, switch to the HTML view and click the bookmarklet.

Steps

  1. Save your draft
  2. Change into HTML view if needed
  3. Click the linker bookmarklet
  4. A Working notice should appear, and when it disappears all of the player names should be linked.

Test the bookmarklet here

END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); $content_ref->{title} = "Currently Supported Webpages and Software"; $content_ref->{section_content} = <<"END_HTML"; END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); $content_ref->{title} = "Notes"; $content_ref->{section_content} = <<"END_HTML"; END_HTML push( @{ $model{pagecontent} }, SR::Defaults::output_content_section($content_ref) ); # Print the site's footer. print qq{CONTENT-TYPE:text/html\n\n}; my $output = $srtemplates->process( 'Pages/General.tt2', \%model ); print $output; } #### [] Finished: "$Bin/$0 " . join(' ',@ARGV) __END__