Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Short URL based off folder indices

I don't mean to push for new features, since what makes Stacey great is its simplicity, but I feel this feature would be easy to implement and appeal to a lot of users.

The idea is that the url_to_file_path function would examine the URL to see if it was comprised of only digits. If so, it would try to match those digits with the indices of content folders.

Using the site structure the official Stacey site:


1.how-it-works/
2.installation/
3.in-use/
4.download-templates/
5.documentation/
1.creating-pages/
2.editing-templates/
3.variable-types/
4.rss-atom-json/


staceyapp.com/1/ would be the short url for staceyapp.com/how-it-works. staceyapp.com/5/3/ would link to staceyapp.com/documentation/variable-types/

There would need to be a new variable @shorturl.

There are a couple problems I can think of: 1. This idea does fall short for unindexed content folders like tutorials/ and download/. 2. In order to avoid conflicts between parsing long or short urls, folders cannot be named just with digits like 1.010/, 2.020/, 3.30
2 people like
this idea
+1
Reply
  • I like the idea of this, but it does have it's problems.
    It also means that the short urls are referring to a page's position, rather than being an alternate permalink.
    For example, if pages were reordered by number, but the names themselves stayed the same, then short urls would now point to different pages, or even straight to 404s.

    What would work nicer would be a built in url shortener, which kept track of the original urls that were pointed to and returned the correct headers (ie. 301 - moved). This would be a bit more work though.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • I’m unsure
    I've updated my page-data.inc.php file with the following code which creates the @short_url variable using the bit.ly API. You'll need to register for your own API account name and key.

    It's been a long time since I've written any code so if anyone can show how to clean this up would be much appreciated!

    # @short_url
    $full_url = 'http://api.bit.ly/v3/shorten?login=YO...;

    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$full_url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);

    $page->short_url = $data;
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited