Created
September 19, 2012 09:37
-
-
Save saurini/3748715 to your computer and use it in GitHub Desktop.
Revisions
-
saurini revised this gist
Sep 23, 2012 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,8 +47,6 @@ function saurini_gist_func( $atts ){ \$( this ).prepend( '<span class="line-number">' + line_number + '.</span>' ); \$( this ).children().each( function(){ line_length += \$( this ).text().length; }); -
saurini revised this gist
Sep 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function saurini_gist_func( $atts ){ longest_line = line_length; }); \$( '.gist .line' ).css( 'width', ( longest_line * 9 ) + 'px' ); var max_line_number_length = ( line_number.toString().length ) * 9 + 9+ 'px'; \$( '.gist .line-number' ).css( 'width', max_line_number_length ); -
saurini revised this gist
Sep 20, 2012 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,26 @@ function saurini_gist_func( $atts ){ // Dollar signs are escaped in the heredoc so I don't give myself a concatenation headache. return <<<HTML <style type="text/css"> html body div .gist .gist-file .gist-data pre { padding: 0 !important; } .gist .line { height: 20px; line-height: 20px; } .gist .line:nth-child( 2n+1 ){ background-color: #f0f0f0; } .gist .line-number{ border-right: 3px solid #AEC7BA; color: #3AA1C9; display: inline-block; font-weight: bold; height: 20px; margin: 0 5px; } </style> <script type="text/javascript" src="http://gist.github.com/{$id}.js"></script> <script type="text/javascript"> ( function( \$ ){ -
saurini revised this gist
Sep 20, 2012 . 1 changed file with 27 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,41 +14,54 @@ function saurini_gist_func( $atts ){ <script type="text/javascript"> ( function( \$ ){ // store this in global scope so it can be modified and then accessed with the each is done var line_number; var longest_line = 0; \$( '.gist .line' ).each( function(){ var line_id = \$( this ).attr( 'id' ); var line_length = 0; line_number = line_id.match( /\d+/ )[0]; \$( this ).prepend( '<span class="line-number">' + line_number + '.</span>' ); \$( this ).children().each( function(){ line_length += \$( this ).text().length; }); if ( line_length > longest_line ) longest_line = line_length; }); \$( '.gist .line' ).css( 'width', ( longest_line * 8 ) + 'px' ); var max_line_number_length = ( line_number.toString().length ) * 9 + 9+ 'px'; \$( '.gist .line-number' ).css( 'width', max_line_number_length ); \$( '.gist-meta a' ).each( function(){ \$( this ).attr( 'target', '_blank' ); var href = \$( this ).attr( 'href' ); if ( href.match( /\/raw/ ) ){ \$( this ).on( 'click', function(){ var raw_window = window.open( href , "Raw Gist", "toolbar=0,status=0,width=500,height=600,scrollbars=1" ); raw_window.moveTo( 500, 50 ); return false; }); } }); } )( jQuery ); </script> -
saurini revised this gist
Sep 19, 2012 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function saurini_gist_func( $atts ){ // We'll use line_length to set the width of the pre element later var line_length = 0; // Now we count the text length inside each span \$( this ).children().each( function(){ line_length = line_length + \$( this ).text().length; }); @@ -45,7 +45,8 @@ function saurini_gist_func( $atts ){ // Set the width of the pre according to how many characters on the longest line \$( '.gist .line' ).css( 'width', ( longest_line * 8 ) + 'px' ); // Calculate the width of the pre element ( so that the var max_line_number_length = ( line_number.toString().length ) * 9 + 9 + 'px'; \$( '.gist .line-number' ).css( 'width', max_line_number_length ); } )( jQuery ); -
saurini revised this gist
Sep 19, 2012 . 1 changed file with 14 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,30 +4,35 @@ function saurini_gist_func( $atts ){ extract(shortcode_atts(array( 'id' => '1337'), $atts)); // Only allow gist ids that are letters or numbers if ( preg_match( '/[^0-9^a-z^A-Z]/', $id ) ) return; // Dollar signs are escaped in the heredoc so I don't give myself a concatenation headache. return <<<HTML <script type="text/javascript" src="http://gist.github.com/{$id}.js"></script> <script type="text/javascript"> ( function( \$ ){ // Store line_number in global scope so it can be modified and then accessed with the each is done var line_number; var longest_line = 0; // Iterate over each line in the embedded gist \$( '.gist .line' ).each( function(){ // We need the id of each line to grab the number var line_id = \$( this ).attr( 'id' ) // Said number grabbing line_number = line_id.match( /\d+/ )[0]; \$( this ).prepend( '<span class="line-number">' + line_number + '.</span>' ); // We'll use line_length to set the width of the pre element later var line_length = 0; // Now we grab count the text length inside each span \$( this ).children().each( function(){ line_length = line_length + \$( this ).text().length; }); @@ -36,6 +41,8 @@ function saurini_gist_func( $atts ){ longest_line = line_length; }); // Set the width of the pre according to how many characters on the longest line \$( '.gist .line' ).css( 'width', ( longest_line * 8 ) + 'px' ); var max_line_number_length = ( line_number.toString().length ) * 9 + 9+ 'px'; @@ -51,4 +58,4 @@ function saurini_gist_func( $atts ){ add_shortcode( 'gist', 'saurini_gist_func' ); ?> -
saurini created this gist
Sep 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ <?php // Inserts an embedded gist into the content usage [gist id="12345"] function saurini_gist_func( $atts ){ extract(shortcode_atts(array( 'id' => '1337'), $atts)); if ( preg_match( '/[^0-9^a-z^A-Z]/', $id ) ) return; return <<<HTML <script type="text/javascript" src="http://gist.github.com/{$id}.js"></script> <script type="text/javascript"> ( function( \$ ){ // store this in global scope so it can be modified and then accessed with the each is done var line_number; var longest_line = 0; \$( '.gist .line' ).each( function(){ var line_id = \$( this ).attr( 'id' ); var line_length = 0; line_number = line_id.match( /\d+/ )[0]; \$( this ).prepend( '<span class="line-number">' + line_number + '.</span>' ); \$( this ).children().each( function(){ line_length = line_length + \$( this ).text().length; }); if ( line_length > longest_line ) longest_line = line_length; }); \$( '.gist .line' ).css( 'width', ( longest_line * 8 ) + 'px' ); var max_line_number_length = ( line_number.toString().length ) * 9 + 9+ 'px'; \$( '.gist .line-number' ).css( 'width', max_line_number_length ); } )( jQuery ); </script> HTML; } add_shortcode( 'gist', 'saurini_gist_func' ); ?>