├── .gitignore ├── LICENSE ├── README.md ├── assets └── javascripts │ └── initializers │ └── hide-post.js.es6 └── plugin.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | *.sassc 3 | .sass-cache 4 | capybara-*.html 5 | .rspec 6 | .rvmrc 7 | /.bundle 8 | /vendor/bundle 9 | /log/* 10 | /tmp/* 11 | /db/*.sqlite3 12 | /public/system/* 13 | /coverage/ 14 | /spec/tmp/* 15 | **.orig 16 | rerun.txt 17 | pickle-email-*.html 18 | .project 19 | config/initializers/secret_token.rb 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Discourse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | discourse-hide-post 2 | =================== 3 | 4 | Hide post plugin for [Discourse](http://discourse.org). 5 | 6 | Installation 7 | ============ 8 | 9 | * Run `rake plugin:install repo=http://github.com/discourse/discourse-hide-post` in your discourse directory 10 | * In development mode, run `rake assets:clean` 11 | * In production, recompile your assets: `rake assets:precompile` 12 | 13 | License 14 | ======= 15 | MIT 16 | -------------------------------------------------------------------------------- /assets/javascripts/initializers/hide-post.js.es6: -------------------------------------------------------------------------------- 1 | import { Button } from "discourse/views/post-menu"; 2 | 3 | export default { 4 | name: "hide-posts", 5 | 6 | initialize: function (container) { 7 | var PostMenuView = container.lookupFactory("view:post-menu"); 8 | 9 | PostMenuView.reopen({ 10 | shouldRerenderHideButton: Discourse.View.renderIfChanged("post.temporarily_hidden"), 11 | 12 | buttonForHide: function (post, buffer) { 13 | var direction = !!post.getWithDefault("temporarily_hidden", false) ? "down" : "up"; 14 | return new Button("hide", direction, "chevron-" + direction); 15 | }, 16 | 17 | clickHide: function () { 18 | $("#post_" + this.get("post.post_number") + " .cooked").toggle(); 19 | this.toggleProperty("post.temporarily_hidden"); 20 | } 21 | }); 22 | 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /plugin.rb: -------------------------------------------------------------------------------- 1 | # name: hide post 2 | # about: add a button at the end of every post allowing users to hide the post 3 | # version: 0.2 4 | # authors: Régis Hanol 5 | --------------------------------------------------------------------------------