├── .gitignore ├── .DS_Store ├── yarn.lock ├── README.md ├── plugin.json ├── static └── lib │ └── main.js ├── library.js ├── LICENSE └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netdata/nodebb-plugin-twitter-netdata/master/.DS_Store -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NodeBB Twitter Plugin 2 | 3 | This is a Netdata fork of the NodeBB plugin found here: https://github.com/NodeBB-Community/nodebb-plugin-twitter 4 | -------------------------------------------------------------------------------- /plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "nodebb-plugin-twitter", 3 | "name": "NodeBB Twitter Embed Plugin", 4 | "description": "NodeBB Plugin that allows users to embed tweets inline in their posts.", 5 | "url": "https://github.com/dovydaskukalis/nodebb-plugin-twitter", 6 | "library": "./library.js", 7 | "hooks": [ 8 | { "hook": "filter:header.build", "method": "init.global.addNavigation" }, 9 | { "hook": "filter:parse.post", "method": "parse", "priority": 6 } 10 | ], 11 | "scripts": [ 12 | "static/lib/main.js" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /static/lib/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* globals document, $ */ 4 | 5 | $(document).ready(function () { 6 | // Inject twitter widget into footer 7 | var scriptEl = document.createElement('script'); 8 | scriptEl.async = 'async'; 9 | scriptEl.src = '//platform.twitter.com/widgets.js'; 10 | scriptEl.charset = 'utf-8'; 11 | 12 | document.head.appendChild(scriptEl); 13 | 14 | function enhanceEmbed() { 15 | var target = $('ul[component="topic"]').get(0); 16 | twttr.widgets.load(target); 17 | } 18 | 19 | $(window).on('action:posts.loaded action:topic.loaded', function () { 20 | setTimeout(enhanceEmbed, window.twttr ? 0 : 1000); 21 | }); 22 | }); -------------------------------------------------------------------------------- /library.js: -------------------------------------------------------------------------------- 1 | (function(module) { 2 | "use strict"; 3 | 4 | var Twitter = {}, 5 | embed = '
'; 6 | 7 | Twitter.parse = function(data, callback) { 8 | var regularUrl = /.+?<\/a>/g 9 | var postContent = data && data.postData && data.postData.content; 10 | 11 | if (postContent && postContent.match(regularUrl)) { 12 | data.postData.content = postContent.replace(regularUrl, embed); 13 | } 14 | callback(null, data); 15 | }; 16 | 17 | module.exports = Twitter; 18 | }(module)); 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Dovydas 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodebb-plugin-twitter", 3 | "version": "0.1.0", 4 | "description": "NodeBB Plugin that allows users to embed tweets inline in their posts", 5 | "main": "library.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/nodebb-community/nodebb-plugin-twitter" 12 | }, 13 | "keywords": [ 14 | "nodebb", 15 | "plugin", 16 | "twitter", 17 | "embed", 18 | "tweet" 19 | ], 20 | "author": { 21 | "name": "Dovydas", 22 | "email": "dovydas.kukalis@gmail.com" 23 | }, 24 | "license": "BSD-2-Clause", 25 | "bugs": { 26 | "url": "https://github.com/nodebb-community/nodebb-plugin-twitter/issues" 27 | }, 28 | "nbbpm": { 29 | "compatibility": "^0.7.0" 30 | }, 31 | "readme": "# NodeBB Twitter Plugin\r\n\r\nThis NodeBB plugin allows users to embed tweets inline in their posts.\r\n\r\n## Installation\r\n\r\n npm install nodebb-plugin-twitter\r\n\r\n## Using\r\n\r\nAll tweet URLs for example https://twitter.com/NodeBB/status/422901451896025089 will be automatically parsed as embedded tweet.\r\n\r\nYou can get tweet URL by clicking on tweet's time and copying page URL in your browser.\r\n![](http://i.imgur.com/ZkF0Mig.png) \r\n\r\n## Screenshots\r\n\r\n![twitter-plugin.png](http://i.imgur.com/8raiDZj.png) \r\n", 32 | "readmeFilename": "README.md", 33 | "_id": "nodebb-plugin-twitter@0.0.10", 34 | "_from": "nodebb-plugin-twitter@", 35 | "homepage": "https://github.com/nodebb-community/nodebb-plugin-twitter", 36 | "gitHead": "044b6f54513ab289489472786687d54aa9ad497f", 37 | "_shasum": "204cd9a04df923775833e837367039de354d4c39" 38 | } 39 | --------------------------------------------------------------------------------