card-mod-comment 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5e2b8a945e89993d22b8c37767949fe653563b085c0dfb99d0c8d4c81c5781f8
4
+ data.tar.gz: c0613cbb53f7adf5da82143217ee7a6a43d118cbe0b36e1ecfdb1089cb79caaf
5
+ SHA512:
6
+ metadata.gz: 4b675eb863e02be19e7809b0ec151564cc679d82fdc174def3e845e676523cb91eabde303105e415ee08b9bb479af81b44f462e048b8620624582c7717066c6d
7
+ data.tar.gz: cf9d0051c8c2d36facf48b2aea651c9a823003020fce0d17017a13934b95504133959f396a9973823cbedc31c11e745c4441e4408e0659528d33e6bda8b7a802
@@ -0,0 +1,80 @@
1
+ def commenting?
2
+ comment && action != :delete
3
+ end
4
+
5
+ event :add_comment, :prepare_to_store, on: :save, when: :comment do
6
+ Env.session[:comment_author] = comment_author if Env.session
7
+ return unless comment.present?
8
+ self.content =
9
+ [content, format.comment_with_signature].compact.join "\n<hr\>\n"
10
+ self.comment = nil
11
+ end
12
+
13
+ attr_writer :comment_author
14
+
15
+ def comment_author
16
+ @comment_author ||=
17
+ Env.session[:comment_author] || Env.params[:comment_author] || "Anonymous"
18
+ end
19
+
20
+ def clean_comment
21
+ comment.split(/\n/).map do |line|
22
+ "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"
23
+ end * "\n"
24
+ end
25
+
26
+ format do
27
+ def comment_with_signature
28
+ card.clean_comment + "\n" + comment_signature
29
+ end
30
+
31
+ def comment_signature
32
+ wrap_with :div, class: "w-comment-author" do
33
+ "#{comment_author}.....#{Time.zone.now}"
34
+ end
35
+ end
36
+
37
+ def comment_author
38
+ if Auth.signed_in?
39
+ "[[#{Auth.current.name}]]"
40
+ else
41
+ "#{card.comment_author} (Not signed in)"
42
+ end
43
+ end
44
+
45
+ view :comment_box, denial: :blank, unknown: true, perms: :update do
46
+ wrap_with :div, class: "comment-box nodblclick" do
47
+ action = card.new_card? ? :create : :update
48
+ card_form action do
49
+ [hidden_comment_fields, comment_box, comment_buttons]
50
+ end
51
+ end
52
+ end
53
+
54
+ def hidden_comment_fields
55
+ return unless card.new_card?
56
+ hidden_field_tag "card[name]", card.name
57
+ # FIXME: wish we had more generalized solution for names.
58
+ # without this, nonexistent cards will often take left's linkname.
59
+ # (needs test)
60
+ end
61
+
62
+ def comment_box
63
+ text_area :comment, rows: 3
64
+ end
65
+
66
+ def comment_buttons
67
+ wrap_with :div, class: "comment-buttons" do
68
+ [comment_author_label, comment_submit_button]
69
+ end
70
+ end
71
+
72
+ def comment_author_label
73
+ return if Auth.signed_in?
74
+ %(<label>My Name is:</label> #{text_field :comment_author})
75
+ end
76
+
77
+ def comment_submit_button
78
+ submit_button text: "Comment", type: :submit, disable_with: "Commenting"
79
+ end
80
+ end
@@ -0,0 +1 @@
1
+ include_set Abstract::Permission
@@ -0,0 +1,9 @@
1
+ view :titled, unknown: true do
2
+ voo.show :comment_box
3
+ super()
4
+ end
5
+
6
+ view :open, unknown: true do
7
+ voo.show :comment_box
8
+ super()
9
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: card-mod-comment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.0
5
+ platform: ruby
6
+ authors:
7
+ - Ethan McCutchen
8
+ - Philipp Kühl
9
+ - Gerry Gleason
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2020-12-24 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: card
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.101.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.101.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: card-mod-permissions
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.11.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.11.0
43
+ description: ''
44
+ email:
45
+ - info@decko.org
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - set/all/comment.rb
51
+ - set/right/comment.rb
52
+ - set/right/discussion.rb
53
+ homepage: http://decko.org
54
+ licenses:
55
+ - GPL-3.0
56
+ metadata:
57
+ card-mod: comment
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '2.5'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.0.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: card comments
77
+ test_files: []