REMOVE: discourse_poll has not worked for over a year now. Let's

remove it.
This commit is contained in:
Robin Ward 2014-01-29 12:00:21 -05:00
parent 2892153712
commit 9117470f27
25 changed files with 0 additions and 628 deletions

View File

@ -1,13 +0,0 @@
source 'https://rubygems.org'
group :test do
gem 'rails'
gem 'rspec'
gem 'mocha'
end
# TODO: We need our own gem server
gem 'discourse_plugin', path: '../discourse_plugin'
# Specify your gem's dependencies in rails_multisite.gemspec
gemspec

View File

@ -1,111 +0,0 @@
PATH
remote: .
specs:
discourse_poll (0.0.1)
PATH
remote: ../discourse_plugin
specs:
discourse_plugin (0.0.1)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.3)
diff-lcs (1.1.3)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.19)
mocha (0.12.7)
metaclass (~> 0.0.1)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
discourse_plugin!
discourse_poll!
mocha
rails
rspec

View File

@ -1,22 +0,0 @@
Copyright (c) 2012 Robin Ward
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,3 +0,0 @@
# Discourse Poll Gem
Include to give Discourse the ability to support polls.

View File

@ -1,7 +0,0 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:test) do |spec|
spec.pattern = 'spec/*_spec.rb'
end

View File

@ -1,20 +0,0 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/discourse_poll/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Robin Ward"]
gem.email = ["robin.ward@gmail.com"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summary}
gem.homepage = ""
# when this is extracted comment it back in, prd has no .git
# gem.files = `git ls-files`.split($\)
gem.files = Dir['README*','LICENSE','lib/**/*.rb']
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "discourse_poll"
gem.require_paths = ["lib"]
gem.version = DiscoursePoll::VERSION
end

View File

@ -1,5 +0,0 @@
require 'discourse_poll/version'
require 'discourse_poll/engine' if defined?(Rails) && (!Rails.env.test?)
I18n.load_path << "#{File.dirname(__FILE__)}/discourse_poll/locale/en.yml"

View File

@ -1,21 +0,0 @@
require 'discourse_poll/plugin'
module DiscoursePoll
class Engine < Rails::Engine
engine_name 'discourse_poll'
initializer "discourse_poll.configure_rails_initialization" do |app|
app.config.after_initialize do
DiscoursePluginRegistry.setup(DiscoursePoll::Plugin)
end
app.config.to_prepare do
DiscoursePoll::Plugin.include_mixins
end
end
end
end

View File

@ -1,47 +0,0 @@
en:
js:
poll:
title: "Poll"
description: "This topic is a poll. Vote for posts by clicking the vote button. Posts with the most votes will rise to the top!"
vote:
voted: 'voted'
title: 'vote'
help: 'vote for this post'
who_voted: 'click to see who voted for this option'
cant: "Sorry, you've already voted."
not_logged_in: "You must be logged in to vote."
topic_statuses:
poll:
help: "this topic is a poll"
topic:
reply:
poll: "Add Poll Option"
post:
archetypes:
poll:
public: "Other users can see what you voted for."
private: "Your vote will be kept private."
single_vote: "You may only vote once."
many_votes: "You may vote for as many options as you like."
post_action_types:
vote:
title: 'Vote'
description: 'Vote for this post'
long_form: 'voted for this post'
archetypes:
poll:
title: "Poll Topic"
options:
single_vote:
title: "Only allow one vote"
description: "A user may only vote on one post."
private_poll:
title: "Voting is Private"
description: "Hide who voted for what choice."

View File

@ -1,49 +0,0 @@
require 'discourse_plugin'
module DiscoursePoll
class Plugin < DiscoursePlugin
MAX_SORT_ORDER = 2147483647
POLL_OPTIONS = {private_poll: 1, single_vote: 1}
def setup
# Add our Assets
register_js('discourse_poll')
register_css('discourse_poll')
# Create the poll archetype
register_archetype('poll', POLL_OPTIONS)
# Callbacks
listen_for(:before_create_post)
end
# Callbacks below
def before_create_post(post)
return unless post.archetype == 'poll'
if post.post_number == 1
post.sort_order = 1
else
post.sort_order = DiscoursePoll::Plugin::MAX_SORT_ORDER
end
end
module TopicViewSerializerMixin
def self.included(base)
base.attributes :private_poll, :single_vote
end
def private_poll
object.topic.has_meta_data_boolean?(:private_poll)
end
def single_vote
object.topic.has_meta_data_boolean?(:single_vote)
end
end
end
end

View File

@ -1,3 +0,0 @@
module DiscoursePoll
VERSION = "0.0.1"
end

View File

@ -1,66 +0,0 @@
require 'spec_helper'
require 'discourse_poll/plugin'
require 'ostruct'
describe DiscoursePoll::Plugin do
let(:registry) { stub_everything }
let(:plugin) { DiscoursePoll::Plugin.new(registry) }
context '.setup' do
it 'registers its js' do
plugin.expects(:register_js)
plugin.setup
end
it 'registers its css' do
plugin.expects(:register_css)
plugin.setup
end
it 'registers a poll archetype' do
plugin.expects(:register_archetype).with('poll', DiscoursePoll::Plugin::POLL_OPTIONS)
plugin.setup
end
it 'registers a handler on post_create' do
plugin.expects(:listen_for).with(:before_create_post)
plugin.setup
end
end
context ".before_create_post" do
context 'without a poll' do
let(:post) { OpenStruct.new(archetype: 'something-else', post_number: 1000) }
it "doesn't set the sort order" do
plugin.before_create_post(post)
post.sort_order.should_not == DiscoursePoll::Plugin::MAX_SORT_ORDER
end
end
context 'with a poll' do
let(:post) { OpenStruct.new(archetype: 'poll') }
it 'sets the sort order to 1 when the post_number is 1' do
post.post_number = 1
plugin.before_create_post(post)
post.sort_order.should == 1
end
it 'sets the sort order to MAX_SORT_ORDER when the post_number is not 1' do
post.post_number = 1000
plugin.before_create_post(post)
post.sort_order.should == DiscoursePoll::Plugin::MAX_SORT_ORDER
end
end
end
end

View File

@ -1,13 +0,0 @@
require 'rubygems'
require 'rails'
ENV["RAILS_ENV"] ||= 'test'
RSpec.configure do |config|
config.mock_framework = :mocha
config.color_enabled = true
end

View File

@ -1,3 +0,0 @@
//= require_tree ./discourse_poll

View File

@ -1,45 +0,0 @@
(function() {
window.Discourse.Post.reopen({
voteAction: function () {
return this.get('actionByName.vote');
}.property('actionByName.vote'),
// We never show "replies below" for polls.
replyBelowUrl: function() {
if (this.get('topic.archetype') === 'poll') return null;
return this.get('replyBelowUrlComputed');
}.property('replyBelowUrlComputed', 'topic.archetype'),
// Vote for this post
vote: function() {
voteType = Discourse.get('site.post_action_types').findProperty('name_key', 'vote');
this.get('voteAction').act();
Em.run.next(function () {
this.set('topic.voted_in_topic', true);
}.bind(this));
return false;
},
cantVote: function() {
if (!Discourse.get('currentUser')) {
bootbox.alert(I18n.t('vote.not_logged_in'));
return false;
}
bootbox.alert(I18n.t('vote.cant'));
return false;
},
undoVote: function() {
voteType = Discourse.get('site.post_action_types').findProperty('name_key', 'vote');
this.get('voteAction').undo();
Em.run.next(function () {
this.set('topic.voted_in_topic', false);
}.bind(this));
return false;
}
});
}).call(this);

View File

@ -1,9 +0,0 @@
(function() {
Discourse.PostActionType.reopen({
isVote: function() {
return (this.get('name_key') === 'vote');
}.property('name_key')
});
}).call(this);

View File

@ -1,15 +0,0 @@
<h3><i class='fa fa-check-square-o'></i>{{i18n poll.title}}</h3>
<p>{{{i18n poll.description}}}</p>
<ul>
{{#if controller.content.private_poll}}
<li>{{i18n post.archetypes.poll.private}}</li>
{{else}}
<li>{{i18n post.archetypes.poll.public}}</li>
{{/if}}
{{#if controller.content.single_vote}}
<li>{{i18n post.archetypes.poll.single_vote}}</li>
{{else}}
<li>{{i18n post.archetypes.poll.many_votes}}</li>
{{/if}}
</ul>

View File

@ -1,17 +0,0 @@
{{#if view.showVotes}}
{{#if view.canSeeWhoVoted}}
<a href='#' class='total' {{action whoActed view.post.voteAction target="controller"}} title="{{i18n vote.who_voted}}">{{view.post.voteAction.count}}</a>
{{else}}
<div {{bindAttr class=":total view.post.voteAction.acted:chosen"}}>{{view.post.voteAction.count}}</div>
{{/if}}
{{#if view.showVoteControls}}
<button class='btn small' {{bindAttr disabled="view.voteDisabled"}} {{action vote target="view.post"}} title="{{i18n vote.help}}"><i class='fa fa-check-square-o'></i><br/>{{view.voteButtonText}}</button>
{{else}}
<button class='btn small' {{action cantVote target="view.post"}}><i class='fa fa-check-square-o'></i><br/>{{view.voteButtonText}}</button>
{{/if}}
{{#if view.post.voteAction.can_undo}}
<a href="#" class='undo' {{action undoVote target="view.post"}}>undo</a>
{{/if}}
{{/if}}

View File

@ -1,18 +0,0 @@
(function() {
window.Discourse.PostView.reopen({
extraClass: function() {
if (this.get('showVotes')) return 'votes';
return null;
}.property('showVotes'),
showVotes: function() {
var post = this.get('post');
if (post.get('post_number') === 1) return;
if (post.get('post_type') !== Discourse.Post.REGULAR_TYPE) return;
if (post.get('reply_to_post_number')) return;
return (post.get('topic.archetype') === 'poll');
}.property('post.post_number', 'post.post_type', 'post.reply_to_post_number')
})
}).call(this);

View File

@ -1,12 +0,0 @@
(function() {
Discourse.PrependPostView.prototype.on("prependPostContent", function(event) {
// Append our template for the poll controls
if (this.get('controller.content.archetype') == 'poll') {
this.get('childViews').pushObject(Discourse.VoteControlsView.create());
}
});
}).call(this);

View File

@ -1,9 +0,0 @@
(function() {
window.Discourse.TopicFooterButtonsView.reopen({
replyButtonTextPoll: function() {
return I18n.t("topic.reply.poll");
}.property()
});
}).call(this);

View File

@ -1,14 +0,0 @@
(function() {
Discourse.TopicSummaryView.prototype.on("appendSummaryInformation", function(childViews) {
// Add the poll information
if (this.get('topic.archetype') === 'poll') {
childViews.pushObject(Em.View.create({
tagName: 'section',
classNames: ['information'],
templateName: 'discourse_poll/templates/about_poll'
}));
}
});
}).call(this);

View File

@ -1,12 +0,0 @@
(function() {
Discourse.TopicStatusView.prototype.on("addCustomIcon", function(buffer) {
// Add check icon for polls
if (this.get('topic.archetype') === 'poll') {
this.renderIcon(buffer, 'square-o', 'poll');
}
});
}).call(this);

View File

@ -1,41 +0,0 @@
(function() {
window.Discourse.VoteControlsView = Em.View.extend({
templateName: 'discourse_poll/templates/poll_controls',
classNameBindings: ['pollControlsClass'],
postBinding: 'parentView.post',
showVotesBinding: 'parentView.parentView.showVotes',
canSeeWhoVoted: function() {
if (this.get('post.voteAction.count') === 0) return false;
return !this.get('controller.content.private_poll');
}.property('post.voteAction.count'),
showVoteControls: function() {
if (!Discourse.get('currentUser')) return false;
if (this.get('post.post_number') === 1) return;
if (this.get('post.topic.single_vote') && this.get('post.topic.voted_in_topic')) return false;
if (this.get('post.topic.archived')) return false;
return true;
}.property('post.post_number', 'post.topic.archived', 'post.topic.single_vote', 'post.topic.voted_in_topic'),
pollControlsClass: function() {
if (this.get('post.post_number') === 1) return;
if (this.get('post.reply_to_post_number')) return;
return 'poll-controls';
}.property('showVoteControls'),
canUndo: function() {
return true;
}.property(),
voteDisabled: function() {
return !this.get('post.voteAction.can_act');
}.property('post.voteAction.can_act'),
voteButtonText: function() {
if (!this.get('post.voteAction.can_act')) return I18n.t("vote.voted");
return I18n.t("vote.title");
}.property('post.voteAction.can_act')
})
}).call(this);

View File

@ -1,53 +0,0 @@
#main
.votes
aside
margin-left: 55px !important
blockquote
margin-left: 0
blockquote
margin-left: 55px
.onebox-result
margin-left: 55px
.topic-body
.contents.votes
min-height: 120px !important
.poll-controls
width: 50px
float: left
height: 100%
margin-right: 5px
padding-top: 10px
text-align: center
.undo
font-size: 12px
.total
color: #000
font-size: 30px
line-height: 20px
text-decoration: none
margin: 0
padding: 0
.total.chosen
color: #0f0
button
margin: 10px 0 0 0
font-size: 14px
padding: 0 3px
i
font-size: 17px
margin: 4px 0 0 0
padding: 0
display: inline-block
&:disabled
background-color: #070
color: #fff
text-shadow: none !important