├── index.html ├── font ├── index.html ├── fontello.eot ├── fontello.ttf ├── fontello.woff └── fontello.svg ├── langs ├── index.html ├── repo-zh_CN.mo ├── zh.js ├── en.js └── repo-zh_CN.po ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png ├── assets └── banner-772x250.png ├── wp-reposidget-mce.js ├── wp-reposidget.html ├── CHANGELOG.md ├── wp-reposidget-dialog.html ├── LICENSE ├── README.md ├── wp-reposidget-editor.css ├── wp-reposidget-dialog.js ├── wp-reposidget.css └── wp-reposidget.php /index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /font/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /langs/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /font/fontello.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/font/fontello.eot -------------------------------------------------------------------------------- /font/fontello.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/font/fontello.ttf -------------------------------------------------------------------------------- /font/fontello.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/font/fontello.woff -------------------------------------------------------------------------------- /screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/screenshot-1.png -------------------------------------------------------------------------------- /screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/screenshot-2.png -------------------------------------------------------------------------------- /screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/screenshot-3.png -------------------------------------------------------------------------------- /langs/repo-zh_CN.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/langs/repo-zh_CN.mo -------------------------------------------------------------------------------- /langs/zh.js: -------------------------------------------------------------------------------- 1 | tinyMCE.addI18n({"zh": {"reposidget": { 2 | "tooltip": "添加 GitHub 仓库挂件" 3 | }}}); -------------------------------------------------------------------------------- /langs/en.js: -------------------------------------------------------------------------------- 1 | tinyMCE.addI18n({"en": {"reposidget": { 2 | "tooltip": "Add GitHub Reposidget" 3 | }}}); -------------------------------------------------------------------------------- /assets/banner-772x250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myst729/wp-reposidget/HEAD/assets/banner-772x250.png -------------------------------------------------------------------------------- /wp-reposidget-mce.js: -------------------------------------------------------------------------------- 1 | void function() { 2 | tinymce.PluginManager.add('reposidget_mce', function(editor) { 3 | editor.addCommand('WP_Reposidget', function() { 4 | window.wpReposidgetDialog.open(editor.id, true); 5 | }); 6 | 7 | editor.addButton('reposidget_mce', { 8 | icon: 'reposidget', 9 | tooltip: editor.translate('reposidget.tooltip'), 10 | cmd: 'WP_Reposidget' 11 | }); 12 | }); 13 | }(); -------------------------------------------------------------------------------- /wp-reposidget.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{plugin_tip}} 4 |

5 | {{owner}} 6 | / 7 | {{name}} 8 |

9 |
10 |
11 |

{{description}}

12 |

{{homepage}}

13 |
14 | 18 |
-------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | ### 2.1.0 (2014-11-23) 4 | * Add GitHub authentication option. 5 | * 增加 GitHub 认证选项。 6 | 7 | ### 2.0.2 (2014-11-04) 8 | * Update author's info and screenshot. 9 | * 更新作者信息和截图。 10 | 11 | ### 2.0.1 (2014-09-03) 12 | * Back compatible with old shortcode syntax. Fix situation when repo info is wrong. 13 | * 兼容旧版短码格式。处理仓库信息有误的情况。 14 | 15 | ### 2.0.0 (2014-09-02) 16 | * Completely rewritten. Fix bugs and improve usability. Compatible with WordPress visual style. 17 | * 完全重写了代码。修复 bug,改善使用体验。兼容 WordPress 界面风格。 18 | 19 | ### 1.0.3 (2014-05-10) 20 | * Be compatible with GitHub API change. 21 | * 修复 GitHub API 变更。 22 | 23 | ### 1.0.2 (2013-05-23) 24 | * Format numbers. 25 | * 格式化数字。 26 | 27 | ### 1.0.1 (2013-05-23) 28 | * Add support to rich editor. Add support to language translation. 29 | * 支持可视化编辑器。支持多语言。 30 | 31 | ### 1.0.0 (2013-05-22) 32 | * First drop. 33 | * 发布第一个版本。 -------------------------------------------------------------------------------- /wp-reposidget-dialog.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Leo Deng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## WP Reposidget (GitHub 仓库挂件) 2 | 3 | Contributors: Leo Deng ([@米粽粽](http://weibo.com/myst729)) 4 | Plugin URI: https://github.com/myst729/wp-reposidget 5 | Tags: github, reposidget 6 | Requires at least: 3.9.0 7 | Tested up to: 4.0.1 8 | Stable tag: 2.1.0 9 | Author URI: http://myst729.github.io/ 10 | License: GPLv2 or later 11 | 12 | Insert GitHub repository widget into you posts/pages. 13 | 14 | 15 | ### Description 16 | 17 | Insert [GitHub](https://github.com/) repository widget into you posts/pages. 18 | 19 | 在 WordPress 文章/页面中嵌入 [GitHub](https://github.com/) 仓库挂件。 20 | 21 | 22 | ### Installation 23 | 24 | 1. Upload the plugin to your `/wp-content/plugins/` directory. 25 | 上传插件到您的 WordPress 插件目录。 26 | 27 | 2. Activate the plugin through the 'Plugins' menu in WordPress. 28 | 登录后台激活插件。 29 | 30 | 3. Now you could see the `GitHub Repo` button in post/page editor. 31 | 进入文章编辑界面,您会看到“GitHub Repo”的快捷按钮。 32 | 33 | 4. Click the button and input the owner and name of your GitHub repo. 34 | 点击按钮后,输入您的仓库所有者和名称即可插入短码。 35 | 36 | 5. (Optional) Fill in your GitHub personal access token in plugin options page. 37 | (可选)在插件设置页面填写你的 GitHub 个人访问令牌。 38 | 39 | 40 | ### Frequently Asked Questions 41 | 42 | 1. **Q**: Does this plugin support BitBucket? 43 | **问题**:这个插件支持添加 BitBucket 仓库吗? 44 | 45 | **A**: No. It's not going to happen until BitBucket API system is actually usable (it's basically shit at the moment). 46 | **回答**:不支持,除非 BitBucket API 系统达到实际可用的程度(目前就是一坨屎)。 47 | 48 | 2. **Q**: After upgraded to version 2.x, I got a "Parse error: syntax error, unexpected T_FUNCTION...", what's that? 49 | **问题**:升级到 2.x 以后报错,“Parse error: syntax error, unexpected T_FUNCTION...”,是什么原因? 50 | 51 | **A**: Version 2.x requires PHP 5.3 and above. Please upgrade your PHP environment, or you can continue to use version 1.x. 52 | **回答**:2.x 要求 PHP 版本不低于 5.3。请升级您的 PHP 环境,或继续使用 1.x 版本。 53 | 54 | 55 | ### Screenshots 56 | 57 | 1. Use shortcode to insert reposidget into the post/page. 58 | 使用简码向文章/页面中嵌入 GitHub 仓库。 59 | ![Insert Reposidget](https://raw.githubusercontent.com/myst729/wp-reposidget/master/screenshot-1.png) 60 | 61 | 2. The look of a reposidget. 62 | 嵌入文章的仓库挂件。 63 | ![Visual Style](https://raw.githubusercontent.com/myst729/wp-reposidget/master/screenshot-2.png) 64 | 65 | 3. Generate a GitHub personal access token. 66 | 生成 GitHub 个人访问令牌。 67 | ![Visual Style](https://raw.githubusercontent.com/myst729/wp-reposidget/master/screenshot-3.png) 68 | -------------------------------------------------------------------------------- /wp-reposidget-editor.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'fontello'; 3 | src: url('font/fontello.eot'); 4 | src: url('font/fontello.eot#iefix') format('embedded-opentype'), 5 | url('font/fontello.woff') format('woff'), 6 | url('font/fontello.ttf') format('truetype'), 7 | url('font/fontello.svg#fontello') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | 12 | i.mce-i-reposidget { 13 | font: 400 20px/1 fontello; 14 | padding: 0; 15 | vertical-align: top; 16 | speak: none; 17 | -webkit-font-smoothing: antialiased; 18 | -moz-osx-font-smoothing: grayscale; 19 | margin-left: -2px; 20 | padding-right: 2px; 21 | } 22 | 23 | i.mce-i-reposidget:before { 24 | content: '\e800'; 25 | } 26 | 27 | #wp-reposidget-wrapper { 28 | display: none; 29 | background-color: #fff; 30 | -webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); 31 | box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); 32 | width: 400px; 33 | overflow: hidden; 34 | margin-left: -200px; 35 | margin-top: -125px; 36 | position: fixed; 37 | top: 50%; 38 | left: 50%; 39 | z-index: 100105; 40 | } 41 | 42 | #wp-reposidget-backdrop { 43 | display: none; 44 | position: fixed; 45 | top: 0; 46 | left: 0; 47 | right: 0; 48 | bottom: 0; 49 | min-height: 360px; 50 | background: #000; 51 | opacity: 0.7; 52 | z-index: 100100; 53 | } 54 | 55 | #wp-reposidget-title { 56 | background: #fcfcfc; 57 | border-bottom: 1px solid #dfdfdf; 58 | height: 36px; 59 | font-size: 18px; 60 | font-weight: 600; 61 | line-height: 36px; 62 | padding: 0 36px 0 16px; 63 | } 64 | 65 | #wp-reposidget-close { 66 | color: #666; 67 | cursor: pointer; 68 | padding: 0; 69 | position: absolute; 70 | top: 0; 71 | right: 0; 72 | width: 36px; 73 | height: 36px; 74 | text-align: center; 75 | } 76 | 77 | #wp-reposidget-close:before { 78 | font: normal 20px/36px 'dashicons'; 79 | vertical-align: top; 80 | speak: none; 81 | -webkit-font-smoothing: antialiased; 82 | -moz-osx-font-smoothing: grayscale; 83 | width: 36px; 84 | height: 36px; 85 | content: '\f158'; 86 | } 87 | 88 | #wp-reposidget-close:hover, 89 | #wp-reposidget-close:focus { 90 | color: #2ea2cc; 91 | } 92 | 93 | #wp-reposidget-info { 94 | padding: 15px; 95 | } 96 | 97 | #wp-reposidget-info p { 98 | margin: 5px 15px 15px; 99 | } 100 | 101 | #wp-reposidget-info input { 102 | -webkit-box-sizing: border-box; 103 | -moz-box-sizing: border-box; 104 | box-sizing: border-box; 105 | margin-top: 8px; 106 | margin-bottom: 8px; 107 | padding: 6px 10px; 108 | width: 70%; 109 | } 110 | 111 | #wp-reposidget-info span { 112 | display: inline-block; 113 | width: 80px; 114 | text-align: right; 115 | padding-right: 8px; 116 | max-width: 24%; 117 | } 118 | 119 | #wp-reposidget-actions { 120 | padding: 8px 16px; 121 | background: #fcfcfc; 122 | border-top: 1px solid #dfdfdf; 123 | text-align: right; 124 | } -------------------------------------------------------------------------------- /font/fontello.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2014 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /langs/repo-zh_CN.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: wp-reposidget\n" 4 | "POT-Creation-Date: 2014-11-23 18:54+0800\n" 5 | "PO-Revision-Date: 2014-11-23 18:54+0800\n" 6 | "Last-Translator: Leo Deng \n" 7 | "Language-Team: myst729 \n" 8 | "Language: zh\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 1.6.10\n" 13 | "X-Poedit-KeywordsList: _e;__\n" 14 | "X-Poedit-Basepath: ..\n" 15 | "X-Poedit-SourceCharset: UTF-8\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | 18 | #: wp-reposidget.php:75 19 | msgid "This repository is not available anymore." 20 | msgstr "这个仓库不存在或已被移除。" 21 | 22 | #: wp-reposidget.php:82 wp-reposidget.php:101 23 | msgid "GitHub Reposidget for WordPress" 24 | msgstr "GitHub 仓库挂件 WordPress 插件" 25 | 26 | #: wp-reposidget.php:94 27 | msgid "This repository doesn't have description or homepage." 28 | msgstr "这个仓库没有描述或主页。" 29 | 30 | #: wp-reposidget.php:121 wp-reposidget.php:137 31 | msgid "Add GitHub Reposidget" 32 | msgstr "添加 GitHub 仓库挂件" 33 | 34 | #: wp-reposidget.php:122 35 | msgid "Please fill the owner and name of the repo:" 36 | msgstr "请填写要添加的仓库的所有者和名称:" 37 | 38 | #: wp-reposidget.php:123 39 | msgid "Repo Owner" 40 | msgstr "仓库所有者" 41 | 42 | #: wp-reposidget.php:124 43 | msgid "Repo Name" 44 | msgstr "仓库名称" 45 | 46 | #: wp-reposidget.php:125 47 | msgid "Add Repo" 48 | msgstr "添加仓库" 49 | 50 | #: wp-reposidget.php:126 51 | msgid "Cancel" 52 | msgstr "取消" 53 | 54 | #: wp-reposidget.php:137 55 | msgid "GitHub Repo" 56 | msgstr "GitHub 仓库" 57 | 58 | #: wp-reposidget.php:168 59 | msgid "Settings" 60 | msgstr "设置" 61 | 62 | #: wp-reposidget.php:174 63 | msgid "WP Reposidget" 64 | msgstr "GitHub 仓库挂件" 65 | 66 | #: wp-reposidget.php:185 67 | msgid "WP Reposidget options" 68 | msgstr "GitHub 仓库挂件 WordPress 插件选项" 69 | 70 | #: wp-reposidget.php:189 71 | msgid "Get authenticated to GitHub API (HIGHLY RECOMMENDED!)" 72 | msgstr "获得 GitHub API 访问认证(强烈推荐!)" 73 | 74 | #: wp-reposidget.php:190 75 | msgid "" 76 | "According to GitHub API's policy, unauthenticated requests have a rate limit " 77 | "of 60 times per hour. For authenticated requests, the rate limit is " 78 | "5,000 times per hour. If you find your reposidgets not working, it's " 79 | "possible that unauthenticated request quota is used up due to your site's " 80 | "page views." 81 | msgstr "" 82 | "根据 GitHub API 的使用条款,未认证请求的限额为每小时 60 次。获得认证后" 83 | "该限额将提升至每小时 5000 次。如果你发现自己的仓库挂件不能正常显示,很" 84 | "可能是因为站点访问量过大,用光了未认证请求的限额。" 85 | 86 | #: wp-reposidget.php:194 87 | msgid "Personal Access Token" 88 | msgstr "个人访问令牌" 89 | 90 | #: wp-reposidget.php:198 wp-reposidget.php:213 91 | msgid "Show Token" 92 | msgstr "显示令牌" 93 | 94 | #: wp-reposidget.php:210 95 | msgid "Hide Token" 96 | msgstr "隐藏令牌" 97 | 98 | #: wp-reposidget.php:223 99 | msgid "How do I get the personal access token?" 100 | msgstr "如何获取个人访问令牌?" 101 | 102 | #: wp-reposidget.php:224 103 | msgid "" 104 | "Visit https://github.com/settings/tokens/new, make sure " 106 | "public_repo is checked (it is the only scope requested by " 107 | "WP Reposidget, you may uncheck others) and generate a token." 108 | msgstr "" 109 | "访问 https://github.com/settings/tokens/new,确保选中了 " 111 | "public_repo(GitHub 仓库挂件只需要这个权限,你可以取消其他选" 112 | "项),生成令牌即可。" 113 | 114 | #~ msgid "GitHub Username" 115 | #~ msgstr "GitHub 用户名" 116 | 117 | #~ msgid "GitHub Password" 118 | #~ msgstr "GitHub 密码" 119 | 120 | #~ msgid "Insert GitHub Reposidget" 121 | #~ msgstr "插入 GitHub 项目挂件" 122 | 123 | #~ msgid "Insert Repo" 124 | #~ msgstr "插入项目" 125 | 126 | #~ msgid "Path to the repo you want to insert:" 127 | #~ msgstr "将要引入的 GitHub 项目路径:" 128 | -------------------------------------------------------------------------------- /wp-reposidget-dialog.js: -------------------------------------------------------------------------------- 1 | var wpReposidgetDialog = { 2 | initialized: false, 3 | 4 | init: function(editorId) { 5 | this.backdrop = document.getElementById("wp-reposidget-backdrop"); 6 | this.wrapper = document.getElementById("wp-reposidget-wrapper"); 7 | this.closeButton = document.getElementById("wp-reposidget-close"); 8 | this.ownerInput = document.getElementById("wp-reposidget-owner"); 9 | this.nameInput = document.getElementById("wp-reposidget-name"); 10 | this.addButton = document.getElementById("wp-reposidget-add"); 11 | this.cancelButton = document.getElementById("wp-reposidget-cancel"); 12 | this.editor = document.getElementById(editorId); 13 | 14 | this.probe(); 15 | this.initialized = true; 16 | }, 17 | 18 | probe: function() { 19 | document.addEventListener("keydown", this.closeDialog, false); 20 | this.backdrop.addEventListener("click", this.closeDialog, false); 21 | this.closeButton.addEventListener("click", this.closeDialog, false); 22 | this.cancelButton.addEventListener("click", this.closeDialog, false); 23 | this.addButton.addEventListener("click", this.insertShortcode, false); 24 | }, 25 | 26 | generateShortcode: function() { 27 | return '[repo owner="' + this.ownerInput.value + '" name="' + this.nameInput.value + '"]'; 28 | }, 29 | 30 | htmlInsert: function() { 31 | var editor = this.editor; 32 | var range = this.range; 33 | var shortcode = this.generateShortcode(); 34 | 35 | // insert shortcode into editor 36 | if(document.selection && range) { 37 | // IE 38 | editor.focus(); 39 | range.text = range.text + shortcode; 40 | range.moveToBookmark(range.getBookmark()); 41 | range.select(); 42 | range = null; 43 | } else if(typeof editor.selectionEnd !== "undefined") { 44 | // W3C 45 | var end = editor.selectionEnd; 46 | var cursor = end + shortcode.length; 47 | editor.value = editor.value.substring(0, end) + shortcode + editor.value.substring(end, editor.value.length); 48 | editor.selectionStart = editor.selectionEnd = cursor; 49 | } 50 | 51 | this.close(); 52 | }, 53 | 54 | mceInsert: function() { 55 | var shortcode = this.generateShortcode(); 56 | var mceEditor = this.mceEditor; 57 | var selected = mceEditor.selection.getContent(); 58 | 59 | mceEditor.focus(); 60 | mceEditor.insertContent(selected + shortcode); 61 | mceEditor.selection.collapse(); 62 | 63 | this.close(); 64 | }, 65 | 66 | insertShortcode: function() { 67 | if(wpReposidgetDialog.isMCE) { 68 | wpReposidgetDialog.mceInsert(); 69 | } else { 70 | wpReposidgetDialog.htmlInsert(); 71 | } 72 | }, 73 | 74 | reset: function() { 75 | this.ownerInput.value = ""; 76 | this.nameInput.value = ""; 77 | this.ownerInput.focus(); 78 | }, 79 | 80 | open: function(editorId, isMCE) { 81 | if(!this.initialized) { 82 | this.init(editorId); 83 | } 84 | 85 | this.isMCE = isMCE; 86 | if(isMCE && typeof tinymce !== "undefined") { 87 | this.mceEditor = this.mceEditor || tinymce.get(editorId); 88 | } 89 | 90 | if(!isMCE && document.selection && document.selection.createRange()) { 91 | // html editor in IE 92 | this.editor.focus(); 93 | this.range = document.selection.createRange().duplicate(); 94 | } 95 | 96 | this.reset(); 97 | this.backdrop.style.display = "block"; 98 | this.wrapper.style.display = "block"; 99 | this.ownerInput.focus(); 100 | }, 101 | 102 | close: function() { 103 | if(this.isMCE) { 104 | this.mceEditor.focus(); 105 | } else { 106 | this.editor.focus(); 107 | var range = this.range; 108 | if(range) { 109 | // html editor in IE 110 | range.moveToBookmark(range.getBookmark()); 111 | range.select(); 112 | range = null; 113 | } 114 | } 115 | 116 | this.backdrop.style.display = "none"; 117 | this.wrapper.style.display = "none"; 118 | }, 119 | 120 | closeDialog: function(e) { 121 | if(e.type === "keydown" && e.keyCode !== 27) { 122 | // pressed key is not "Esc" 123 | return; 124 | } 125 | wpReposidgetDialog.close(); 126 | } 127 | }; -------------------------------------------------------------------------------- /wp-reposidget.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'fontello'; 3 | src: url('font/fontello.eot'); 4 | src: url('font/fontello.eot#iefix') format('embedded-opentype'), 5 | url('font/fontello.woff') format('woff'), 6 | url('font/fontello.ttf') format('truetype'), 7 | url('font/fontello.svg#fontello') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | 12 | .reposidget { 13 | font-family: helvetica, arial, freesans, clean, sans-serif !important; 14 | color: #666 !important; 15 | max-width: 400px !important; 16 | margin: 20px 0 !important; 17 | display: block !important; 18 | clear: both !important; 19 | } 20 | 21 | .reposidget a { 22 | color: #4183c4 !important; 23 | text-decoration: none !important; 24 | } 25 | 26 | .reposidget a:hover { 27 | color: #4183c4 !important; 28 | text-decoration: underline !important; 29 | } 30 | 31 | .reposidget .fontello:before { 32 | font-family: fontello !important; 33 | font-style: normal !important; 34 | font-weight: normal !important; 35 | speak: none !important; 36 | display: inline-block !important; 37 | text-decoration: inherit !important; 38 | text-align: center !important; 39 | font-variant: normal !important; 40 | text-transform: none !important; 41 | } 42 | 43 | .reposidget .hidden { 44 | display: none !important; 45 | } 46 | 47 | .reposidget > header { 48 | height: 36px !important; 49 | background: #fafafa !important; 50 | background: -webkit-gradient(linear, 0 0, 0 100%, from(#fafafa), to(#eaeaea)) !important; 51 | background: -webkit-linear-gradient(top, #fafafa, #eaeaea) !important; 52 | background: -moz-linear-gradient(top, #fafafa, #eaeaea) !important; 53 | background: -ms-linear-gradient(top, #fafafa, #eaeaea) !important; 54 | background: linear-gradient(top, #fafafa, #eaeaea) !important; 55 | border: 1px solid #eaeaea !important; 56 | border-radius: 3px 3px 0 0 !important; 57 | position: relative !important; 58 | } 59 | 60 | .reposidget > header:before { 61 | content: '\e801' !important; 62 | width: 1.6em !important; 63 | line-height: 36px !important; 64 | position: absolute !important; 65 | font-size: 22px !important; 66 | color: #333 !important; 67 | } 68 | 69 | .reposidget > header h2 { 70 | height: 36px !important; 71 | line-height: 36px !important; 72 | overflow: hidden !important; 73 | box-sizing: border-box !important; 74 | font-size: 16px !important; 75 | font-weight: normal !important; 76 | margin: 0 0 0 2.2em !important; 77 | padding: 0 !important; 78 | display: inline-block !important; 79 | max-width: 336px !important; 80 | white-space: nowrap !important; 81 | text-overflow: ellipsis !important; 82 | } 83 | 84 | .reposidget > header .info { 85 | float: right !important; 86 | margin: 0.2em 0.3em 0 0 !important; 87 | line-height: 1em !important; 88 | font-size: 14px !important; 89 | } 90 | 91 | .reposidget > header .info:before { 92 | content: '\e804' !important; 93 | width: 1em !important; 94 | line-height: 1em !important; 95 | vertical-align: text-bottom !important; 96 | font-size: 14px !important; 97 | cursor: pointer !important; 98 | font-style: italic !important; 99 | color: #333 !important; 100 | opacity: 0.5 !important; 101 | } 102 | 103 | .reposidget > header .info:hover:before { 104 | opacity: 1 !important; 105 | } 106 | 107 | .reposidget > header .info a { 108 | background: rgba(0, 0, 0, 0.8) !important; 109 | position: absolute !important; 110 | right: 0 !important; 111 | top: -30px !important; 112 | font-size: 13px !important; 113 | padding: 0 6px !important; 114 | border-radius: 5px !important; 115 | display: none !important; 116 | color: white !important; 117 | height: 25px !important; 118 | line-height: 25px !important; 119 | z-index: 9999 !important; 120 | } 121 | 122 | .reposidget > header .info a:before { 123 | content: ' ' !important; 124 | height: 0 !important; 125 | width: 0 !important; 126 | position: absolute !important; 127 | right: 4px !important; 128 | top: 25px !important; 129 | border-left: 5px solid rgba(255, 255, 255, 0) !important; 130 | border-right: 5px solid rgba(255, 255, 255, 0) !important; 131 | border-top: 8px solid rgba(0, 0, 0, 0.8) !important; 132 | } 133 | 134 | .reposidget > header .info:hover a { 135 | display: block !important; 136 | } 137 | 138 | .reposidget > section { 139 | padding: 5px !important; 140 | background: #fafafa !important; 141 | border: 1px solid #ddd !important; 142 | box-shadow: inset 0 1px 1px #fff !important; 143 | line-height: 1.5 !important; 144 | } 145 | 146 | .reposidget > section p { 147 | margin: 5px !important; 148 | font-size: 13px !important; 149 | line-height: 1.5 !important; 150 | } 151 | 152 | .reposidget > section p.homepage { 153 | white-space: nowrap !important; 154 | text-overflow: ellipsis !important; 155 | overflow: hidden !important; 156 | } 157 | 158 | .reposidget > footer { 159 | height: 46px !important; 160 | background: #fcfcfc !important; 161 | border: 1px solid #ddd !important; 162 | border-top: none !important; 163 | border-radius: 0 0 3px 3px !important; 164 | padding: 0 10px !important; 165 | } 166 | 167 | .reposidget > footer span { 168 | vertical-align: top !important; 169 | margin: 10px 0 0 !important; 170 | border: 1px solid #ddd !important; 171 | height: 24px !important; 172 | line-height: 24px !important; 173 | display: inline-block !important; 174 | color: #777 !important; 175 | font-size: 12px !important; 176 | font-weight: bold !important; 177 | padding: 0 7px !important; 178 | } 179 | 180 | .reposidget > footer span:before { 181 | width: 1em !important; 182 | margin-right: .4em !important; 183 | line-height: 1em !important; 184 | vertical-align: text-bottom !important; 185 | font-size: 14px !important; 186 | color: #333 !important; 187 | } 188 | 189 | .reposidget > footer .star { 190 | border-radius: 3px 0 0 3px !important; 191 | } 192 | 193 | .reposidget > footer .star:before { 194 | content: '\e802' !important; 195 | } 196 | 197 | .reposidget > footer .fork { 198 | border-radius: 0 3px 3px 0 !important; 199 | border-left: none !important; 200 | } 201 | 202 | .reposidget > footer .fork:before { 203 | content: '\e803' !important; 204 | } 205 | 206 | .reposidget > footer a { 207 | float: right !important; 208 | margin: 6px 0 0 0 !important; 209 | display: inline-block !important; 210 | padding: 8px 15px !important; 211 | line-height: 1.25 !important; 212 | font-size: 12px !important; 213 | font-weight: bold !important; 214 | color: #666 !important; 215 | text-shadow: rgba(255, 255, 255, 0.898438) 0px 1px !important; 216 | background: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#e5e5e5)) !important; 217 | background: -webkit-linear-gradient(top, #f5f5f5, #e5e5e5) !important; 218 | background: -moz-linear-gradient(top, #f5f5f5, #e5e5e5) !important; 219 | background: -ms-linear-gradient(top, #f5f5f5, #e5e5e5) !important; 220 | background: linear-gradient(top, #f5f5f5, #e5e5e5) !important; 221 | border-radius: 3px !important; 222 | border: 1px solid #ddd !important; 223 | border-bottom-color: #bbb !important; 224 | box-shadow: rgba(0, 0, 0, 0.0976563) 0px 1px 3px !important; 225 | -webkit-user-select: none !important; 226 | } 227 | 228 | .reposidget > footer a:hover { 229 | color: #337797 !important; 230 | text-shadow: rgba(255, 255, 255, 0.898438) 0px 1px !important; 231 | background: -webkit-gradient(linear, 0 0, 0 100%, from(#f0f7fa), to(#d8eaf2)) !important; 232 | background: -webkit-linear-gradient(top, #f0f7fa, #d8eaf2) !important; 233 | background: -moz-linear-gradient(top, #f0f7fa, #d8eaf2) !important; 234 | background: -ms-linear-gradient(top, #f0f7fa, #d8eaf2) !important; 235 | background: linear-gradient(top, #f0f7fa, #d8eaf2) !important; 236 | border: 1px solid #cbe3ee !important; 237 | border-bottom-color: #97c7dd !important; 238 | text-decoration: none !important; 239 | } 240 | 241 | .reposidget > footer a:active { 242 | color: #fff !important; 243 | text-shadow: rgba(0, 0, 0, 0.296875) 0px -1px 0px !important; 244 | background: -webkit-gradient(linear, 0 0, 0 100%, from(#0770a0), to(#0ca6dd)) !important; 245 | background: -webkit-linear-gradient(top, #0770a0, #0ca6dd) !important; 246 | background: -moz-linear-gradient(top, #0770a0, #0ca6dd) !important; 247 | background: -ms-linear-gradient(top, #0770a0, #0ca6dd) !important; 248 | background: linear-gradient(top, #0770a0, #0ca6dd) !important; 249 | border: 1px solid #2a65a0 !important; 250 | border-bottom-color: #0770a0 !important; 251 | } -------------------------------------------------------------------------------- /wp-reposidget.php: -------------------------------------------------------------------------------- 1 | $atts_owner, 71 | "owner_url" => "https://github.com/" . $atts_owner, 72 | "name" => $atts_name, 73 | "html_url" => "https://github.com/" . $atts_owner . "/" . $atts_name, 74 | "default_branch" => "-", 75 | "description" => __("This repository is not available anymore.", "repo"), 76 | "toggle_description" => "", 77 | "homepage" => "https://github.com/" . $atts_owner . "/" . $atts_name, 78 | "toggle_homepage" => "hidden", 79 | "stargazers_count" => "-", 80 | "forks_count" => "-", 81 | "toggle_download" => "hidden", 82 | "plugin_tip" => __("GitHub Reposidget for WordPress", "repo"), 83 | "plugin_url" => WP_REPOSIDGET_HOMEPAGE 84 | ); 85 | } else { 86 | $description_empty = ($repo["description"] == ""); 87 | $homepage_empty = ($repo["homepage"] == "" || $repo["homepage"] == null); 88 | $data = array( 89 | "owner" => $repo["owner"]["login"], 90 | "owner_url" => $repo["owner"]["html_url"], 91 | "name" => $repo["name"], 92 | "html_url" => $repo["html_url"], 93 | "default_branch" => $repo["default_branch"], 94 | "description" => ($description_empty && $homepage_empty) ? __("This repository doesn't have description or homepage.", "repo") : $repo["description"], 95 | "toggle_description" => ($description_empty && !$homepage_empty) ? "hidden" : "", 96 | "homepage" => $homepage_empty ? $repo["html_url"] : $repo["homepage"], 97 | "toggle_homepage" => $homepage_empty ? "hidden" : "", 98 | "stargazers_count" => number_format($repo["stargazers_count"]), 99 | "forks_count" => number_format($repo["forks_count"]), 100 | "toggle_download" => "", 101 | "plugin_tip" => __("GitHub Reposidget for WordPress", "repo"), 102 | "plugin_url" => WP_REPOSIDGET_HOMEPAGE 103 | ); 104 | } 105 | 106 | $template = plugin_dir_path( __FILE__ ) . "wp-reposidget.html"; 107 | $pattern = '/{{([a-z_]+)}}/'; 108 | 109 | return wp_reposidget_render($template, $pattern, $data); 110 | } 111 | 112 | function wp_reposidget_editor_style() { 113 | wp_enqueue_style("reposidget_html", plugins_url("wp-reposidget-editor.css", __FILE__)); 114 | } 115 | 116 | function wp_reposidget_editor() { 117 | if(wp_script_is("quicktags")) { 118 | $template = plugin_dir_path( __FILE__ ) . "wp-reposidget-dialog.html"; 119 | $pattern = '/{{([a-z_]+)}}/'; 120 | $data = array( 121 | "title" => __('Add GitHub Reposidget', 'repo'), 122 | "message" => __('Please fill the owner and name of the repo:', 'repo'), 123 | "owner" => __('Repo Owner', 'repo'), 124 | "name" => __('Repo Name', 'repo'), 125 | "add" => __('Add Repo', 'repo'), 126 | "cancel" => __('Cancel', 'repo') 127 | ); 128 | 129 | echo wp_reposidget_render($template, $pattern, $data); 130 | ?> 131 | 132 | 140 | 'wp-reposidget-options'), admin_url('options-general.php')); 168 | $settings_link = '' . __('Settings', 'repo').''; 169 | array_unshift($links, $settings_link); 170 | return $links; 171 | } 172 | 173 | function wp_reposidget_options_menu() { 174 | add_options_page(__('WP Reposidget', 'repo'), __('WP Reposidget', 'repo'), 'manage_options', 'wp-reposidget-options', 'wp_reposidget_options_page'); 175 | } 176 | 177 | function wp_reposidget_register_settings() { 178 | add_option('wp_reposidget_github_token', ''); 179 | register_setting('wp_reposidget_options_group', 'wp_reposidget_github_token'); 180 | } 181 | 182 | function wp_reposidget_options_page() { 183 | ?> 184 |
185 |

186 |
187 | 188 |
189 |

190 |

60 times per hour. For authenticated requests, the rate limit is 5,000 times per hour. If you find your reposidgets not working, it's possible that unauthenticated request quota is used up due to your site's page views.", 'repo') ?>

191 | 192 | 193 | 196 | 200 | 201 |
194 | 195 | 197 | 198 | 199 |
202 | 215 |
216 | 217 |
218 |

219 |

https://github.com/settings/tokens/new, make sure public_repo is checked (it is the only scope requested by WP Reposidget, you may uncheck others) and generate a token.', 'repo') ?>

220 |

" alt="GitHub Personal Access Token" style="box-shadow:0 0 15px lightgray">

221 |
222 | 234 | --------------------------------------------------------------------------------