This commit is contained in:
Tom Slominski
2011-05-07 12:44:45 +01:00
parent 618fa91271
commit 675f103ff1
11 changed files with 534 additions and 40 deletions

View File

@@ -6,15 +6,24 @@ require_once( dirname(__FILE__).'/includes/load-yourls.php' );
<head> <head>
<title>kwl.me</title> <title>kwl.me</title>
<link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/public.css" type="text/css" media="screen" /> <script src="<?php echo YOURLS_SITE; ?>/js/jquery-1.4.3.min.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<script src="<?php echo YOURLS_SITE; ?>/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="<?php echo YOURLS_SITE; ?>/js/ZeroClipboard.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> <script src="<?php echo YOURLS_SITE; ?>/js/ZeroClipboard.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
<script type="text/javascript">ZeroClipboard.setMoviePath( '<?php echo YOURLS_SITE; ?>/js/ZeroClipboard.swf' );</script> <script type="text/javascript">ZeroClipboard.setMoviePath( '<?php echo YOURLS_SITE; ?>/js/ZeroClipboard.swf' );</script>
<script src="<?php echo YOURLS_SITE; ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> <script src="<?php echo YOURLS_SITE; ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
<!-- Formalize --> <!-- Custom -->
<link rel="stylesheet" href="css/formalize.css" /> <link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/public/formalize.css" />
<script src="js/jquery.formalize.min.js"></script> <script src="<?php echo YOURLS_SITE; ?>/public/js/jquery.formalize.min.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<script src="<?php echo YOURLS_SITE; ?>/public/js/jquery.qtip.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/public/jquery.qtip.min.css" />
<link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/public/public.css" type="text/css" media="screen" />
<script>
$(document).ready(function()
{
// Match all A links with a title tag and use it as the content (default).
$('label[title]').qtip();
});
</script>
</head> </head>
<body> <body>
@@ -34,28 +43,6 @@ require_once( dirname(__FILE__).'/includes/load-yourls.php' );
$url = yourls_sanitize_url( $_REQUEST['url'] ); $url = yourls_sanitize_url( $_REQUEST['url'] );
$keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ; $keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ;
$title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ; $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ;
// Mr. Tech- URL Sanitizing
function valid_url($str) {
return ( ! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $str))
? FALSE : TRUE;
}
$url = yourls_sanitize_url($_REQUEST['url']);
if (!valid_url($url)) {
die( 'Invalid url, go back and try again' );
}
// Mr. Tech- Bans
$url = $_REQUEST['url'];
foreach ($yourls_banned_URL as $banned_url) {
if (stristr($url, $banned_url)) {
die( 'Banned site' );
}
}
$return = yourls_add_new_link( $url, $keyword, $title ); $return = yourls_add_new_link( $url, $keyword, $title );
$shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : ''; $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';
@@ -63,14 +50,19 @@ foreach ($yourls_banned_URL as $banned_url) {
$title = isset( $return['title'] ) ? $return['title'] : ''; $title = isset( $return['title'] ) ? $return['title'] : '';
echo <<<RESULT echo <<<RESULT
<h2>URL has been shortened</h2> <h2>Your URL has been shortened</h2>
<p>Original URL: <code><a href="$url">$url</a></code></p> <p>$message</p>
<p>Short URL: <code><a href="$shorturl">$shorturl</a></code></p> <div class="output">
<p><strong>$message</strong></p> <p>Original URL: <a href="$url">$url</a></p>
<p>Short URL: <a href="$shorturl">$shorturl</a></p>
<p>Stats: <a href="$shorturl+">$shorturl+</a></p>
</div>
<h2>Share</h2>
<p>Share your short URL</p>
<a href="http://twitter.com/share" class="twitter-share-button" data-url="$shorturl" data-text="$keyword" data-count="vertical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<iframe src="http://www.facebook.com/plugins/like.php?href=$shorturl&amp;send=false&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=90" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:55px; height:60px;" allowTransparency="true"></iframe>
RESULT; RESULT;
// Include the Copy box and the Quick Share box
yourls_share_box( $url, $shorturl, $title );
// Part to be executed when no form has been submitted // Part to be executed when no form has been submitted
} else { } else {
@@ -79,12 +71,13 @@ RESULT;
echo <<<HTML echo <<<HTML
<h2>Enter a new URL to shorten</h2> <h2>Enter a new URL to shorten</h2>
<h3>Hover over the labels to see more information</h3>
<form method="post" action=""> <form method="post" action="">
<p><label>URL (required):</label> <input type="text" name="url" value="Paste the long URL here" onfocus="if(this.value == this.defaultValue) this.value = ''" class="right" /></p> <p><label for="url" title="Paste the long URL here">Long URL (required):</label> <input type="text" id="url" class="right" name="url" /></p>
<p><label>Custom keyword:</label> <input type="text" name="keyword" value="A keyword replaces the default short string" onfocus="if(this.value == this.defaultValue) this.value = ''" class="right" /></p> <p><label for="keyword" title="A keyword replaces the default short string">Custom keyword:</label> <input type="text" id="keyword" class="right" name="keyword" /></p>
<p><label>Optional title:</label> <input type="text" name="title" value="Optional title used when sharing a link from YOURLS" onfocus="if(this.value == this.defaultValue) this.value = ''" class="right" /></p> <p><label for="title" title="Optional title used when sharing a link from YOURLS">Optional title:</label> <input type="text" id="title" class="right" name="title" /></p>
<p><input type="submit" value="Shorten" /></p> <p><input type="submit" value="Shorten" /></p>
</form> </form>
HTML; HTML;
} }
@@ -97,7 +90,7 @@ HTML;
<p><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='http://kwl.me/admin/index.php?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet">Custom Keyword Shorten</a></p> <p><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='http://kwl.me/admin/index.php?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet">Custom Keyword Shorten</a></p>
<div class="footer"> <div class="footer">
<p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a>. Design by <a href="http://tomslominski.net/">Tom Slominski</a>.</p> <p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a>. Design by <a href="http://tomslominski.net/">Tom Slominski</a>. Also used: <a href="http://formalize.me/">Formalize</a> and <a href="http://craigsworks.com/projects/qtip2/">qTip²</a>. Find this theme on <a href="https://github.com/tomslominski/infinity-squared-yourls">GitHub</a>.</p>
</div> </div>
</div> </div>
</body> </body>

22
public/CHANGELOG Normal file
View File

@@ -0,0 +1,22 @@
∞² for YOURLS
CHANGELOG
=======================================================================
=======================================================================
Version 1.0
-----------------------------------------------------------------------
Initial release
=======================================================================
Version 1.1
-----------------------------------------------------------------------
Added a "for" attribute to the shortening form
Added tooltips for revealing more information about inputs
Removed input=text content (replaced by tooltips)
Changed file theme structure (files now located in /public)
New README and CHANGELOG files
Updated formalize
The theme is now showing links on it's own
Added a new sharing system using native buttons
Got rid of yourls_share_box
Updated footer with new credits and a github repo link
Cleaned up CSS
=======================================================================

9
public/README Normal file
View File

@@ -0,0 +1,9 @@
A port of the beautiful ∞² theme for WordPress, by Tom Slominski (http://tomslominski.net/)
To activate, just upload the included files to your main YOURLS directory.
qTip 2 is dual licensed under MIT or GPLv2 licenses
http://en.wikipedia.org/wiki/MIT_License
http://en.wikipedia.org/wiki/GNU_General_Public_License
Formalize and the theme itself are also licenced on GPLv2.

302
public/formalize.css Normal file
View File

@@ -0,0 +1,302 @@
/* `Widths
----------------------------------------------------------------------------------------------------*/
.input_tiny {
width: 50px;
}
.input_small {
width: 100px;
}
.input_medium {
width: 150px;
}
.input_large {
width: 200px;
}
.input_xlarge {
width: 250px;
}
.input_xxlarge {
width: 300px;
}
.input_full {
width: 100%;
}
/*
Added via JS to <textarea> and class="input_full".
Applies only to IE7. Other browsers don't need it.
*/
.input_full_wrap {
display: block;
padding-right: 8px;
}
/* `UI Consistency
----------------------------------------------------------------------------------------------------*/
::-moz-focus-inner {
border: 0;
}
input[type="search"]::-webkit-search-decoration {
display: none;
}
input,
button,
select,
textarea {
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
margin: 0;
vertical-align: middle;
}
button,
input[type="reset"],
input[type="submit"],
input[type="button"] {
-webkit-appearance: none;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
background: #ddd url(../img/button.png) repeat-x;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(1, #ddd));
background: -moz-linear-gradient(top center, #fff 0%, #ddd 100%);
border: 1px solid;
border-color: #ddd #bbb #999;
cursor: pointer;
color: #333;
font: bold 12px/1.2 Arial, sans-serif;
outline: 0;
overflow: visible;
padding: 3px 10px 4px;
text-shadow: #fff 0 1px 1px;
width: auto;
/* IE7 */
*padding-top: 2px;
*padding-bottom: 0px;
}
button {
/* IE7 */
*padding-top: 1px;
*padding-bottom: 1px;
}
button[disabled],
input[type="reset"][disabled],
input[type="submit"][disabled],
input[type="button"][disabled] {
color: #888;
}
textarea,
select,
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="email"],
input[type="month"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="text"],
input[type="time"],
input[type="url"],
input[type="week"] {
-webkit-appearance: none;
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
border: 1px solid;
border-color: #848484 #c1c1c1 #e1e1e1;
color: #000;
outline: 0;
padding: 2px 3px;
font-size: 13px;
font-family: Arial, sans-serif;
height: 1.8em;
/* IE7 */
*padding-top: 2px;
*padding-bottom: 1px;
*height: auto;
}
/*
Separate rule for Firefox.
Cannot stack with WebKit's.
*/
input.placeholder_text,
textarea.placeholder_text,
input:-moz-placeholder,
textarea:-moz-placeholder {
color: #888;
}
::-webkit-input-placeholder {
color: #888;
}
textarea[disabled],
select[disabled],
input[type="date"][disabled],
input[type="datetime"][disabled],
input[type="datetime-local"][disabled],
input[type="email"][disabled],
input[type="month"][disabled],
input[type="number"][disabled],
input[type="password"][disabled],
input[type="search"][disabled],
input[type="tel"][disabled],
input[type="text"][disabled],
input[type="time"][disabled],
input[type="url"][disabled],
input[type="week"][disabled] {
background-color: #eee;
color: #888;
}
button:focus,
button:active,
input:focus,
input:active,
select:focus,
select:active,
textarea:focus,
textarea:active {
-moz-box-shadow: #06f 0 0 7px;
-webkit-box-shadow: #06f 0 0 7px;
box-shadow: #06f 0 0 7px;
/* for Opera */
z-index: 1;
}
input[type="file"]:focus,
input[type="file"]:active,
input[type="radio"]:focus,
input[type="radio"]:active,
input[type="checkbox"]:focus,
input[type="checkbox"]:active {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.is_webkit select {
/* Tweaks for Safari + Chrome. */
background-image: url(../img/select_arrow.gif);
background-repeat: no-repeat;
background-position: right center;
padding-right: 20px;
}
textarea,
select[multiple] {
height: auto;
}
select[multiple],
.is_webkit select[multiple] {
background-image: none;
padding: 0;
}
textarea {
min-height: 40px;
overflow: auto;
resize: vertical;
width: 100%;
}
optgroup {
color: #000;
font-style: normal;
font-weight: normal;
}
/* `IE6
----------------------------------------------------------------------------------------------------*/
/*
Everything below this line is for IE6.
Delete it if you don't support it! :)
Classes are added dynamically via JS,
because IE6 doesn't support attribute
selectors: .ie6_button, .ie6_input, etc.
Note: These style rules are somewhat
duplicated because IE6 bombs out when
it sees attribute selectors. Example:
.ie6_button {
This works in IE6.
}
.ie6_button,
input[type=submit] {
This doesn't work.
}
*/
.ie6_button,
* html button {
background: #ddd url(../img/button.png) repeat-x;
border: 1px solid;
border-color: #ddd #bbb #999;
cursor: pointer;
color: #333;
font: bold 12px/1.2 Arial, sans-serif;
padding: 2px 10px 0px;
overflow: visible;
width: auto;
}
* html button {
padding-top: 1px;
padding-bottom: 1px;
}
.ie6_input,
* html textarea,
* html select {
background: #fff;
border: 1px solid;
border-color: #848484 #c1c1c1 #e1e1e1;
color: #000;
padding: 2px 3px 1px;
font-size: 13px;
font-family: Arial, sans-serif;
vertical-align: top;
}
* html select {
margin-top: 1px;
}
.placeholder_text,
.ie6_input_disabled,
.ie6_button_disabled {
color: #888;
}
.ie6_input_disabled {
background: #eee;
}

BIN
public/img/button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

BIN
public/img/noise.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
public/img/select_arrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

1
public/jquery.qtip.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/js/jquery.formalize.min.js vendored Normal file
View File

@@ -0,0 +1 @@
var FORMALIZE=function(a,b,c,d){var e="placeholder"in c.createElement("input"),f="autofocus"in c.createElement("input"),g="webkitAppearance"in c.createElement("select").style,h=!!a.browser.msie&&parseInt(a.browser.version,10)===6,i=!!a.browser.msie&&parseInt(a.browser.version,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{detect_webkit:function(){!g||a(c.documentElement).addClass("is_webkit")},full_input_size:function(){!!i&&!!a("textarea, input.input_full").length&&a("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(!!h&&!!a("input, select, textarea").length){var b=/button|submit|reset/,c=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;a("input").each(function(){var d=a(this);this.getAttribute("type").match(b)?(d.addClass("ie6_button"),this.disabled&&d.addClass("ie6_button_disabled")):this.getAttribute("type").match(c)&&(d.addClass("ie6_input"),this.disabled&&d.addClass("ie6_input_disabled"))}),a("textarea, select").each(function(){this.disabled&&a(this).addClass("ie6_input_disabled")})}},autofocus:function(){!f&&!!a(":input[autofocus]").length&&a(":input[autofocus]:visible:first").focus()},placeholder:function(){!e&&!!a(":input[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");b.focus(function(){b.val()===c&&b.val("").removeClass("placeholder_text")}).blur(function(){FORMALIZE.misc.add_placeholder()}),b.closest("form").submit(function(){b.val()===c&&b.val("").removeClass("placeholder_text")}).bind("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!e&&!!a(":input[placeholder]").length&&a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");(!b.val()||b.val()===c)&&b.val(c).addClass("placeholder_text")})}}}}(jQuery,this,this.document);jQuery(document).ready(function(){FORMALIZE.go()})

13
public/js/jquery.qtip.min.js vendored Normal file

File diff suppressed because one or more lines are too long

153
public/public.css Normal file
View File

@@ -0,0 +1,153 @@
/* Main */
body {
background:#F1F1F1;
color:#000;
font-family:'Ubuntu', sans-serif, Helvetica, Arial;
font-size: 12px;
}
h2 {
color:#000;
margin-bottom:-8px;
}
a {
color:#013F6D;
text-decoration:none;
}
a:visited {
color:#013F6D;
text-decoration:none;
}
/* Header */
h1 {
background: url(img/noise.png) #013F6D;
width:100%;
text-align:center;
color:#FFFFFF;
font-size:60px;
border-top:4px #000 solid;
margin-top:0;
margin-bottom:-6px;
}
h1 a {
color:#FFF;
text-decoration:none;
}
h1 a:hover {
border-bottom: #FFF 1px dashed;
}
h1 a:visited {
color:#FFF;
text-decoration:none;
}
.menu {
background: #000;
display: block;
float: left;
margin: 0 auto;
width: 750px;
color:#FFF;
padding: 0 15px 0 15px;
margin-bottom:30px;
}
.menu a {
color: #FFF;
text-decoration: none;
line-height:38px;
display: block;
padding: 0 10px;
}
.menu a:hover {
background:#292929;
}
.menu li {
list-style: none;
float: left;
line-height:38px;
background:#000;
width:auto;
}
/* Container */
#container {
width: 780px;
margin-left: auto;
margin-right: auto;
background-color: #FFF;
padding: 20px;
margin-top: 20px;
}
.right {
width: 400px;
float: right;
}
.bookmarklet {
border-radius: 11px;
background: #ddd url(../img/button.png) repeat-x;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(1, #ddd));
background: -moz-linear-gradient(top center, #fff 0%, #ddd 100%);
border: 1px solid;
border-color: #ddd #bbb #999;
cursor: pointer;
color: #333;
font: bold 12px/1.2 Arial, sans-serif;
outline: 0;
overflow: visible;
padding: 3px 10px 4px;
text-shadow: #fff 0 1px 1px;
width: auto;
text-decoration:none;
}
/* Tooltips */
.ui-tooltip-titlebar,
.ui-tooltip-content{
border-color: #013F6D;
background-color: #013F6D;
color: #FFF;
}
/* Output */
.output {
border: 3px #013F6D solid;
padding: 4px;
background: url(img/noise.png);
border-radius: 10px;
width:600px;
}
.output p {
margin:2px;
}
.output a, .output a:visited {
color:#013F6D;
text-decoration:none;
}
.output a:hover {
border-bottom: #013F6D 1px dashed;
}
/* Footer */
.footer {
text-align:center;
border-top:3px solid #000;
margin-top:30px;
}
.footer p {
padding-top:20px;
margin:0 auto;
}
.footer a {
color:#013F6D;
}
.footer a:hover {
text-decoration:none;
border-bottom:dashed 1px #013F6D;
}
.footer a:visited {
color:#013F6D;
}
/* Other */
div#copybox {
width:600px;
height:auto;
}
div#sharebox {
height:auto;
width:600px;
margin-top: 20px
}