Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bug/edit-comment-select-image-cr…
Browse files Browse the repository at this point in the history
…osswiring' into bug/edit-comment-select-image-crosswiring
  • Loading branch information
noi5e committed Jan 8, 2021
2 parents 364beba + 3ad1a7d commit 8e67269
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 73 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ gem "i18n-js", ">= 3.0.0.rc11"
gem 'impressionist'
gem 'jbuilder', '~> 2.10'
gem 'jquery-rails'
gem 'less-rails', '~> 5.0'
gem 'mocha', '~> 1.12'
gem 'mustermann' , '1.1.1'
gem 'omniauth', '~> 1.9'
Expand Down Expand Up @@ -97,7 +96,6 @@ gem 'coffee-rails', '~> 5.0.0'
gem 'execjs' # See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem "sassc", "~> 2.4.0"
gem 'sassc-rails'
gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
gem 'grape-rails-cache'

Expand Down
26 changes: 6 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
commonjs (0.2.7)
composite_primary_keys (11.2.0)
activerecord (~> 5.2.1)
concurrent-ruby (1.1.7)
Expand Down Expand Up @@ -146,7 +145,7 @@ GEM
thor (>= 0.14.0, < 2)
font-awesome-rails (4.7.0.6)
railties (>= 3.2, < 6.2)
friendly_id (5.4.1)
friendly_id (5.4.2)
activerecord (>= 4.0.0)
gemoji (3.0.1)
geocoder (1.6.4)
Expand Down Expand Up @@ -220,7 +219,7 @@ GEM
http_accept_language (2.1.1)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.8.5)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
i18n-js (3.8.0)
i18n (>= 0.6.6)
Expand Down Expand Up @@ -249,15 +248,8 @@ GEM
lazyload-rails (0.5.0)
nokogiri (~> 1.5)
lemmatizer (0.2.2)
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (5.0.0)
actionpack (>= 5.0)
less (~> 2.6.0)
sprockets (~> 3.0)
letter_opener (1.7.0)
launchy (~> 2.2)
libv8 (3.16.14.19)
listen (3.4.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -286,7 +278,7 @@ GEM
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.2)
minitest (5.14.3)
minitest-reporters (1.4.2)
ansi
builder
Expand All @@ -305,10 +297,10 @@ GEM
netrc (0.11.0)
nifty-generators (0.4.6)
nio4r (2.5.4)
nokogiri (1.11.0)
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
nokogumbo (2.0.2)
nokogumbo (2.0.4)
nokogiri (~> 1.8, >= 1.8.4)
oauth (0.5.4)
oauth2 (1.4.4)
Expand Down Expand Up @@ -422,7 +414,6 @@ GEM
recaptcha (4.14.0)
json
redis (4.1.4)
ref (2.0.0)
regexp_parser (1.8.2)
representable (3.0.4)
declarative (< 0.1.0)
Expand Down Expand Up @@ -470,7 +461,7 @@ GEM
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
rubyzip (2.0.0)
sanitize (5.2.1)
sanitize (5.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
nokogumbo (~> 2.0)
Expand Down Expand Up @@ -526,9 +517,6 @@ GEM
climate_control (>= 0.0.3, < 1.0)
test-unit (3.3.9)
power_assert
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.9)
Expand Down Expand Up @@ -621,7 +609,6 @@ DEPENDENCIES
json_expressions
lazyload-rails
lemmatizer (~> 0.2.2)
less-rails (~> 5.0)
letter_opener
listen (~> 3.4.0)
loadcss-rails (~> 2.0.1)
Expand Down Expand Up @@ -675,7 +662,6 @@ DEPENDENCIES
sqlite3 (~> 1.3.6)
teaspoon-mocha
test-unit
therubyracer
timecop
turbolinks (~> 5)
twitter
Expand Down
1 change: 0 additions & 1 deletion app/assets/less/lightbox.less

This file was deleted.

2 changes: 2 additions & 0 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def print
end

def edit
@revision = Revision.new
@node = if params[:lang]
Node.find_wiki(params[:lang] + '/' + params[:id])
else
Expand All @@ -133,6 +134,7 @@ def edit
end

def new
@revision = Revision.new
if current_user &.first_time_poster
flash[:notice] = "Please post a question or other content before editing the wiki. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
redirect_to '/'
Expand Down
30 changes: 14 additions & 16 deletions app/views/notes/_comment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,22 @@
</button>

<div id="emoji-dropdown" style="background:#f8f8f8;padding:0;" class=" dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<p id="emoji-title" style="text-align: center;color: #586069; font-size:14px;margin:6px;">Pick your reaction</p>
<div id= "dropdown-divider" style="display: block;height: 0;border-top: 1px solid #e1e4e8;"></div>

<div id="emoji-list" class="emoji-container">
<% emoji_names, emoji_image_map = emoji_info %>
<% emoji_names.each do |e| %>
<% capitalized_emoji_name = e.split("-").map(&:capitalize).join %>
<% str = "/comment/like?comment_id=#{comment.cid}&user_id=#{current_user.uid}&emoji_type=#{capitalized_emoji_name}" %>
<%= link_to str, data: { method: "post", remote: true }, style: "margin: 6px;" do %>
<img alt="React to post" class="emoji grow" height="20" width="20" src="<%= emoji_image_map[e] %>">
<% end %>
<% end %>
<p id="emoji-title" style="text-align: center;color: #586069; font-size:14px;margin:6px;">Pick your reaction</p>
<div id= "dropdown-divider" style="display: block;height: 0;border-top: 1px solid #e1e4e8;"></div>

<div id="emoji-list" class="emoji-container">
<% emoji_names, emoji_image_map = emoji_info %>
<% emoji_names.each do |e| %>
<% capitalized_emoji_name = e.split("-").map(&:capitalize).join %>
<% str = "/comment/like?comment_id=#{comment.cid}&user_id=#{current_user.uid}&emoji_type=#{capitalized_emoji_name}" %>
<%= link_to str, data: { method: "post", remote: true }, style: "margin: 6px;" do %>
<img alt="React to post" class="emoji grow" height="20" width="20" src="<%= emoji_image_map[e] %>">
<% end %>
<% end %>
</div>
</div>

<% end %>
</div>
<% end %>
</div>

</div>

<script>
Expand Down
5 changes: 2 additions & 3 deletions app/views/wiki/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
%>

<%= form_for :node, :as => :node, :url => url do |f| %>
<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages %></div><% end %>
<%= render partial: 'layouts/errorMessages', locals: { model: @node } %>
<% end %>
<div class="card bg-light">
<div class="card-body">
<%= form_for :revision, :as => :revision, :url => url, :html => {:class => "form well wiki-form row"} do |f| %>

<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages %></div><% end %>

<%= render partial: 'layouts/errorMessages', locals: { model: @revision } %>
<%= render :partial => "editor/main_image" %>

<div class="col-lg-9 order-lg-1">
Expand Down
2 changes: 0 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.paths << Rails.root.join("public","lib")
config.less.paths << Rails.root.join("assets","less")
config.less.compress = true

# Add environments to skylight
config.skylight.environments += ["staging_unstable", "staging"]
Expand Down
69 changes: 66 additions & 3 deletions test/fixtures/comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,79 @@ comment_by_first_time_user:
timestamp: <%= Time.now.to_i + 10 %>
thread: /01

reply_to_this_comment:
reply_to_this_comment: # comment on question, for comment system tests
uid: 1
nid: 37
status: 1
comment: Uhh...
timestamp: <%= Time.now.to_i + 10 %>

note_comment_for_responses:
note_comment_for_responses: # comment on note, for comment system tests
uid: 1
nid: 38
status: 1
comment: I do what I want!
timestamp: <%= Time.now.to_i + 10 %>
timestamp: <%= Time.now.to_i + 10 %>

ketchup_comment: # question fixture for testing multiple comments
uid: 1
nid: 40
status: 1
comment: I like ketchup
timestamp: <%= Time.now.to_i + 10 %>

mustard_comment:
uid: 5
nid: 40
status: 1
comment: I like mustard
timestamp: <%= Time.now.to_i + 20 %>

mayo_comment:
uid: 6
nid: 40
status: 1
comment: I like mayo
timestamp: <%= Time.now.to_i + 30 %>

ouija_comment_1: # note fixture for testing multiple comments
uid: 1
nid: 41
status: 1
comment: P
timestamp: <%= Time.now.to_i + 10 %>

ouija_comment_2:
uid: 5
nid: 41
status: 1
comment: O
timestamp: <%= Time.now.to_i + 20 %>

ouija_comment_3:
uid: 6
nid: 41
status: 1
comment: O
timestamp: <%= Time.now.to_i + 30 %>

wiki_comment_1: # wiki fixture for testing multiple comments
uid: 1
nid: 42
status: 1
comment: Squirtle
timestamp: <%= Time.now.to_i + 10 %>

wiki_comment_2:
uid: 5
nid: 42
status: 1
comment: Charmander
timestamp: <%= Time.now.to_i + 20 %>

wiki_comment_3:
uid: 6
nid: 42
status: 1
comment: Bulbasaur
timestamp: <%= Time.now.to_i + 30 %>
5 changes: 5 additions & 0 deletions test/fixtures/node_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,8 @@ hidden_response_node_tag:
uid: 2
nid: 39
date: <%= DateTime.now.to_i %>

question_with_multiple_comments: # another question for testing comments
tid: 35
uid: 2
nid: 40
36 changes: 36 additions & 0 deletions test/fixtures/nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,39 @@ hidden_response_note:
type: "note"
cached_likes: 0
slug: "note-tagged-with-hidden-response"

question_with_multiple_comments: # for testing multiple comment forms
nid: 40
uid: 2
title: "Which condiments do you like"
path: "/notes/jeff/12-20-2020/which-condiments-do-you-like"
created: <%= DateTime.new(2020,12,20).to_i %>
changed: <%= DateTime.new(2020,12,20).to_i %>
status: 1
type: "note"
cached_likes: 0
slug: "jeff-12-20-2020-which-condiments-do-you-like"

note_with_multiple_comments:
nid: 41
uid: 2
title: "Ouija Board"
path: "/notes/jeff/12-20-2020/ouija-board"
created: <%= DateTime.new(2020,12,20).to_i %>
changed: <%= DateTime.new(2020,12,20).to_i %>
status: 1
type: "note"
cached_likes: 0
slug: "jeff-12-20-2020-ouija-board"

wiki_with_multiple_comments:
nid: 42
uid: 2
title: "List of pokemon"
path: "/wiki/list-of-pokemon"
created: <%= DateTime.new(2020,12,21).to_i %>
changed: <%= DateTime.new(2020,12,21).to_i %>
status: 1
type: "page"
cached_likes: 0
slug: "wiki-list-of-pokemon"
26 changes: 25 additions & 1 deletion test/fixtures/revisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,34 @@ comment_note: # for testing comments on notes
timestamp: <%= DateTime.new(2020,12,8).to_i %>
status: 1

hidden_response_note_revision: # for testing comments on notes
hidden_response_note_revision:
nid: 39
uid: 2
title: "Note tagged with hidden:response"
body: "This is a hidden note"
timestamp: <%= DateTime.new(2020,12,8).to_i %>
status: 1

question_with_multiple_comments:
nid: 40
uid: 2
title: "Which condiments do you like"
body: "I want to know"
timestamp: <%= DateTime.new(2020,12,20).to_i %>
status: 1

note_with_multiple_comments:
nid: 41
uid: 2
title: "Ouija Board"
body: "Don't be scurred"
timestamp: <%= DateTime.new(2020,12,20).to_i %>
status: 1

wiki_with_multiple_comments:
nid: 42
uid: 2
title: "List of pokemon"
body: "Gotta catch em all"
timestamp: <%= DateTime.new(2020,12,21).to_i %>
status: 1
2 changes: 1 addition & 1 deletion test/functional/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def setup
@wikis.each do |obj|
if obj.class == Revision && obj.status == 1
selections = css_select '.wiki'
assert_equal 9, selections.length
assert_equal 10, selections.length
elsif obj.class == Revision && obj.status != 1
selections = css_select '.wiki'
assert_equal 0, selections.length
Expand Down
Loading

0 comments on commit 8e67269

Please sign in to comment.