Browse files

CSS Min Files and HubInfo Shortcode added.

Added CSS Min Files for optimization and Added HubInfo Shortcodes to use [hubinfo user="username" repo="repo-name" twitter="twitter-username"]. Twitter Username is optional. More information for Hubinfo can be found here: http://projects.jga.me/hubinfo/

Signed-off-by: Justin Yost <justin.yost@yostivanich.com>
  • Loading branch information...
1 parent dfcfa88 commit b60b82bfcca8df8b77ca88f7d262bb7b90c46c54 @justinyost committed Jul 14, 2012
View
22 css/erudite-child.css
@@ -1,3 +1,25 @@
+/* For modern browsers */
+/* float clearing for IE6 */
+* html .clearfix{
+ height: 1%;
+ overflow: visible;
+}
+
+/* float clearing for IE7 */
+*+html .clearfix{
+ min-height: 1%;
+}
+
+/* float clearing for everyone else */
+.clearfix:after{
+ clear: both;
+ content: ".";
+ display: block;
+ height: 0;
+ visibility: hidden;
+ font-size: 0;
+}
+
/* CSS Reset based on http://meyerweb.com/eric/tools/css/reset/ */
/* Typography Test */
View
1 css/erudite-child.min.css
@@ -0,0 +1 @@
+* html .clearfix{height:1%;overflow:visible}*+html .clearfix{min-height:1%}.clearfix:after{clear:both;content:".";display:block;height:0;visibility:hidden;font-size:0}.twtr-widget,.footer ul div div.twtr-widget{font-size:12px!important}
View
63 css/hubinfo.css
@@ -0,0 +1,63 @@
+.github-repo {
+ position: relative;
+ font-size: 14px;
+ font-family: Helvetica, Arial, sans-serif;
+ letter-spacing: 1px;
+ border-radius: 5px;
+ border: 1px solid #ccc;
+ box-shadow: 0px 0px 3px #333;
+ background: url("../images/Octocat.png") no-repeat right bottom;
+}
+.github-repo a {
+ text-decoration: none;
+}
+.github-repo a:hover {
+ text-decoration: underline;
+}
+.github-repo .repo-header {
+ background: rgba(240,240,240,0.7);
+}
+.github-repo .repo-header .repo-stats {
+ font-size: 12px;
+ float: right;
+ margin: 5px 10px 0 0;
+ line-height: 20px;
+}
+.github-repo .repo-header .repo-stats span,
+.github-repo .repo-header .repo-stats a {
+ padding-right: 5px;
+ padding: 0 5px 0 25px;
+ color: #000;
+}
+.github-repo .repo-header .repo-stats .repo-watchers {
+ background: url("../images/repostat.png") no-repeat;
+ background-position: 5px -5px;
+}
+.github-repo .repo-header .repo-stats .repo-forks {
+ background: url("../images/repostat.png") no-repeat;
+ background-position: 5px -55px;
+}
+.github-repo .repo-header .repo-stats .repo-twitter {
+ float: right;
+ margin-left: 5px;
+}
+.github-repo .repo-header .repo-name {
+ padding: 5px 10px;
+ font-size: 18px;
+ letter-spacing: 2px;
+ display: block;
+}
+.github-repo .repo-commit {
+ padding: 10px;
+}
+.github-repo .repo-commit .repo-commit-message {
+ color: #000;
+}
+.github-repo .repo-commit .repo-commit-date {
+ display: block;
+ margin-top: 10px;
+ letter-spacing: 0;
+ font-style: italic;
+ font-size: 12px;
+ color: #333;
+}
View
1 css/hubinfo.min.css
@@ -0,0 +1 @@
+.github-repo{position:relative;font-size:14px;font-family:Helvetica,Arial,sans-serif;letter-spacing:1px;border-radius:5px;border:1px solid #ccc;box-shadow:0 0 3px #333;background:url("../images/Octocat.png") no-repeat right bottom}.github-repo a{text-decoration:none}.github-repo a:hover{text-decoration:underline}.github-repo .repo-header{background:rgba(240,240,240,0.7)}.github-repo .repo-header .repo-stats{font-size:12px;float:right;margin:5px 10px 0 0;line-height:20px}.github-repo .repo-header .repo-stats span,.github-repo .repo-header .repo-stats a{padding-right:5px;padding:0 5px 0 25px;color:#000}.github-repo .repo-header .repo-stats .repo-watchers{background:url("../images/repostat.png") no-repeat;background-position:5px -5px}.github-repo .repo-header .repo-stats .repo-forks{background:url("../images/repostat.png") no-repeat;background-position:5px -55px}.github-repo .repo-header .repo-stats .repo-twitter{float:right;margin-left:5px}.github-repo .repo-header .repo-name{padding:5px 10px;font-size:18px;letter-spacing:2px;display:block}.github-repo .repo-commit{padding:10px}.github-repo .repo-commit .repo-commit-message{color:#000}.github-repo .repo-commit .repo-commit-date{display:block;margin-top:10px;letter-spacing:0;font-style:italic;font-size:12px;color:#333}
View
43 functions.php
@@ -13,11 +13,18 @@
*/
function add_stylesheets() {
?>
- <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/css/erudite-child.css" />
+ <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/css/erudite-child.min.css" />
+ <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/css/hubinfo.min.css" />
<?php
}
/**
+ * [add_scripts description]
+ */
+function add_scripts() {
+}
+
+/**
* add_my_open_id_information function.
*
* @access public
@@ -62,6 +69,28 @@ function add_favicons(){
}
/**
+ * [hubinfo description]
+ * @param [type] $atts [description]
+ * @return [type] [description]
+ */
+function hubinfo($atts) {
+ extract( shortcode_atts( array(
+ 'user' => 'jtyost2',
+ 'repo' => 'Erudite-Child-Theme',
+ 'twitter' => '',
+ ), $atts ) );
+
+ wp_enqueue_script(
+ 'hubinfo.min',
+ get_stylesheet_directory_uri() . '/js/hubinfo.min.js',
+ array('jquery')
+ );
+
+ require_once(CHILD_TEMPLATE_DIR."/library/hubinfo_buttons.php");
+ return hubinfo_button($user, $repo, $twitter);
+}
+
+/**
* add_meta_tags function.
*
* @access public
@@ -226,10 +255,10 @@ function is_bitly_information_set(){
$options = get_theme_options();
return (
- isset($options['bitly_username']) &&
- isset($options['bitly_api_key']) &&
- !empty($options['bitly_username']) &&
- !empty($options['bitly_api_key'])
+ isset($options['bitly_username'])
+ && isset($options['bitly_api_key'])
+ && !empty($options['bitly_username'])
+ && !empty($options['bitly_api_key'])
);
}
@@ -335,6 +364,7 @@ function add_to_head(){
insert_short_url();
add_favicons();
add_meta_tags();
+ add_scripts();
}
/**
@@ -391,4 +421,7 @@ function get_theme_options() {
//Add Actions
add_action('publish_post', 'add_on_publish');
+//Add Shortcodes
+add_shortcode( 'hubinfo', 'hubinfo' );
+
?>
View
BIN images/Octocat.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/repostat.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 js/hubinfo.min.js
@@ -0,0 +1,8 @@
+/*!
+ * hubInfo - a github repo widget
+ * v0.0.1
+ * https://github.com/jgallen23/hubinfo
+ * copyright JGA 2012
+ * MIT License
+ */
+!function(e){var t=function(t,n,r){e.ajax({url:"https://api.github.com/repos/"+t+"/"+n,dataType:"jsonp",success:function(e){if(e.data.message=="Not Found")throw new Error("Invalid user or repo");r(e.data)}})},n=function(t,n,r){e.ajax({url:"https://api.github.com/repos/"+t+"/"+n+"/commits",dataType:"jsonp",success:function(e){var t=e.data[0];r(t)}})},r=function(e,r,i){var s=0,o=2,u,a,f=function(){s==o&&i(u,a)};t(e,r,function(e){s++,u=e,f()}),n(e,r,function(e){s++,a=e,f()})},i=function(e){if(typeof e=="string"){var t=e.split("T")[0].split("-");e=new Date(t[0],t[1]-1,t[2])}var n=(new Date).getTime(),r=n-e.getTime(),i=r/1e3,s=Math.floor(r/864e5);return s===0?"today":s>30?Math.floor(s/30)+" month(s) ago":s+" day(s) ago"};e.fn.hubInfo=function(t){var n=e.extend({},e.fn.hubInfo.defaults,t),s=this;return r(n.user,n.repo,function(t,r){n.debug&&console.log(arguments),s.each(function(s,o){var u=e(n.template);u.find(".repo-lang").html(t.language).end().find(".repo-watchers").html(t.watchers).attr("href",t.html_url).end().find(".repo-forks").html(t.forks).attr("href",t.html_url).end().find(".repo-name").html(t.name).attr("href",t.html_url).end().find(".repo-commit-message").html(r.commit.message).attr("href","http://github.com"+r.url).end().find(".repo-commit-date span").html(i(r.commit.committer.date)).end();var a=e(o);a.html(u),a.trigger("render")})}),s},e.fn.hubInfo.defaults={user:"",repo:"",debug:!1,template:['<div class="github-repo">','<div class="repo-header">','<div class="repo-stats">','<span class="repo-lang"></span>','<a class="repo-watchers"></a>','<a class="repo-forks"></a>',"</div>","<div>",'<a class="repo-name"></a>',"</div>","</div>",'<div class="repo-commit">','<a class="repo-commit-message"></a>','<div class="repo-commit-date">committed <span></span></div>',"</div>","</div>"].join("")}}(jQuery)
View
39 library/hubinfo_buttons.php
@@ -0,0 +1,39 @@
+<?php
+function hubinfo_button($userName = null, $repoName = null, $twitterUsername = null) {
+ $randomValue = return_random_value();
+ $scriptString = null;
+ $scriptString .= '<div class="hubInfo" id="' . $randomValue . '"> </div>';
+ $scriptString .= '<script type="text/javascript">';
+ $scriptString .= 'jQuery(document).ready(function(){';
+ $scriptString .= '
+ var hubInfoDiv = jQuery("div.hubInfo#' . $randomValue . '").hubInfo({
+ user: "' . $userName . '",
+ repo: "' . $repoName . '"
+ });';
+
+ if(!empty($twitterUsername)) {
+ $scriptString .= '
+ hubInfoDiv.on(\'render\', function() {
+ jQuery(\'<a href="https://twitter.com/share" class="twitter-share-button" data-via="' . $twitterUsername . '">Tweet</a>\')
+ .insertAfter(\'.repo-forks\');
+ !function(d,s,id){
+ var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}
+ }(document,"script","twitter-wjs");
+ });';
+ }
+ $scriptString .= "});";
+ $scriptString .= '</script>';
+ return $scriptString;
+}
+
+function make_seed()
+{
+ list($usec, $sec) = explode(' ', microtime());
+ return (float) $sec + ((float) $usec * 100000);
+}
+
+function return_random_value() {
+ mt_srand(make_seed());
+ return mt_rand();
+}
+?>

0 comments on commit b60b82b

Please sign in to comment.