From bd6eca21b18850f570b6c8402483e76383c93ef2 Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sat, 15 Oct 2022 17:03:18 +0100 Subject: [PATCH 1/7] Used string interpolation in notes_controller --- app/controllers/notes_controller.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 1e6e2170a5..7faaf02b38 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -140,7 +140,7 @@ def create return elsif params[:draft] == "true" token = SecureRandom.urlsafe_base64(16, false) - @node.slug = @node.slug + " token:" + token + @node.slug = "#{@node.slug} token:#{token}" @node.save! end @@ -153,7 +153,7 @@ def create if params[:event] == 'on' @node.add_tag('event', current_user) @node.add_tag('event:rsvp', current_user) - @node.add_tag('date:' + params[:date], current_user) if params[:date] + @node.add_tag("date:#{params[:date]}", current_user) if params[:date] end @node.add_tag('first-time-poster', current_user) if current_user.first_time_poster @@ -273,7 +273,7 @@ def update if request.xhr? render plain: "#{@node.path(format)}?_=#{Time.now.to_i}" else - redirect_to URI.parse(@node.path(format)).path + '?_=' + Time.now.to_i.to_s + redirect_to "#{URI.parse(@node.path(format)).path}?_=#{Time.now.to_i} end else flash[:error] = I18n.t('notes_controller.edit_not_saved') @@ -301,13 +301,13 @@ def delete render plain: I18n.t('notes_controller.content_deleted') else flash[:notice] = I18n.t('notes_controller.content_deleted') - redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s + redirect_to "/dashboard?_=#{Time.now.to_i}" end end end else flash[:error] = I18n.t('notes_controller.more_than_one_contributor') - redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s + redirect_to "/dashboard?_=#{Time.now.to_i}" end else prompt_login @@ -328,7 +328,7 @@ def author def author_topic @user = User.find_by(name: params[:author]) @tagnames = params[:topic].split('+') - @title = @user.name + " on '" + @tagnames.join(', ') + "'" + @title = "#{@user.name} on '#{@tagnames.join(', ')}'" @notes = @user.notes_for_tags(@tagnames) @unpaginated = true render template: 'notes/index' @@ -391,8 +391,8 @@ def rsvp # leave a comment @comment = @node.add_comment(subject: 'rsvp', uid: current_user.uid, body: 'I will be attending!') # make a tag - @node.add_tag('rsvp:' + current_user.username, current_user) - redirect_to URI.parse(@node.path).path + '#comments' + @node.add_tag("rsvp:#{current_user.username}", current_user) + redirect_to "#{URI.parse(node.path).path}#comments" end # Updates title of a wiki page, takes id and title as query string params. maps to '/node/update/title' @@ -400,15 +400,15 @@ def update_title node = Node.find params[:id].to_i unless current_user && current_user == node.author flash.keep[:error] = I18n.t('notes_controller.author_can_edit_note') - return redirect_to URI.parse(node.path).path + "#comments" + return redirect_to "#{URI.parse(node.path).path}#comments" end node.update(title: params[:title]) - redirect_to URI.parse(node.path).path + "#comments" + redirect_to "#{URI.parse(node.path).path}#comments" end def publish_draft @node = Node.find(params[:id]) - if current_user && current_user.uid == @node.uid || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}") + if (current_user && current_user.uid == @node.uid) || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}") @node.path = @node.generate_path @node.slug = @node.slug.split('token').first @node['created'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types @@ -470,11 +470,13 @@ def new_note end def new_preview_note - Node.new_preview_note(uid: current_user.uid, + Node.new_preview_note( ++ uid: current_user.uid, title: params[:title], body: params[:body], main_image: params[:main_image], - location: params[:location]) + location: params[:location] ++ ) end def not_draft_and_user_is_first_time_poster? From 2033204808eebfafa8926f4ebb0e4f45a75d9188 Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sat, 15 Oct 2022 21:54:21 +0100 Subject: [PATCH 2/7] Update notes_controller.rb --- app/controllers/notes_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 7faaf02b38..fe56bd50d4 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -273,7 +273,7 @@ def update if request.xhr? render plain: "#{@node.path(format)}?_=#{Time.now.to_i}" else - redirect_to "#{URI.parse(@node.path(format)).path}?_=#{Time.now.to_i} + redirect_to "#{URI.parse(@node.path(format)).path}?_=#{Time.now.to_i}" end else flash[:error] = I18n.t('notes_controller.edit_not_saved') @@ -471,7 +471,7 @@ def new_note def new_preview_note Node.new_preview_note( -+ uid: current_user.uid, ++ uid: current_user.uid, title: params[:title], body: params[:body], main_image: params[:main_image], From 9163540a3bab8782989539bbc93a2b878d0f1e1d Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sat, 15 Oct 2022 22:06:00 +0100 Subject: [PATCH 3/7] Update notes_controller.rb --- app/controllers/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index fe56bd50d4..82c6492306 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -476,7 +476,7 @@ def new_preview_note body: params[:body], main_image: params[:main_image], location: params[:location] -+ ) ++ ) end def not_draft_and_user_is_first_time_poster? From 250fc4b2f6e157ab1e248d10ee9329086e22eba4 Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sun, 16 Oct 2022 11:25:23 +0100 Subject: [PATCH 4/7] Update notes_controller.rb --- app/controllers/notes_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 82c6492306..47a1cf7097 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -471,12 +471,12 @@ def new_note def new_preview_note Node.new_preview_note( -+ uid: current_user.uid, - title: params[:title], - body: params[:body], - main_image: params[:main_image], - location: params[:location] -+ ) ++ uid: current_user.uid, + title: params[:title], + body: params[:body], + main_image: params[:main_image], + location: params[:location] ++ ) end def not_draft_and_user_is_first_time_poster? From a17cea82d690799272ed01234c36c6c3dc6560d2 Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sun, 16 Oct 2022 11:35:27 +0100 Subject: [PATCH 5/7] Update app/controllers/notes_controller.rb Co-authored-by: Tilda Udufo --- app/controllers/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 47a1cf7097..05f99b9ff1 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -476,7 +476,7 @@ def new_preview_note body: params[:body], main_image: params[:main_image], location: params[:location] -+ ) + ) end def not_draft_and_user_is_first_time_poster? From 7a529815c677c8dd38116868fedd2a5701ea0e60 Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sun, 16 Oct 2022 16:43:51 +0100 Subject: [PATCH 6/7] Update notes_controller.rb --- app/controllers/notes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 05f99b9ff1..89ce775bb5 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -471,7 +471,7 @@ def new_note def new_preview_note Node.new_preview_note( -+ uid: current_user.uid, + uid: current_user.uid, title: params[:title], body: params[:body], main_image: params[:main_image], From ec9da4bd34151c9f05f3f0d049b8da702463306d Mon Sep 17 00:00:00 2001 From: Idayat Sanni <103503556+IdayatSanni@users.noreply.github.com> Date: Sun, 16 Oct 2022 16:46:33 +0100 Subject: [PATCH 7/7] Update notes_controller.rb --- app/controllers/notes_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 89ce775bb5..092307f0a6 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -471,11 +471,11 @@ def new_note def new_preview_note Node.new_preview_note( - uid: current_user.uid, - title: params[:title], - body: params[:body], - main_image: params[:main_image], - location: params[:location] + uid: current_user.uid, + title: params[:title], + body: params[:body], + main_image: params[:main_image], + location: params[:location] ) end