From fde7904c1a5a4173ee1c33cfd466ac16379c9a05 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 29 Oct 2013 21:47:36 +0100 Subject: [PATCH 01/14] allow plugins to modify the navigation menu --- config/navigation.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/navigation.rb b/config/navigation.rb index 74b76bbe..7522f463 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -3,6 +3,11 @@ SimpleNavigation::Configuration.run do |navigation| + # allow engines to add to the menu - https://gist.github.com/mjtko/4873ee0c112b6bd646f8 + engines = Rails.application.railties.engines.select { |e| e.respond_to?(:navigation) } + # to include an engine but keep it from modifying the menu: + #engines.reject! { |e| e.instance_of? FoodsoftMyplugin::Engine } + navigation.items do |primary| primary.dom_class = 'nav' @@ -47,6 +52,8 @@ SimpleNavigation::Configuration.run do |navigation| subnav.item :ordergroups, I18n.t('navigation.admin.ordergroups'), admin_ordergroups_path, id: nil subnav.item :workgroups, I18n.t('navigation.admin.workgroups'), admin_workgroups_path, id: nil end + + engines.each { |e| e.navigation(primary, self) } end end From 6d0ba985aa5cfbc909aa46ecfe0ff746b4d20271 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 29 Oct 2013 22:22:24 +0100 Subject: [PATCH 02/14] first version of the foodsoft_wiki plugin --- lib/foodsoft_wiki/README.rdoc | 3 ++ lib/foodsoft_wiki/Rakefile | 40 +++++++++++++++++++ lib/foodsoft_wiki/foodsoft_wiki.gemspec | 22 ++++++++++ lib/foodsoft_wiki/lib/foodsoft_wiki.rb | 4 ++ lib/foodsoft_wiki/lib/foodsoft_wiki/engine.rb | 14 +++++++ .../lib/foodsoft_wiki/version.rb | 3 ++ 6 files changed, 86 insertions(+) create mode 100644 lib/foodsoft_wiki/README.rdoc create mode 100644 lib/foodsoft_wiki/Rakefile create mode 100644 lib/foodsoft_wiki/foodsoft_wiki.gemspec create mode 100644 lib/foodsoft_wiki/lib/foodsoft_wiki.rb create mode 100644 lib/foodsoft_wiki/lib/foodsoft_wiki/engine.rb create mode 100644 lib/foodsoft_wiki/lib/foodsoft_wiki/version.rb diff --git a/lib/foodsoft_wiki/README.rdoc b/lib/foodsoft_wiki/README.rdoc new file mode 100644 index 00000000..db552fde --- /dev/null +++ b/lib/foodsoft_wiki/README.rdoc @@ -0,0 +1,3 @@ += FoodsoftWiki + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/lib/foodsoft_wiki/Rakefile b/lib/foodsoft_wiki/Rakefile new file mode 100644 index 00000000..a3d12088 --- /dev/null +++ b/lib/foodsoft_wiki/Rakefile @@ -0,0 +1,40 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'FoodsoftWiki' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/lib/foodsoft_wiki/foodsoft_wiki.gemspec b/lib/foodsoft_wiki/foodsoft_wiki.gemspec new file mode 100644 index 00000000..df5c0416 --- /dev/null +++ b/lib/foodsoft_wiki/foodsoft_wiki.gemspec @@ -0,0 +1,22 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "foodsoft_wiki/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "foodsoft_wiki" + s.version = FoodsoftWiki::VERSION + s.authors = ["wvengen"] + s.email = ["dev-foodsoft@willem.engen.nl"] + s.homepage = "https://github.com/foodcoops/foodsoft" + s.summary = "Wiki plugin for foodsoft." + s.description = "Adds a wiki to foodsoft." + + s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + s.add_dependency "rails", "~> 3.2.15" + + s.add_development_dependency "sqlite3" +end diff --git a/lib/foodsoft_wiki/lib/foodsoft_wiki.rb b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb new file mode 100644 index 00000000..614a2a32 --- /dev/null +++ b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb @@ -0,0 +1,4 @@ +require "foodsoft_wiki/engine" + +module FoodsoftWiki +end diff --git a/lib/foodsoft_wiki/lib/foodsoft_wiki/engine.rb b/lib/foodsoft_wiki/lib/foodsoft_wiki/engine.rb new file mode 100644 index 00000000..68f0ab7f --- /dev/null +++ b/lib/foodsoft_wiki/lib/foodsoft_wiki/engine.rb @@ -0,0 +1,14 @@ +module FoodsoftWiki + class Engine < ::Rails::Engine + def navigation(primary, ctx) + 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)) + end + end + end +end diff --git a/lib/foodsoft_wiki/lib/foodsoft_wiki/version.rb b/lib/foodsoft_wiki/lib/foodsoft_wiki/version.rb new file mode 100644 index 00000000..2a67a94e --- /dev/null +++ b/lib/foodsoft_wiki/lib/foodsoft_wiki/version.rb @@ -0,0 +1,3 @@ +module FoodsoftWiki + VERSION = "0.0.1" +end From d4dccbc64643975a2f107608c9820cdb5aedbf41 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 29 Oct 2013 22:23:17 +0100 Subject: [PATCH 03/14] add foodsoft_wiki plugin to Gemfile by default --- Gemfile | 2 ++ Gemfile.lock | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index 0c1868e4..946bf0d4 100644 --- a/Gemfile +++ b/Gemfile @@ -43,6 +43,8 @@ gem "rails-settings-cached", "0.2.4" gem 'resque' gem 'whenever', require: false # For defining cronjobs, see config/schedule.rb +gem 'foodsoft_wiki', path: 'lib/foodsoft_wiki' + group :production do gem 'exception_notification' end diff --git a/Gemfile.lock b/Gemfile.lock index b5e4f6d5..b719c030 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,6 +18,12 @@ GIT acts_as_versioned (0.6.0) activerecord (>= 3.0.9) +PATH + remote: lib/foodsoft_wiki + specs: + foodsoft_wiki (0.0.1) + rails (~> 3.2.15) + GEM remote: https://rubygems.org/ specs: @@ -345,6 +351,7 @@ DEPENDENCIES exception_notification factory_girl_rails (~> 4.0) faker + foodsoft_wiki! haml-rails i18n-js! i18n-spec From 70c12b7c1fd09cff5a168b99295a8d64c0778624 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 29 Oct 2013 22:42:06 +0100 Subject: [PATCH 04/14] move wiki functionality to plugin --- Gemfile | 3 ++- Gemfile.lock | 1 + config/navigation.rb | 5 ----- config/routes.rb | 10 ---------- .../foodsoft_wiki/app}/controllers/pages_controller.rb | 0 {app => lib/foodsoft_wiki/app}/helpers/pages_helper.rb | 0 {app => lib/foodsoft_wiki/app}/models/page.rb | 0 .../foodsoft_wiki/app}/views/pages/_body.html.haml | 0 .../foodsoft_wiki/app}/views/pages/_form.html.haml | 0 .../app}/views/pages/_page_list_item.html.haml | 0 .../app}/views/pages/_recent_changes.html.haml | 0 .../foodsoft_wiki/app}/views/pages/_site_map.html.haml | 0 .../app}/views/pages/_title_list.html.haml | 0 .../foodsoft_wiki/app}/views/pages/all.html.haml | 0 .../foodsoft_wiki/app}/views/pages/edit.html.haml | 0 .../foodsoft_wiki/app}/views/pages/new.html.haml | 0 .../foodsoft_wiki/app}/views/pages/show.html.haml | 0 .../foodsoft_wiki/app}/views/pages/version.html.haml | 0 lib/foodsoft_wiki/foodsoft_wiki.gemspec | 1 + 19 files changed, 4 insertions(+), 16 deletions(-) rename {app => lib/foodsoft_wiki/app}/controllers/pages_controller.rb (100%) rename {app => lib/foodsoft_wiki/app}/helpers/pages_helper.rb (100%) rename {app => lib/foodsoft_wiki/app}/models/page.rb (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_body.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_form.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_page_list_item.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_recent_changes.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_site_map.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/_title_list.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/all.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/edit.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/new.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/show.html.haml (100%) rename {app => lib/foodsoft_wiki/app}/views/pages/version.html.haml (100%) diff --git a/Gemfile b/Gemfile index 946bf0d4..27d7cba5 100644 --- a/Gemfile +++ b/Gemfile @@ -37,12 +37,13 @@ gem 'twitter-bootstrap-rails' gem 'simple-navigation' gem 'simple-navigation-bootstrap' gem 'meta_search' -gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.git' # Use this instead of rubygem gem 'acts_as_tree' gem "rails-settings-cached", "0.2.4" gem 'resque' gem 'whenever', require: false # For defining cronjobs, see config/schedule.rb +# we use the git version of acts_as_versioned, and need to include it in this Gemfile +gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.git' gem 'foodsoft_wiki', path: 'lib/foodsoft_wiki' group :production do diff --git a/Gemfile.lock b/Gemfile.lock index b719c030..9933c081 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,6 +22,7 @@ PATH remote: lib/foodsoft_wiki specs: foodsoft_wiki (0.0.1) + acts_as_versioned rails (~> 3.2.15) GEM diff --git a/config/navigation.rb b/config/navigation.rb index 7522f463..49a3293d 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -21,11 +21,6 @@ SimpleNavigation::Configuration.run do |navigation| subnav.item :tasks, I18n.t('navigation.tasks'), tasks_path, id: nil end - primary.item :wiki, I18n.t('navigation.wiki.title'), '#', id: nil do |subnav| - subnav.item :wiki_home, I18n.t('navigation.wiki.home'), wiki_path, id: nil - subnav.item :all_pages, I18n.t('navigation.wiki.all_pages'), all_pages_path, id: nil - end - primary.item :orders, I18n.t('navigation.orders.title'), '#', id: nil do |subnav| subnav.item :ordering, I18n.t('navigation.orders.ordering'), group_orders_path, id: nil subnav.item :ordering_archive, I18n.t('navigation.orders.archive'), archive_group_orders_path, id: nil diff --git a/config/routes.rb b/config/routes.rb index 533d2d97..e3565686 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,16 +29,6 @@ Foodsoft::Application.routes.draw do match '/home/ordergroup' => 'home#ordergroup', :as => 'my_ordergroup' match '/home/cancel_membership' => 'home#cancel_membership', :as => 'cancel_membership' - ############ Wiki - - resources :pages do - get :all, :on => :collection - get :version, :on => :member - get :revert, :on => :member - end - match '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/} - match '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki' - ############ Orders, ordering resources :orders do diff --git a/app/controllers/pages_controller.rb b/lib/foodsoft_wiki/app/controllers/pages_controller.rb similarity index 100% rename from app/controllers/pages_controller.rb rename to lib/foodsoft_wiki/app/controllers/pages_controller.rb diff --git a/app/helpers/pages_helper.rb b/lib/foodsoft_wiki/app/helpers/pages_helper.rb similarity index 100% rename from app/helpers/pages_helper.rb rename to lib/foodsoft_wiki/app/helpers/pages_helper.rb diff --git a/app/models/page.rb b/lib/foodsoft_wiki/app/models/page.rb similarity index 100% rename from app/models/page.rb rename to lib/foodsoft_wiki/app/models/page.rb diff --git a/app/views/pages/_body.html.haml b/lib/foodsoft_wiki/app/views/pages/_body.html.haml similarity index 100% rename from app/views/pages/_body.html.haml rename to lib/foodsoft_wiki/app/views/pages/_body.html.haml diff --git a/app/views/pages/_form.html.haml b/lib/foodsoft_wiki/app/views/pages/_form.html.haml similarity index 100% rename from app/views/pages/_form.html.haml rename to lib/foodsoft_wiki/app/views/pages/_form.html.haml diff --git a/app/views/pages/_page_list_item.html.haml b/lib/foodsoft_wiki/app/views/pages/_page_list_item.html.haml similarity index 100% rename from app/views/pages/_page_list_item.html.haml rename to lib/foodsoft_wiki/app/views/pages/_page_list_item.html.haml diff --git a/app/views/pages/_recent_changes.html.haml b/lib/foodsoft_wiki/app/views/pages/_recent_changes.html.haml similarity index 100% rename from app/views/pages/_recent_changes.html.haml rename to lib/foodsoft_wiki/app/views/pages/_recent_changes.html.haml diff --git a/app/views/pages/_site_map.html.haml b/lib/foodsoft_wiki/app/views/pages/_site_map.html.haml similarity index 100% rename from app/views/pages/_site_map.html.haml rename to lib/foodsoft_wiki/app/views/pages/_site_map.html.haml diff --git a/app/views/pages/_title_list.html.haml b/lib/foodsoft_wiki/app/views/pages/_title_list.html.haml similarity index 100% rename from app/views/pages/_title_list.html.haml rename to lib/foodsoft_wiki/app/views/pages/_title_list.html.haml diff --git a/app/views/pages/all.html.haml b/lib/foodsoft_wiki/app/views/pages/all.html.haml similarity index 100% rename from app/views/pages/all.html.haml rename to lib/foodsoft_wiki/app/views/pages/all.html.haml diff --git a/app/views/pages/edit.html.haml b/lib/foodsoft_wiki/app/views/pages/edit.html.haml similarity index 100% rename from app/views/pages/edit.html.haml rename to lib/foodsoft_wiki/app/views/pages/edit.html.haml diff --git a/app/views/pages/new.html.haml b/lib/foodsoft_wiki/app/views/pages/new.html.haml similarity index 100% rename from app/views/pages/new.html.haml rename to lib/foodsoft_wiki/app/views/pages/new.html.haml diff --git a/app/views/pages/show.html.haml b/lib/foodsoft_wiki/app/views/pages/show.html.haml similarity index 100% rename from app/views/pages/show.html.haml rename to lib/foodsoft_wiki/app/views/pages/show.html.haml diff --git a/app/views/pages/version.html.haml b/lib/foodsoft_wiki/app/views/pages/version.html.haml similarity index 100% rename from app/views/pages/version.html.haml rename to lib/foodsoft_wiki/app/views/pages/version.html.haml diff --git a/lib/foodsoft_wiki/foodsoft_wiki.gemspec b/lib/foodsoft_wiki/foodsoft_wiki.gemspec index df5c0416..e4712387 100644 --- a/lib/foodsoft_wiki/foodsoft_wiki.gemspec +++ b/lib/foodsoft_wiki/foodsoft_wiki.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 3.2.15" + s.add_dependency 'acts_as_versioned' # need git version, make sure that is included in foodsoft's Gemfile s.add_development_dependency "sqlite3" end From de948d7692c06fcce1e7a5da178262a05ea90b72 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 30 Oct 2013 01:56:23 +0100 Subject: [PATCH 05/14] fix and cleanup routing (closes foodcoops#190) --- app/controllers/orders_controller.rb | 15 +++++++++------ app/views/articles/_destroy_active_article.haml | 2 +- app/views/home/_start_nav.haml | 2 +- app/views/home/profile.html.haml | 2 +- app/views/login/forgot_password.html.haml | 2 +- app/views/login/new_password.html.haml | 2 +- app/views/orders/show.html.haml | 2 +- app/views/tasks/_archive_tasks.html.haml | 2 +- config/routes.rb | 10 +++++----- 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index d52ae698..578327f1 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -48,6 +48,9 @@ class OrdersController < ApplicationController end send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf' end + format.text do + send_data text_fax_template, filename: @order.name+'.txt', type: 'text/plain' + end end end @@ -101,12 +104,14 @@ class OrdersController < ApplicationController rescue => error redirect_to orders_url, alert: I18n.t('errors.general_msg', :msg => error.message) end + + protected # Renders the fax-text-file # e.g. for easier use with online-fax-software, which don't accept pdf-files + # TODO move to text template def text_fax_template - order = Order.find(params[:id]) - supplier = order.supplier + supplier = @order.supplier contact = FoodsoftConfig[:contact].symbolize_keys text = I18n.t('orders.fax.heading', :name => FoodsoftConfig[:name]) text += "\n#{Supplier.human_attribute_name(:customer_number)}: #{supplier.customer_number}" unless supplier.customer_number.blank? @@ -117,15 +122,13 @@ class OrdersController < ApplicationController text += "****** " + I18n.t('orders.fax.articles') + "\n\n" text += I18n.t('orders.fax.number') + " " + I18n.t('orders.fax.amount') + " " + I18n.t('orders.fax.name') + "\n" # now display all ordered articles - order.order_articles.ordered.all(:include => [:article, :article_price]).each do |oa| + @order.order_articles.ordered.all(:include => [:article, :article_price]).each do |oa| number = oa.article.order_number (8 - number.size).times { number += " " } quantity = oa.units_to_order.to_i.to_s quantity = " " + quantity if quantity.size < 2 text += "#{number} #{quantity} #{oa.article.name}\n" end - send_data text, - :type => 'text/plain; charset=utf-8; header=present', - :disposition => "attachment; filename=#{order.name}" + text end end diff --git a/app/views/articles/_destroy_active_article.haml b/app/views/articles/_destroy_active_article.haml index 73c59e1c..90dcfae2 100644 --- a/app/views/articles/_destroy_active_article.haml +++ b/app/views/articles/_destroy_active_article.haml @@ -1,3 +1,3 @@ %tr.edit_inline{:id=> "edit_"+@article.id.to_s} %td{:colspan=>"10"} - = t('.note', article: h(@article.name), drop_link: link_to(t('.drop'), :controller => 'orders', :action => 'edit', :id => @order)).html_safe + = t('.note', article: h(@article.name), drop_link: link_to(t('.drop'), edit_order_path(@order))).html_safe diff --git a/app/views/home/_start_nav.haml b/app/views/home/_start_nav.haml index 4f7f1b5c..346aa67a 100644 --- a/app/views/home/_start_nav.haml +++ b/app/views/home/_start_nav.haml @@ -4,7 +4,7 @@ %li.nav-header= t '.foodcoop' %li= link_to t('.members'), foodcoop_users_path %li= link_to t('.tasks'), user_tasks_path - %li= link_to t('.write_message'), :controller => "messages", :action => "new" + %li= link_to t('.write_message'), new_message_path - has_ordergroup = !@current_user.ordergroup.nil? - has_orders_role = @current_user.role_orders? diff --git a/app/views/home/profile.html.haml b/app/views/home/profile.html.haml index d462995a..6a54fce6 100644 --- a/app/views/home/profile.html.haml +++ b/app/views/home/profile.html.haml @@ -5,7 +5,7 @@ %h3 = h(t('.user.title', user: @current_user.nick)) %small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on) - = simple_form_for(@current_user, :url => { :action => 'update_profile'}) do |f| + = simple_form_for(@current_user, :url => update_profile_path) do |f| = render :partial => 'shared/user_form_fields', :locals => {:f => f} .form-actions = submit_tag t('ui.save'), class: 'btn' diff --git a/app/views/login/forgot_password.html.haml b/app/views/login/forgot_password.html.haml index 568ac258..c299f0ae 100644 --- a/app/views/login/forgot_password.html.haml +++ b/app/views/login/forgot_password.html.haml @@ -1,6 +1,6 @@ - title t('.title') = t('.body').html_safe -= simple_form_for User.new, url: {action: 'reset_password'} do |form| += simple_form_for User.new, url: reset_password_path do |form| = form.input :email .form-actions = form.submit t('.submit'), class: 'btn' diff --git a/app/views/login/new_password.html.haml b/app/views/login/new_password.html.haml index d3f2c58c..ea928051 100644 --- a/app/views/login/new_password.html.haml +++ b/app/views/login/new_password.html.haml @@ -1,6 +1,6 @@ - title t('.title') = t('.body', user: h(@user.nick)).html_safe -= simple_form_for @user, :url => {:action => 'update_password', :id => @user.id, :token => @user.reset_password_token} do |form| += simple_form_for @user, :url => update_password_path(@user.id, :token => @user.reset_password_token) do |form| = form.input :password = form.input :password_confirmation .form-actions diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml index 0e9a3926..82d43cc2 100644 --- a/app/views/orders/show.html.haml +++ b/app/views/orders/show.html.haml @@ -50,7 +50,7 @@ %li= order_pdf(@order, :articles, t('.download.article_pdf')) %li= order_pdf(@order, :matrix, t('.download.matrix_pdf')) %li= order_pdf(@order, :fax, t('.download.fax_pdf')) - %li= link_to t('.download.fax_txt'), {action: 'text_fax_template', id: @order }, {title: t('.download.download_file')} + %li= link_to t('.download.fax_txt'), order_path(@order, format: :txt), {title: t('.download.download_file')} %section#articles_table = render 'articles', order: @order diff --git a/app/views/tasks/_archive_tasks.html.haml b/app/views/tasks/_archive_tasks.html.haml index 46250ddd..9ece4d05 100644 --- a/app/views/tasks/_archive_tasks.html.haml +++ b/app/views/tasks/_archive_tasks.html.haml @@ -13,5 +13,5 @@ - @tasks.each do |task| %tr %td= task.due_date unless task.due_date.nil? - %td= link_to t('.task_format', name: task.name, duration: task.duration), :controller => "tasks", :action => "show", :id => task + %td= link_to t('.task_format', name: task.name, duration: task.duration), task_path(task) %td= task_assignments task diff --git a/config/routes.rb b/config/routes.rb index e3565686..655a1038 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,14 +18,17 @@ Foodsoft::Application.routes.draw do match '/login' => 'sessions#new', :as => 'login' match '/logout' => 'sessions#destroy', :as => 'logout' - get '/login/forgot_password' => 'login#forgot_password', as: :forgot_password - get '/login/new_password' => 'login#new_password', as: :new_password + get '/login/forgot_password' => 'login#forgot_password', as: :forgot_password + post '/login/reset_password' => 'login#reset_password', as: :reset_password + get '/login/new_password' => 'login#new_password', as: :new_password + get '/login/update_password' => 'login#update_password', as: :update_password match '/login/accept_invitation/:token' => 'login#accept_invitation', as: :accept_invitation resources :sessions, :only => [:new, :create, :destroy] ########### User specific match '/home/profile' => 'home#profile', :as => 'my_profile' + put '/home/update_profile' => 'home#update_profile', :as => 'update_profile' match '/home/ordergroup' => 'home#ordergroup', :as => 'my_ordergroup' match '/home/cancel_membership' => 'home#cancel_membership', :as => 'cancel_membership' @@ -181,8 +184,5 @@ Foodsoft::Application.routes.draw do resources :users, :only => [:index] - # TODO: This is very error prone. Better deactivate this catch all route - match ':controller(/:action(/:id))(.:format)' - end # End of /:foodcoop scope end From c3068c8d51be5de1a6ed1acc172795dbf4229abf Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 30 Oct 2013 09:43:38 +0100 Subject: [PATCH 06/14] move foodsoft_wiki db migration to plugin --- config/application.rb | 3 +++ .../foodsoft_wiki/db}/migrate/20090325175756_create_pages.rb | 0 2 files changed, 3 insertions(+) rename {db => lib/foodsoft_wiki/db}/migrate/20090325175756_create_pages.rb (100%) diff --git a/config/application.rb b/config/application.rb index 2d8cf3ef..4f0f199b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -63,5 +63,8 @@ module Foodsoft # It would be nice not to enable database connection when precompiling assets, # but i18n-js requires initialization, that's why it's on. config.assets.initialize_on_precompile = true + + # Include engine migrations. - http://stackoverflow.com/a/8364459/2866660 + config.paths['db/migrate'] += Rails.application.railties.engines.map{|e| e.paths['db/migrate'].existent}.flatten end end diff --git a/db/migrate/20090325175756_create_pages.rb b/lib/foodsoft_wiki/db/migrate/20090325175756_create_pages.rb similarity index 100% rename from db/migrate/20090325175756_create_pages.rb rename to lib/foodsoft_wiki/db/migrate/20090325175756_create_pages.rb From ea71d691e963350dadd37e9cd5a1dd89932438d8 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 30 Oct 2013 09:50:06 +0100 Subject: [PATCH 07/14] update foodsoft_wiki README --- lib/foodsoft_wiki/README.rdoc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/foodsoft_wiki/README.rdoc b/lib/foodsoft_wiki/README.rdoc index db552fde..852d77a1 100644 --- a/lib/foodsoft_wiki/README.rdoc +++ b/lib/foodsoft_wiki/README.rdoc @@ -1,3 +1,17 @@ = FoodsoftWiki -This project rocks and uses MIT-LICENSE. \ No newline at end of file +This plugin adds wiki pages to foodsoft. A new 'Wiki' menu is added next to +the 'Foodcoops' menu in the navigation bar. + +This plugin is enabled by default in foodsoft, so you don't need to do anything +to install it. If you still want to, for example when it has been disabled, +add the following to foodsoft's Gemfile: + +```Gemfile +# we use the git version of acts_as_versioned, so this needs to be in foodsoft's Gemfile +gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.git' +gem 'foodsoft_wiki', path: 'lib/foodsoft_wiki' +``` + +This plugin is part of the foodsoft package and uses the GPL-3 license (see +foodsoft's LICENSE for the full license text). From f507efcdb3dfe5e314842888edc6c4ad00078138 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 30 Oct 2013 09:51:11 +0100 Subject: [PATCH 08/14] update foodsoft_wiki README [ci skip] --- lib/foodsoft_wiki/{README.rdoc => README.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename lib/foodsoft_wiki/{README.rdoc => README.md} (96%) diff --git a/lib/foodsoft_wiki/README.rdoc b/lib/foodsoft_wiki/README.md similarity index 96% rename from lib/foodsoft_wiki/README.rdoc rename to lib/foodsoft_wiki/README.md index 852d77a1..dcf2f18c 100644 --- a/lib/foodsoft_wiki/README.rdoc +++ b/lib/foodsoft_wiki/README.md @@ -1,4 +1,5 @@ -= FoodsoftWiki +FoodsoftWiki +============ This plugin adds wiki pages to foodsoft. A new 'Wiki' menu is added next to the 'Foodcoops' menu in the navigation bar. From 6e9954c86fdaf3500bcaafbd03f9087899812b68 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 30 Oct 2013 11:04:22 +0100 Subject: [PATCH 09/14] remove user referencing page as it is not being used anyway --- app/models/user.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2b4a399b..c46d950c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,7 +17,6 @@ class User < ActiveRecord::Base has_many :assignments, :dependent => :destroy has_many :tasks, :through => :assignments has_many :send_messages, :class_name => "Message", :foreign_key => "sender_id" - has_many :pages, :foreign_key => 'updated_by' has_many :created_orders, :class_name => 'Order', :foreign_key => 'created_by_user_id', :dependent => :nullify attr_accessor :password, :settings_attributes From fa0102fed57a818e27e1cb009e4feef2d958b071 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 1 Nov 2013 20:32:30 +0100 Subject: [PATCH 10/14] fix gemspec after file rename --- lib/foodsoft_wiki/foodsoft_wiki.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/foodsoft_wiki/foodsoft_wiki.gemspec b/lib/foodsoft_wiki/foodsoft_wiki.gemspec index e4712387..f8d436d9 100644 --- a/lib/foodsoft_wiki/foodsoft_wiki.gemspec +++ b/lib/foodsoft_wiki/foodsoft_wiki.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.summary = "Wiki plugin for foodsoft." s.description = "Adds a wiki to foodsoft." - s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.rdoc"] + s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"] s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 3.2.15" From 841cdad0100ebd381dc1dc04d0c6c49d57615c73 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sat, 2 Nov 2013 10:57:37 +0100 Subject: [PATCH 11/14] add missing routes to wiki plugin --- lib/foodsoft_wiki/config/routes.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/foodsoft_wiki/config/routes.rb diff --git a/lib/foodsoft_wiki/config/routes.rb b/lib/foodsoft_wiki/config/routes.rb new file mode 100644 index 00000000..29a5ebef --- /dev/null +++ b/lib/foodsoft_wiki/config/routes.rb @@ -0,0 +1,15 @@ +Rails.application.routes.draw do + + scope '/:foodcoop' do + + resources :pages do + get :all, :on => :collection + get :version, :on => :member + get :revert, :on => :member + end + match '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/} + match '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki' + + end + +end From a27dda62e008dc32f823a26bb0d4c193f6200ebc Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 6 Nov 2013 10:54:20 +0100 Subject: [PATCH 12/14] copy migrations to default directory instead of trying to make it more easy to use --- config/application.rb | 3 --- ...95325_create_pages.foodsoft_wiki_engine.rb | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb diff --git a/config/application.rb b/config/application.rb index 4f0f199b..2d8cf3ef 100644 --- a/config/application.rb +++ b/config/application.rb @@ -63,8 +63,5 @@ module Foodsoft # It would be nice not to enable database connection when precompiling assets, # but i18n-js requires initialization, that's why it's on. config.assets.initialize_on_precompile = true - - # Include engine migrations. - http://stackoverflow.com/a/8364459/2866660 - config.paths['db/migrate'] += Rails.application.railties.engines.map{|e| e.paths['db/migrate'].existent}.flatten end end diff --git a/db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb b/db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb new file mode 100644 index 00000000..dc8cb3bc --- /dev/null +++ b/db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb @@ -0,0 +1,24 @@ +# This migration comes from foodsoft_wiki_engine (originally 20090325175756) +class CreatePages < ActiveRecord::Migration + def self.up + create_table :pages do |t| + t.string :title + t.text :body + t.string :permalink + t.integer :lock_version, :default => 0 + t.integer :updated_by + t.integer :redirect + t.integer :parent_id + + t.timestamps + end + add_index :pages, :title + add_index :pages, :permalink + Page.create_versioned_table # Automaticly creates pages_versions table + end + + def self.down + drop_table :pages + Page.drop_versioned_table + end +end From fd3aa7ebc90f7f48357111166d737eb23f36180e Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 6 Nov 2013 13:43:04 +0100 Subject: [PATCH 13/14] move dependency to wiki plugin --- Gemfile | 1 - Gemfile.lock | 2 +- lib/foodsoft_wiki/foodsoft_wiki.gemspec | 1 + lib/foodsoft_wiki/lib/foodsoft_wiki.rb | 4 +++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 27d7cba5..c04e5041 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,6 @@ gem 'client_side_validations' gem 'client_side_validations-simple_form' gem 'inherited_resources' gem 'localize_input', git: "git://github.com/bennibu/localize_input.git" -gem 'wikicloth' gem 'daemons' gem 'twitter-bootstrap-rails' gem 'simple-navigation' diff --git a/Gemfile.lock b/Gemfile.lock index 9933c081..9783d484 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,6 +24,7 @@ PATH foodsoft_wiki (0.0.1) acts_as_versioned rails (~> 3.2.15) + wikicloth GEM remote: https://rubygems.org/ @@ -388,4 +389,3 @@ DEPENDENCIES twitter-bootstrap-rails uglifier (>= 1.0.3) whenever - wikicloth diff --git a/lib/foodsoft_wiki/foodsoft_wiki.gemspec b/lib/foodsoft_wiki/foodsoft_wiki.gemspec index f8d436d9..937a887f 100644 --- a/lib/foodsoft_wiki/foodsoft_wiki.gemspec +++ b/lib/foodsoft_wiki/foodsoft_wiki.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 3.2.15" + s.add_dependency 'wikicloth' s.add_dependency 'acts_as_versioned' # need git version, make sure that is included in foodsoft's Gemfile s.add_development_dependency "sqlite3" diff --git a/lib/foodsoft_wiki/lib/foodsoft_wiki.rb b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb index 614a2a32..acf5ef50 100644 --- a/lib/foodsoft_wiki/lib/foodsoft_wiki.rb +++ b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb @@ -1,4 +1,6 @@ -require "foodsoft_wiki/engine" +require 'wikicloth' +require 'acts_as_versioned' +require 'foodsoft_wiki/engine' module FoodsoftWiki end From 9490357fcc4785fb7cfffb41406d8d28ded07efd Mon Sep 17 00:00:00 2001 From: wvengen Date: Thu, 7 Nov 2013 12:03:28 +0100 Subject: [PATCH 14/14] fix migration name --- ...ine.rb => 20090325175756_create_pages.foodsoft_wiki_engine.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{20131106095325_create_pages.foodsoft_wiki_engine.rb => 20090325175756_create_pages.foodsoft_wiki_engine.rb} (100%) diff --git a/db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb b/db/migrate/20090325175756_create_pages.foodsoft_wiki_engine.rb similarity index 100% rename from db/migrate/20131106095325_create_pages.foodsoft_wiki_engine.rb rename to db/migrate/20090325175756_create_pages.foodsoft_wiki_engine.rb