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">
13 <h2><?php yourls_e( 'Bookmarklets' ); ?></h2>
15 <p><?php yourls_e( 'YOURLS comes with handy <span>bookmarklets</span> for easier link shortening and sharing.' ); ?></p>
17 <h3><?php yourls_e( 'Standard or Instant, Simple or Custom' ); ?></h3>
20 <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>
22 <li><?php yourls_e( 'The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing.' ); ?></li>
24 <li><?php yourls_e( 'The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword.' ); ?></li>
26 <li><?php yourls_e( 'The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first.' ); ?></li>
30 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" );
33 <h3><?php yourls_e( 'The Bookmarklets' ); ?></h3>
35 <?php $base_bookmarklet = yourls_admin_url( 'index.php' ); ?>
37 <p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
39 <table class="tblSorter" cellpadding="0" cellspacing="1">
43 <th><?php yourls_e( 'Standard (new page)' ); ?></th>
44 <th><?php yourls_e( 'Instant (popup)' ); ?></th>
49 <th class="header"><?php yourls_e( 'Simple' ); ?></th>
52 <?php $js_code = <<<STANDARD_SIMPLE
53 // Simple Standard Bookmarklet (new page, no keyword asked)
56 enc = encodeURIComponent,
60 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
61 s2 = ((s.toString() == '') ? s : enc(s)),
62 f = '$base_bookmarklet',
64 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
65 ur = l.split(new RegExp(ups))[1],
66 ups = ups.split(/\:/),
67 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2,
73 if (!w.open(u)) l.href = u;
75 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
80 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Shorten' ) );
85 <?php $js_code = <<<POPUP_SIMPLE
86 // Simple Popup (in-page popup dialog, no keyword asked)
88 sc = d.createElement('script'),
90 enc = encodeURIComponent,
91 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
92 ur = l.split(new RegExp(ups))[1],
93 ups = ups.split(/\:/),
94 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
95 window.yourls_callback = function (r) {
97 prompt(r.message, r.short_url);
99 alert('An error occured: ' + r.message);
102 sc.src = '$base_bookmarklet' + p + '&jsonp=yourls';
103 void(d.body.appendChild(sc));
105 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Shorten' ) );
111 <th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th>
114 <?php $js_code = <<<CUSTOM_STANDARD
115 // Custom Standard (new page, prompt for a keyword)
117 enc = encodeURIComponent,
122 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
123 s2 = ((s.toString() == '') ? s : enc(s)),
124 f = '$base_bookmarklet',
126 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
127 ur = l.split(new RegExp(ups))[1],
128 ups = ups.split(/\:/),
129 k = prompt("Custom URL"),
130 k2 = (k ? '&k=' + k : ""),
131 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2 + k2,
135 throw ('ozhismygod');
138 if (!w.open(u)) l = u;
140 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
146 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Custom shorten' ) );
151 <?php $js_code = <<<CUSTOM_POPUP
152 // Custom Popup (prompt for a keyword + on-page popup)
155 k = prompt('Custom URL'),
156 enc = encodeURIComponent,
157 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
158 ur = l.split(new RegExp(ups))[1],
159 ups = ups.split(/\:/),
160 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
161 sc = d.createElement('script');
163 window.yourls_callback = function (r) {
165 prompt(r.message, r.short_url);
167 alert('An error occured: ' + r.message);
170 sc.src = '$base_bookmarklet' + p + '&k=' + k + '&jsonp=yourls';
171 void(d.body.appendChild(sc));
174 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Custom Shorten' ) );
183 <h3><?php yourls_e( 'Social Bookmarklets' ); ?></h3>
185 <p><?php yourls_e( 'Create a short URL and share it on social networks, all in one click!' ); ?>
186 <?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
188 <p><?php yourls_e( 'Shorten and share:' ); ?></p>
191 <?php $js_code = <<<FACEBOOK
194 enc = encodeURIComponent,
195 f = '$base_bookmarklet',
197 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
198 ur = l.split(new RegExp(ups))[1],
199 ups = ups.split(/\:/),
200 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur=' + enc(ur) + '&t=' + enc(d.title) + '&share=facebook',
203 throw ('ozhismygod');
206 if (!window.open(u,'Share','width=500,height=340,left=100','_blank')) l.href = u;
208 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
213 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Facebook' ) );
216 <?php $js_code = <<<TWITTER
220 enc = encodeURIComponent,
224 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
225 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
226 f = '$base_bookmarklet',
228 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
229 ur = l.split(new RegExp(ups))[1],
230 ups = ups.split(/\:/),
231 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + s2 + '&share=twitter',
234 throw ('ozhismygod');
237 if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l = u;
239 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
244 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Twitter' ) );
247 <?php $js_code = <<<TUMBLR
251 enc = encodeURIComponent,
256 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
257 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
258 f = '$base_bookmarklet',
260 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
261 ur = l.split(new RegExp(ups))[1],
262 ups = ups.split(/\:/),
263 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=tumblr',
266 throw ('ozhismygod');
269 if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u;
271 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
276 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Tumblr' ) );
279 <?php yourls_do_action( 'social_bookmarklet_buttons_after' ); ?>
283 <h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2>
285 <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>
288 yourls_e( 'Note: this will probably not work if your web server is running on Windows' );
289 if( yourls_is_windows() )
290 yourls_e( ' (which seems to be the case here)' );
294 <?php if( yourls_is_private() ) { ?>
296 <h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2>
299 yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' );
301 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." );
304 <p><?php yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() ); ?>
305 <?php yourls_e( "(It's a secret. Keep it secret) "); ?></p>
307 <p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p>
310 <li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3>
311 <p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p>
312 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>
315 <li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3>
318 <tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt>
319 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' );
320 <tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>
323 <p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p>
324 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>
325 <p><?php yourls_e( 'Actual values:' ); ?><br/>
326 <tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>
327 <p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p>
331 <p><?php yourls_se( 'See the <a href="%s">API documentation</a> for more', YOURLS_SITE . '/readme.html#API' ); ?></p>
335 <?php } // end is private ?>
337 <?php yourls_html_footer(); ?>