Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 77 lines (66 sloc) 3.777 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
- if @authenticated
  .sidebox
    %h2 Bookmarklet

    %p
      Drag the following link to your bookmarks. Click it to shorten the URL to the page you're currently viewing.
    %p
      %a{ :href => "javascript:var%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:('%22'+enc(s)+'%22')),key=enc('#{@config[:api_key]}'),f='http://#{@config[:hostname]}/api/add',l=d.location,p='?visual=1&api_key='+key+'&url='+enc(l.href),u=f+p;try{if(!/^(.*\.)?tumblrzzz[^.]*$/.test(l.host))throw(0);tstbklt();}catch(z){a%20=function(){if(!w.open(u))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0)" } Shorten with #{@config[:hostname]}

  %h1 How about shortening a URL?

  .the_form
    %form{ :action => '/api/add', :method => 'post' }
      %input{ :type => "hidden", :name => "visual", :value => "1" }
      %p
        %input.big_url{ :type => 'text', :placeholder => "Paste your long URL here...", :name => 'url', :id => 'url', :size => 40, :autocomplete => "off", :spellcheck => 'false' }
        %span{ :style => "font-size: 1.8em;" }= '>'
        %input.big_url{ :type => 'text', :placeholder => "Optional short code", :name => 'short', :id => 'short', :size => 20, :autocomplete => "off", :spellcheck => 'false' }
      %p
        %input.big_url{ :type => 'submit', :name => 'submit', :id => 'submit', :value => "Make it short!" }

  %h2 Recently shortened
  
  %table
    %tr
      %td.label(nowrap='nowrap') Short URL <a href="/?s=code&d=asc">▲</a> <a href="/?s=code&d=desc">▼</a>
      %td.label(nowrap='nowrap') Full URL <a href="/?s=url&d=asc">▲</a> <a href="/?s=url&d=desc">▼</a>
      %td.label(nowrap='nowrap') Clicks <a href="/?s=clicks&d=asc">▲</a> <a href="/?s=clicks&d=desc">▼</a>
      %td.label(nowrap='nowrap') Shortened At <a href="/?s=created_at&d=asc">▲</a> <a href="/?s=created_at&d=desc">▼</a>
      %td.label &nbsp;
    - @urls.each do |url|
      %tr{ :class => is_highlighted?(url) ? 'highlighted' : '' }
        %td.value
          %input{ :type => "text", :value => short_url(url), :class => 'short_url', :size => 31 }
        %td.value.fill <a href="#{url.url}">#{truncate url.url, 130}</a>
        %td.value.center= url.clicks
        %td.value= url.created_at.strftime("%Y-%m-%d %H:%M")
        %td.value.actions
          - if @config[:sharing_targets].include? :twitter
            %a.twitter{ :href => twitter(short_url(url)) }
          - if @config[:sharing_targets].include? :facebook
            %a.facebook{ :href => facebook(short_url(url)) }
          - if @config[:sharing_targets].include? :hyves
            %a.hyves{ :href => hyves(short_url(url)) }
          %a.qrcode{ :href => "#{short_url(url)}.png" }

  :javascript
    $(document).ready(function() {
      $('input.short_url').each(function(index) {
        $(this).mouseup(function() { $(this).select(); });
      });

      if (window.location.search == "") {
        var pathname = window.location.pathname + '?s=created_at&d=desc';
      } else {
        var pathname = window.location.pathname + window.location.search;
      }

      $('#main table tr td.label a').each(function(index) {
        if ($(this).attr('href') == pathname) {
          $(this).addClass('highlight');
        }
      });
    });
- else
  %h1 Please enter your API key
  
  %p
    Please enter your API key below to make sure only you can shorten URLs here.
  
  %form{ :action => '/api/set', :method => 'post' }
    %p
      %label{ :for => 'api_key' } API Key
      %input{ :type => 'password', :name => 'api_key', :id => 'api_key' }
    %p
      %input{ :type => 'submit', :name => 'submit', :id => 'submit', :value => "Let me in" }
Something went wrong with that request. Please try again.