Skip to content

YOURLS URL preview plugin with image caching powered by PhantomJS

License

Notifications You must be signed in to change notification settings

joshp23/YOURLS-Snapshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 

Repository files navigation

YOURLS-Snapshot

YOURLS URL preview plugin with image caching powered by PhantomJS

Snapshot is a visual preview plugin for YOURLS personal URL shortener that uses the power of PhantomJS headless web browser via the Screen PHP library.

Updating to v3.0.0 + from the 2.x.x branch may cause some unexpected behavior. Flushing the cache may be necessary. Note, attempting to install this before the required U-SRV will result in failure.

Features & Function

Easy Configuration

  • Just append your short URL with a '~', or choose a custom character from the admin interface to trigger a preview.
  • Clear, detailed, personalized instructions included for setting up a subdomain service, and more.
  • Highly configurable PhantomJS options dialogue, makes working with the application trivial.
  • All options are easily configured in admin interface and stored in the databse, no file editing.
  • Screen is included and ready to go, no setup required.
  • Cache directory created and moved automatically, no manual file system manipulation required.

Simple integration into other plugins

Because of the U-SRV method of image serving, it is a snap to integrate Snapshot into other plugins. Currently the Rscrub and Compliance plugins utilize this feature.

Seamless, out-of-the-box integration with other plugins

  • If Phishtank-2.0 is installed, the previewed url will be (re)checked against the Phishtank API
    • If there is a hit, a very visible warning is displayed
    • Otherwise the Phistank logo and a friendly message is displayed below the image
  • If Compliance is installed, a small link and message under the preview image is displayed for potentially bad links.

Robust cache features:

  • Set cache expiration times for rendered preview images.
  • Easily monitor cache disk usage via the admin interface.
  • Manual cache flush with granular configuration options.
  • Custom API for cache flushing.
  • Personalized cron example included for use with API, keep the cahce in check with a configurable auto-flush.
  • Self-cleaning: Cached images are deleted when a keyword is removed from database.

Requirements and Installation

  • Install and configure YOURLS 1.7.9 +
  • Install and configure U-SRV v2.0.0 +
  • Install phantomjs: details and prebuilt binaries can be found here
    • NOTE: On Debian/Ubuntu there is a known bug with upstream packaging. Installing the prebuilt binary is therefore reccomended. Ex:
    # cd /opt
    # wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    # tar xjf phantomjs-2.1.1-linux-x86_64.tar.bz2
    # rm phantomjs-2.1.1-linux-x86_64.tar.bz2
    # ln -s /opt/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
    # phantomjs --version
    2.1.1
    
    • Install font requirements for phantomjs
    $ sudo apt-get install fontconfig freetype*
    
  • Grab Snapshot's latest release and extract the snapshot folder into YOURLS/user/plugins/
  • Permissions:
    • Recursively make the folder YOURLS/user/plugins/snapshot/assets/screen/jobs writable by your webserver
    • Make the directory YOURLS/user writable by your webserver OR create a YOURLS/user/cache/snapshot/ directory that is writable by your webserver.
  • Go to the YOURLS Manage Plugins page and enable this plugin.
  • Go to the Snapshot page and follow the instructions there.

Optional

  • configure a cron job to keep up on cache maintanence

Notes

  1. If you installed via binary make sure totake note of the location of the phantomjs binary.
  2. Your webserver needs to have write permissions in order to make the cache directory. If you run into errors, try making the director and setting chmod 0777 manually.
  3. Please see the TODO list for future feature enhancements
  4. By default Snapshot will keep an error log in its own directory provided permissions are correctly set. This behavior can be disabled in the admin section.

Credits

OZH's original preview plugin was used as the original code base.

If you appreciate this code and want to show thanks, please feel free go to my website and drop a donation.

Disclaimer

This plugin is offered "as is", and may or may not work for you. Give it a try, and have fun! If you run into any problems, please open up an issue on github, or simply submit a pull request with your fix.

Tips

Dogecoin: DARhgg9q3HAWYZuN95DKnFonADrSWUimy3

===========================

Copyright (C) 2016 Josh Panter

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.