Code Monkey home page Code Monkey logo

mt-plugin-id-shorts's Introduction

ID Shorts

Author: David Raynes Shortcode Additions: Steve Ivy Config Assistant Conversion: Byrne Reese

Testing and Generally Inspiring Fellow: Matt Jacobs

Overview

This plugin provides a way to pass an entry ID or other shortcode to a cgi script and have it send the user to the entry permalink.

Creating the shortcode

The plugin allows for several kinds of shortcodes that may be used, all can be created from the edit entry screen:

  1. The entry id - this is the default value and can be used for any entry by visiting http://example.com/mt-directory/mt/id-shorts.cgi?id=[mt:EntryID]
  2. An auto-generated "shortcode" - click the "Generate Shortcode" link to autogenerate a shortcode that can be passed to the cgi: http://example.com/mt-directory/mt/id-shorts.cgi?id=[shortcode]
  3. A custom code or vanity path, entered into the Short URL Path field

After a value has been saved for the entry, a "Link" link will appear next to the "Generate Shortcode" link. This link will let you copy or visit the existing shortcode for an entry or page.

Using the "Generate Shortcode" link will hide the "Link" link until the entry is resaved, as the old link will no longer be valid.

WARNING: Changing the shortcode or vanity path for an entry will break any existing links to that shortcode.

Installation

Unarchive the plugin and copy id-shorts.cgi into your main Movable Type directory. Copy the contents of the plugins/ folder into your plugins/ directory.

Usage

  1. Edit an entry or page
  2. Find the Short URL Path setting under "basename":
  3. Generate a random shortcode for the entry or page, or enter a custom path
  4. Save the entry.
  5. Click on the "Link" link next to the shortcode field to visit the short url.
  6. Get sent back to the entry or page's permalink.

Rewrites

This plugin works best when you combine it with a tool like Apache's mod_rewrite. Add this to your Apache config or .htaccess file:

RewriteEngine On
RewriteRule ^(\d{1,6})$ /cgi-bin/mt/id-shorts.cgi?id=$1 [L,R]

This says any one to six digit string after the hostname will be passed to id-shorts.cgi. Of course, you'll want to change the path to match the actual location of your MT install and make the sure the matched text doesn't conflict with a file or another rewrite rule. After this, you should be able to visit http://super-awesome-url.biz/[mt:EntryID] and go to the entry.

Tags

This plugin adds the <mt:entryshorturl> tag. The output of this tag is based on the blog level plugin setting for the short url template, which defaults to <mt:blogurl><mt:var name='id_shorts_path' />.

Plugin Settings:

IdShorts provides two blog-level plugin settings, and one system-level setting. The blog-level settings are:

  • Track Clicks: With this option selected, IdShorts will record each time an entries short url is clicked, and display this value on the edit entry (or page) screen.
  • Short URL Template: This micro-template should be updated to match any custom paths set in your apache rewrite rules. For example, if you limit shorted urls to a /s/ namespace on your server, your Short URL Template value should be <mt:blogurl>/s/<mt:var name='id_shorts_path' />.

The system level-setting is:

  • 404 Document: Because IdShorts can be configured (via mod_rewrite) to look for a short url when a file or directory is not found, it can bypass Apache's ErrorDocument 404 handling. In these (hopefully rare) cases, you can tell IdShorts what file to serve to users to when both a file-system check and a short-url check have failed.

Credits

mt-plugin-id-shorts's People

Contributors

capndesign avatar rayners avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

danwolfgang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.