Changeset 638773
- Timestamp:
- 12/13/2012 07:19:55 PM (13 years ago)
- Location:
- embed-github-gist/trunk
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
embed-github-gist.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
-
stylesheets/embed.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
embed-github-gist/trunk
- Property svn:ignore
-
old new 1 1 .git 2 2 .gitignore 3 README.md
-
- Property svn:ignore
-
embed-github-gist/trunk/embed-github-gist.php
r610431 r638773 6 6 Author: Dragonfly Development 7 7 Author URI: http://dflydev.com/ 8 Version: 0.1 09 License: New BSD License - http://www.opensource.org/licenses/bsd-license.php8 Version: 0.11 9 License: MIT - http://opensource.org/licenses/mit 10 10 */ 11 11 … … 25 25 26 26 if ( !defined('EMBED_GISTHUB_INLINE_HTML') ) { 27 define('EMBED_GISTHUB_INLINE_HTML', true);27 define('EMBED_GISTHUB_INLINE_HTML', false); 28 28 } 29 29 … … 74 74 75 75 $key = embed_github_gist_build_cache_key($id, $bump, $file); 76 if ( embed_github_gist_bypass_cache() orfalse === ( $gist = get_transient($key) ) ) {76 if ( embed_github_gist_bypass_cache() || false === ( $gist = get_transient($key) ) ) { 77 77 $http = new WP_Http; 78 79 if ( embed_github_gist_prefer_inline_html() and function_exists('json_decode') ) { 80 if ($file) $file = "?file=$file"; 81 $args = array('sslverify' => false); 82 $result = $http->request('https://gist.github.com/' . $id . '.json' . $file, $args); 83 if ( is_wp_error($result) ) { 84 echo $result->get_error_message(); 78 $args = array('sslverify' => false); 79 $result = $http->request('https://api.github.com/gists/' . $id, $args); 80 if ( is_wp_error($result) ) { 81 echo $result->get_error_message(); 82 } 83 $json = json_decode($result['body'], true); 84 85 $files = array(); 86 foreach ($json['files'] as $name => $fileInfo) { 87 if ($file === null) { 88 $files[$name] = $fileInfo; 89 } else { 90 if ($file == $name) { 91 $files[$name] = $fileInfo; 92 break; 93 } 85 94 } 86 $json = json_decode($result['body']); 87 $gist = $json->div; 88 } else { 89 if ( ! $file ) $file = 'file'; 90 $result = $http->request('https://gist.github.com/raw/' . $id . '/' . $file); 91 $gist = '<script src="https://gist.github.com/' . $id . '.js?file=' . $file . '" type="text/javascript"></script>'; 92 $gist .= '<noscript><div class="embed-github-gist-source"><code><pre>'; 93 $gist .= htmlentities($result['body']); 94 $gist .= '</pre></code></div></noscript>'; 95 } 96 97 $gist = ''; 98 99 if (count($files)) { 100 if ( embed_github_gist_prefer_inline_html() ) { 101 foreach ($files as $name => $fileInfo) { 102 $language = strtolower($fileInfo['language']); 103 $gist .= '<pre><code class="language-'.$language.' '.$language.'">'; 104 $gist .= htmlentities($fileInfo['content']); 105 $gist .= '</code></pre>'; 106 } 107 } else { 108 $urlExtra = $file ? '?file='.$file : ''; 109 $gist .= '<script src="https://gist.github.com/'.$id.'.js'.$urlExtra.'"></script>'; 110 $gist .= '<noscript>'; 111 foreach ($files as $name => $fileInfo) { 112 $language = strtolower($fileInfo['language']); 113 $gist .= '<pre><code class="language-'.$language.' '.$language.'">'; 114 $gist .= htmlentities($fileInfo['content']); 115 $gist .= '</code></pre>'; 116 } 117 $gist .= '</noscript>'; 118 } 95 119 } 96 120 … … 130 154 131 155 /** 132 * Styles.133 */134 function embed_github_gist_styles() {135 wp_enqueue_style('embed_github_gist_from_gist', plugins_url('stylesheets/embed.css', __FILE__));136 }137 138 /**139 156 * Init the plugin. 140 157 */ … … 154 171 foreach ($posts as $p) { 155 172 if (preg_match('/\[gist[^\]]*\]/siU', $p->post_content)) { 156 embed_github_gist_styles();157 158 173 return true; 159 174 } -
embed-github-gist/trunk/readme.txt
r610431 r638773 3 3 Tags: github, gist, source, syntax, highlight, highlighter, embed 4 4 Requires at least: 2.8.6 5 Tested up to: 3. 16 Stable tag: 0.1 05 Tested up to: 3.5 6 Stable tag: 0.11 7 7 8 8 Embed GitHub Gists into WordPress. … … 10 10 == Description == 11 11 12 Follow here: [Embed GitHub Gist](http://dflydev.com/d2code/wordpress/embed-github-gist-plugin/) 12 This project is available for forking on GitHub: 13 14 * https://github.com/dflydev/embed-github-gist 13 15 14 16 Embed [GitHub](http://github.com/) [Gists](http://gist.github.com) into … … 103 105 == Changelog == 104 106 107 = 0.11 = 108 * Updated to account for recent changes to Gist. 109 105 110 = 0.10 = 106 111 * Bump release ("same as 0.9") -
embed-github-gist/trunk/stylesheets/embed.css
r330569 r638773 1 /** 2 * Gist Embed Stylesheet 3 * 4 * Locally cached stylesheet, packing/minifying friendly. 5 * 6 * @copyright Github 7 * @licence Unknown 8 */ 9 10 .gist { 11 color: #000; 12 } 13 14 .gist div { 15 padding: 0; 16 margin: 0; 17 } 18 19 .gist .gist-file { 20 border: 1px solid #dedede; /* gray */ 21 font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; 22 margin-bottom: 1em; 23 } 24 25 .gist .gist-file .gist-meta { 26 overflow: hidden; 27 font-size: 85%; 28 padding: .5em; 29 color: #666; 30 background-color: #eaeaea; 31 } 32 33 .gist .gist-file .gist-meta a { 34 color: #369; 35 } 36 37 .gist .gist-file .gist-meta a:visited { 38 color: #737; 39 } 40 41 .gist .gist-file .gist-data { 42 overflow: auto; 43 word-wrap: normal; 44 background-color: #f8f8ff; 45 border-bottom: 1px solid #ddd; 46 font-size: 100%; 47 } 48 49 .gist .gist-file .gist-data pre { 50 font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace; 51 background: transparent !important; 52 margin: 0 !important; 53 border: none !important; 54 padding: .25em .5em .5em .5em !important; 55 } 56 57 .gist .gist-file .gist-data .gist-highlight { 58 background: transparent !important; 59 } 60 61 .gist .gist-file .gist-data .gist-line-numbers { 62 background-color: #ececec; 63 color: #aaa; 64 border-right: 1px solid #ddd; 65 text-align: right; 66 } 67 68 .gist .gist-file .gist-data .gist-line-numbers span { 69 clear: right; 70 display: block; 71 } 72 73 .gist-syntax { background: #ffffff; } 74 .gist-syntax .c { color: #999988; font-style: italic } /* Comment */ 75 .gist-syntax .err { color: #a61717; background-color: #e3d2d2 } /* Error */ 76 .gist-syntax .k { color: #000000; font-weight: bold } /* Keyword */ 77 .gist-syntax .o { color: #000000; font-weight: bold } /* Operator */ 78 .gist-syntax .cm { color: #999988; font-style: italic } /* Comment.Multiline */ 79 .gist-syntax .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ 80 .gist-syntax .c1 { color: #999988; font-style: italic } /* Comment.Single */ 81 .gist-syntax .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ 82 .gist-syntax .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ 83 .gist-syntax .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ 84 .gist-syntax .ge { color: #000000; font-style: italic } /* Generic.Emph */ 85 .gist-syntax .gr { color: #aa0000 } /* Generic.Error */ 86 .gist-syntax .gh { color: #999999 } /* Generic.Heading */ 87 .gist-syntax .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ 88 .gist-syntax .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ 89 .gist-syntax .go { color: #888888 } /* Generic.Output */ 90 .gist-syntax .gp { color: #555555 } /* Generic.Prompt */ 91 .gist-syntax .gs { font-weight: bold } /* Generic.Strong */ 92 .gist-syntax .gu { color: #aaaaaa } /* Generic.Subheading */ 93 .gist-syntax .gt { color: #aa0000 } /* Generic.Traceback */ 94 .gist-syntax .kc { color: #000000; font-weight: bold } /* Keyword.Constant */ 95 .gist-syntax .kd { color: #000000; font-weight: bold } /* Keyword.Declaration */ 96 .gist-syntax .kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */ 97 .gist-syntax .kr { color: #000000; font-weight: bold } /* Keyword.Reserved */ 98 .gist-syntax .kt { color: #445588; font-weight: bold } /* Keyword.Type */ 99 .gist-syntax .m { color: #009999 } /* Literal.Number */ 100 .gist-syntax .s { color: #d14 } /* Literal.String */ 101 .gist-syntax .na { color: #008080 } /* Name.Attribute */ 102 .gist-syntax .nb { color: #0086B3 } /* Name.Builtin */ 103 .gist-syntax .nc { color: #445588; font-weight: bold } /* Name.Class */ 104 .gist-syntax .no { color: #008080 } /* Name.Constant */ 105 .gist-syntax .ni { color: #800080 } /* Name.Entity */ 106 .gist-syntax .ne { color: #990000; font-weight: bold } /* Name.Exception */ 107 .gist-syntax .nf { color: #990000; font-weight: bold } /* Name.Function */ 108 .gist-syntax .nn { color: #555555 } /* Name.Namespace */ 109 .gist-syntax .nt { color: #000080 } /* Name.Tag */ 110 .gist-syntax .nv { color: #008080 } /* Name.Variable */ 111 .gist-syntax .ow { color: #000000; font-weight: bold } /* Operator.Word */ 112 .gist-syntax .w { color: #bbbbbb } /* Text.Whitespace */ 113 .gist-syntax .mf { color: #009999 } /* Literal.Number.Float */ 114 .gist-syntax .mh { color: #009999 } /* Literal.Number.Hex */ 115 .gist-syntax .mi { color: #009999 } /* Literal.Number.Integer */ 116 .gist-syntax .mo { color: #009999 } /* Literal.Number.Oct */ 117 .gist-syntax .sb { color: #d14 } /* Literal.String.Backtick */ 118 .gist-syntax .sc { color: #d14 } /* Literal.String.Char */ 119 .gist-syntax .sd { color: #d14 } /* Literal.String.Doc */ 120 .gist-syntax .s2 { color: #d14 } /* Literal.String.Double */ 121 .gist-syntax .se { color: #d14 } /* Literal.String.Escape */ 122 .gist-syntax .sh { color: #d14 } /* Literal.String.Heredoc */ 123 .gist-syntax .si { color: #d14 } /* Literal.String.Interpol */ 124 .gist-syntax .sx { color: #d14 } /* Literal.String.Other */ 125 .gist-syntax .sr { color: #009926 } /* Literal.String.Regex */ 126 .gist-syntax .s1 { color: #d14 } /* Literal.String.Single */ 127 .gist-syntax .ss { color: #990073 } /* Literal.String.Symbol */ 128 .gist-syntax .bp { color: #999999 } /* Name.Builtin.Pseudo */ 129 .gist-syntax .vc { color: #008080 } /* Name.Variable.Class */ 130 .gist-syntax .vg { color: #008080 } /* Name.Variable.Global */ 131 .gist-syntax .vi { color: #008080 } /* Name.Variable.Instance */ 132 .gist-syntax .il { color: #009999 } /* Literal.Number.Integer.Long */ 1 .gist{color:#000}.gist .gist-file{border:1px solid #dedede;font-family:Consolas, "Liberation Mono", Courier, monospace;margin-bottom:1em}.gist .gist-file .gist-meta{font-family:Helvetica, arial, freesans, clean, sans-serif;overflow:hidden;font-size:85%;padding:.5em;color:#666;background-color:#eaeaea}.gist .gist-file .gist-meta a{color:#369}.gist .gist-file .gist-meta a:visited{color:#737}.gist .gist-file .gist-data{overflow:auto;word-wrap:normal;background-color:#f8f8ff;border-bottom:1px solid #ddd;font-size:100%}.gist .gist-file .gist-data .line_data{padding:.5em !important}.gist .gist-file .gist-data pre{font-family:Consolas, "Liberation Mono", Courier, monospace;background:transparent !important;border:none !important;margin:0 !important;padding:0 !important}.gist .gist-file .gist-data .gist-highlight{background:transparent !important}.gist .gist-file .gist-data .line_numbers{background-color:#ececec;color:#aaa;border-right:1px solid #ddd;text-align:right;padding:.5em}.gist .gist-file .gist-data .gist-line-numbers span{clear:right;display:block}.gist-syntax{background:#ffffff}.gist-syntax .c{color:#999988;font-style:italic}.gist-syntax .err{color:#a61717;background-color:#e3d2d2}.gist-syntax .k{color:#000000;font-weight:bold}.gist-syntax .o{color:#000000;font-weight:bold}.gist-syntax .cm{color:#999988;font-style:italic}.gist-syntax .cp{color:#999999;font-weight:bold}.gist-syntax .c1{color:#999988;font-style:italic}.gist-syntax .cs{color:#999999;font-weight:bold;font-style:italic}.gist-syntax .gd{color:#000000;background-color:#ffdddd}.gist-syntax .gd .x{color:#000000;background-color:#ffaaaa}.gist-syntax .ge{color:#000000;font-style:italic}.gist-syntax .gr{color:#aa0000}.gist-syntax .gh{color:#999999}.gist-syntax .gi{color:#000000;background-color:#ddffdd}.gist-syntax .gi .x{color:#000000;background-color:#aaffaa}.gist-syntax .go{color:#888888}.gist-syntax .gp{color:#555555}.gist-syntax .gs{font-weight:bold}.gist-syntax .gu{color:#aaaaaa}.gist-syntax .gt{color:#aa0000}.gist-syntax .kc{color:#000000;font-weight:bold}.gist-syntax .kd{color:#000000;font-weight:bold}.gist-syntax .kp{color:#000000;font-weight:bold}.gist-syntax .kr{color:#000000;font-weight:bold}.gist-syntax .kt{color:#445588;font-weight:bold}.gist-syntax .m{color:#009999}.gist-syntax .s{color:#d14}.gist-syntax .na{color:#008080}.gist-syntax .nb{color:#0086B3}.gist-syntax .nc{color:#445588;font-weight:bold}.gist-syntax .no{color:#008080}.gist-syntax .ni{color:#800080}.gist-syntax .ne{color:#990000;font-weight:bold}.gist-syntax .nf{color:#990000;font-weight:bold}.gist-syntax .nn{color:#555555}.gist-syntax .nt{color:#000080}.gist-syntax .nv{color:#008080}.gist-syntax .ow{color:#000000;font-weight:bold}.gist-syntax .w{color:#bbbbbb}.gist-syntax .mf{color:#009999}.gist-syntax .mh{color:#009999}.gist-syntax .mi{color:#009999}.gist-syntax .mo{color:#009999}.gist-syntax .sb{color:#d14}.gist-syntax .sc{color:#d14}.gist-syntax .sd{color:#d14}.gist-syntax .s2{color:#d14}.gist-syntax .se{color:#d14}.gist-syntax .sh{color:#d14}.gist-syntax .si{color:#d14}.gist-syntax .sx{color:#d14}.gist-syntax .sr{color:#009926}.gist-syntax .s1{color:#d14}.gist-syntax .ss{color:#990073}.gist-syntax .bp{color:#999999}.gist-syntax .vc{color:#008080}.gist-syntax .vg{color:#008080}.gist-syntax .vi{color:#008080}.gist-syntax .il{color:#009999}
Note: See TracChangeset
for help on using the changeset viewer.