Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -23,8 +23,6 @@ end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false
end
task :default => :test

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class PagesController < ApplicationController
before_action -> { require_plugin_enabled FoodsoftWiki }
before_action :catch_special_pages, only: [:show, :new]
@ -33,7 +32,7 @@ class PagesController < ApplicationController
redirect_to wiki_page_path(page.permalink) and return
end
end
if @page.nil?
redirect_to new_page_path(:title => params[:permalink])
elsif @page.redirect?
@ -61,7 +60,7 @@ class PagesController < ApplicationController
end
def create
@page = Page.new(params[:page].merge({:user => current_user}))
@page = Page.new(params[:page].merge({ :user => current_user }))
if params[:preview]
render :action => 'new'
@ -77,7 +76,7 @@ class PagesController < ApplicationController
def update
@page = Page.find(params[:id])
@page.attributes = params[:page].merge({:user => current_user})
@page.attributes = params[:page].merge({ :user => current_user })
if params[:preview]
@page.attributes = params[:page]
@ -92,7 +91,6 @@ class PagesController < ApplicationController
render :action => "edit"
end
end
rescue ActiveRecord::StaleObjectError
flash[:error] = I18n.t('pages.error_stale_object')
redirect_to wiki_page_path(@page.permalink)
@ -116,11 +114,11 @@ class PagesController < ApplicationController
end
if params[:sort]
sort = case params[:sort]
when "title" then "title"
when "title_reverse" then "title DESC"
when "last_updated" then "updated_at DESC"
when "last_updated_reverse" then "updated_at"
end
when "title" then "title"
when "title_reverse" then "title DESC"
when "last_updated" then "updated_at DESC"
when "last_updated_reverse" then "updated_at"
end
else
sort = "title"
end
@ -152,7 +150,7 @@ class PagesController < ApplicationController
def variables
keys = Foodsoft::ExpansionVariables.variables.keys
@variables = Hash[keys.map {|k| [k, Foodsoft::ExpansionVariables.get(k)]}]
@variables = Hash[keys.map { |k| [k, Foodsoft::ExpansionVariables.get(k)] }]
render 'variables'
end

View file

@ -6,7 +6,7 @@ module PagesHelper
end
def wikified_body(body, title = nil)
FoodsoftWiki::WikiParser.new(data: body+"\n", params: {referer: title}).to_html(noedit: true).html_safe
FoodsoftWiki::WikiParser.new(data: body + "\n", params: { referer: title }).to_html(noedit: true).html_safe
rescue => e
# try the following with line breaks: === one === == two == = three =
content_tag :span, class: 'alert alert-error' do
@ -22,13 +22,12 @@ module PagesHelper
end
end
def link_to_wikipage_by_permalink(permalink, text = nil)
unless permalink.blank?
page = Page.find_by_permalink(permalink)
if page.nil?
if text.nil?
link_to permalink, new_page_path(:title => permalink)
link_to permalink, new_page_path(:title => permalink)
else
link_to text, new_page_path(:title => permalink)
end
@ -65,9 +64,8 @@ module PagesHelper
end
# return url for all_pages rss feed
def all_pages_rss_url(options={})
def all_pages_rss_url(options = {})
token = TokenVerifier.new(['wiki', 'all']).generate
all_pages_url({:format => 'rss', :token => token}.merge(options))
all_pages_url({ :format => 'rss', :token => token }.merge(options))
end
end

View file

@ -76,10 +76,10 @@ class Page < ApplicationRecord
def create_redirect
unless old_title.blank?
Page.create :redirect => id,
:title => old_title,
:body => I18n.t('model.page.redirect', :title => title),
:permalink => Page.permalink(old_title),
:updated_by => updated_by
:title => old_title,
:body => I18n.t('model.page.redirect', :title => title),
:permalink => Page.permalink(old_title),
:updated_by => updated_by
end
end
end

View file

@ -1,7 +1,5 @@
Rails.application.routes.draw do
scope '/:foodcoop' do
resources :pages do
get :all, :on => :collection
get :version, :on => :member
@ -9,8 +7,6 @@ Rails.application.routes.draw do
get :diff, :on => :member
end
get '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/}
get '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki'
get '/wiki' => 'pages#show', :defaults => { :permalink => 'Home' }, :as => 'wiki'
end
end

View file

@ -2,13 +2,14 @@ module FoodsoftWiki
class Engine < ::Rails::Engine
def navigation(primary, ctx)
return unless FoodsoftWiki.enabled?
primary.item :wiki, I18n.t('navigation.wiki.title'), '#', id: nil do |subnav|
subnav.item :wiki_home, I18n.t('navigation.wiki.home'), ctx.wiki_path, id: nil
subnav.item :all_pages, I18n.t('navigation.wiki.all_pages'), ctx.all_pages_path, id: nil
end
# move this last added item to just after the foodcoop menu
if i = primary.items.index(primary[:foodcoop])
primary.items.insert(i+1, primary.items.delete_at(-1))
primary.items.insert(i + 1, primary.items.delete_at(-1))
end
end

View file

@ -1,20 +1,16 @@
module FoodsoftWiki
module Mailer
def self.included(base) # :nodoc:
base.class_eval do
# modify user presentation link to writing a message for the user
def additonal_welcome_text(user)
if FoodsoftWiki.enabled? && (page = Page.welcome_mail)
page.body
end
end
end
end
end
end
# modify existing helper

View file

@ -1,6 +1,5 @@
module FoodsoftWiki
class WikiParser < WikiCloth::Parser
template do |template|
Foodsoft::ExpansionVariables.get(template)
end
@ -31,12 +30,11 @@ module FoodsoftWiki
super(render_options)
end
private
def link_attributes_if_number_sign_contained_in_nonexistent(page, referer)
# Interpret the part after the last number sign as anchor.
arr = page.split('#', -1)# `-1` preserves empty anchor
arr = page.split('#', -1) # `-1` preserves empty anchor
page = arr[0...-1].join('#')
anchor = arr[-1]
@ -52,9 +50,8 @@ module FoodsoftWiki
end
end
def url_for(path_name, options={})
Rails.application.routes.url_helpers.send path_name, options.merge({foodcoop: FoodsoftConfig.scope})
def url_for(path_name, options = {})
Rails.application.routes.url_helpers.send path_name, options.merge({ foodcoop: FoodsoftConfig.scope })
end
end
end