2 define( 'YOURLS_ADMIN', true );
3 require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
4 yourls_maybe_require_auth();
6 yourls_html_head( 'tools', yourls__( 'Cool YOURLS Tools' ) );
11 <div class="sub_wrap">
14 <h2><?php yourls_e( 'Bookmarklets' ); ?></h2>
16 <p><?php yourls_e( 'YOURLS comes with handy <span>bookmarklets</span> for easier link shortening and sharing.' ); ?></p>
18 <h3><?php yourls_e( 'Standard or Instant, Simple or Custom' ); ?></h3>
21 <li><?php yourls_e( 'The <span>Standard Bookmarklets</span> will take you to a page where you can easily edit or delete your brand new short URL.' ); ?></li>
23 <li><?php yourls_e( 'The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing.' ); ?></li>
25 <li><?php yourls_e( 'The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword.' ); ?></li>
27 <li><?php yourls_e( 'The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first.' ); ?></li>
31 yourls_e( "If you want to share a description along with the link you're shortening, simply <span>select text</span> on the page you're viewing before clicking on your bookmarklet link" );
34 <h3><?php yourls_e( 'The Bookmarklets' ); ?></h3>
36 <?php $base_bookmarklet = yourls_admin_url( 'index.php' ); ?>
38 <p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
40 <table class="tblSorter" cellpadding="0" cellspacing="1">
44 <th><?php yourls_e( 'Standard (new page)' ); ?></th>
45 <th><?php yourls_e( 'Instant (popup)' ); ?></th>
50 <th class="header"><?php yourls_e( 'Simple' ); ?></th>
53 <?php $js_code = <<<STANDARD_SIMPLE
54 // Simple Standard Bookmarklet (new page, no keyword asked)
57 enc = encodeURIComponent,
61 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
62 s2 = ((s.toString() == '') ? s : enc(s)),
63 f = '$base_bookmarklet',
65 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
66 ur = l.split(new RegExp(ups))[1],
67 ups = ups.split(/\:/),
68 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2,
74 if (!w.open(u)) l.href = u;
76 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
81 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Shorten' ) );
86 <?php $js_code = <<<POPUP_SIMPLE
87 // Simple Popup (in-page popup dialog, no keyword asked)
89 sc = d.createElement('script'),
91 enc = encodeURIComponent,
92 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
93 ur = l.split(new RegExp(ups))[1],
94 ups = ups.split(/\:/),
95 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
96 window.yourls_callback = function (r) {
98 prompt(r.message, r.short_url);
100 alert('An error occured: ' + r.message);
103 sc.src = '$base_bookmarklet' + p + '&jsonp=yourls';
104 void(d.body.appendChild(sc));
106 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Shorten' ) );
112 <th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th>
115 <?php $js_code = <<<CUSTOM_STANDARD
116 // Custom Standard (new page, prompt for a keyword)
118 enc = encodeURIComponent,
123 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
124 s2 = ((s.toString() == '') ? s : enc(s)),
125 f = '$base_bookmarklet',
127 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
128 ur = l.split(new RegExp(ups))[1],
129 ups = ups.split(/\:/),
130 k = prompt("Custom URL"),
131 k2 = (k ? '&k=' + k : ""),
132 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2 + k2,
136 throw ('ozhismygod');
139 if (!w.open(u)) l = u;
141 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
147 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Custom shorten' ) );
152 <?php $js_code = <<<CUSTOM_POPUP
153 // Custom Popup (prompt for a keyword + on-page popup)
156 k = prompt('Custom URL'),
157 enc = encodeURIComponent,
158 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
159 ur = l.split(new RegExp(ups))[1],
160 ups = ups.split(/\:/),
161 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
162 sc = d.createElement('script');
164 window.yourls_callback = function (r) {
166 prompt(r.message, r.short_url);
168 alert('An error occured: ' + r.message);
171 sc.src = '$base_bookmarklet' + p + '&k=' + k + '&jsonp=yourls';
172 void(d.body.appendChild(sc));
175 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Custom Shorten' ) );
184 <h3><?php yourls_e( 'Social Bookmarklets' ); ?></h3>
186 <p><?php yourls_e( 'Create a short URL and share it on social networks, all in one click!' ); ?>
187 <?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
189 <p><?php yourls_e( 'Shorten and share:' ); ?></p>
192 <?php $js_code = <<<FACEBOOK
195 enc = encodeURIComponent,
196 f = '$base_bookmarklet',
198 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
199 ur = l.split(new RegExp(ups))[1],
200 ups = ups.split(/\:/),
201 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur=' + enc(ur) + '&t=' + enc(d.title) + '&share=facebook',
204 throw ('ozhismygod');
207 if (!window.open(u,'Share','width=500,height=340,left=100','_blank')) l.href = u;
209 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
214 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Facebook' ) );
217 <?php $js_code = <<<TWITTER
221 enc = encodeURIComponent,
225 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
226 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
227 f = '$base_bookmarklet',
229 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
230 ur = l.split(new RegExp(ups))[1],
231 ups = ups.split(/\:/),
232 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + s2 + '&share=twitter',
235 throw ('ozhismygod');
238 if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l = u;
240 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
245 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Twitter' ) );
248 <?php $js_code = <<<TUMBLR
252 enc = encodeURIComponent,
257 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
258 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
259 f = '$base_bookmarklet',
261 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
262 ur = l.split(new RegExp(ups))[1],
263 ups = ups.split(/\:/),
264 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=tumblr',
267 throw ('ozhismygod');
270 if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u;
272 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
277 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Tumblr' ) );
280 <?php yourls_do_action( 'social_bookmarklet_buttons_after' ); ?>
284 <h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2>
286 <p><?php yourls_se( "When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add \"<span>%s</span>\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', YOURLS_SITE) . '/' ); ?></p>
289 yourls_e( 'Note: this will probably not work if your web server is running on Windows' );
290 if( yourls_is_windows() )
291 yourls_e( ' (which seems to be the case here)' );
295 <?php if( yourls_is_private() ) { ?>
297 <h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2>
300 yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' );
302 yourls_e( "If you're worried about sending your credentials into the wild, you can also make API calls without using your login or your password, using a secret signature token." );
305 <p><?php yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() ); ?>
306 <?php yourls_e( "(It's a secret. Keep it secret) "); ?></p>
308 <p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p>
311 <li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3>
312 <p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p>
313 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>
316 <li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3>
319 <tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt>
320 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' );
321 <tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>
324 <p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p>
325 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>
326 <p><?php yourls_e( 'Actual values:' ); ?><br/>
327 <tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>
328 <p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p>
332 <p><?php yourls_se( 'See the <a href="%s">API documentation</a> for more', YOURLS_SITE . '/readme.html#API' ); ?></p>
337 <?php } // end is private ?>
339 <?php yourls_html_footer(); ?>