Add help page for Foodsoft variables
This commit is contained in:
parent
a6f02a24d4
commit
15ac566ece
5 changed files with 38 additions and 1 deletions
|
@ -1386,6 +1386,11 @@ en:
|
|||
title: Title
|
||||
update:
|
||||
notice: Page was updated
|
||||
variables:
|
||||
title: Foodsoft variables
|
||||
description: Variables return information from somewhere else. When you use the variable, it will be replaced by its value when displayed. Foodsoft has a number of pre-defined variables, such as the name and address of your foodcoop, the software version, and the number of members and suppliers. See the table below for all variables. You can use these in wiki pages as well as in the footer (from the configuration screen).
|
||||
variable: Variable
|
||||
value: Current value
|
||||
version:
|
||||
author: 'Author: %{user}'
|
||||
date_format: "%a, %d-%m-%Y, %H:%M"
|
||||
|
|
|
@ -40,7 +40,7 @@ module Foodsoft
|
|||
'supplier_count' => ->{ Supplier.undeleted.count },
|
||||
'active_supplier_count' => ->{ active_supplier_count },
|
||||
'active_suppliers' => ->{ active_suppliers },
|
||||
'first_order_date' => ->{ I18n.l Order.first.created_at.to_date }
|
||||
'first_order_date' => ->{ I18n.l Order.first.try{|o| o.starts.to_date} }
|
||||
}
|
||||
|
||||
# Return expanded variable
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# encoding: utf-8
|
||||
class PagesController < ApplicationController
|
||||
before_filter -> { require_plugin_enabled FoodsoftWiki }
|
||||
before_filter :catch_special_pages, only: [:show, :new]
|
||||
|
||||
skip_before_filter :authenticate, :only => :all
|
||||
before_filter :only => :all do
|
||||
|
@ -140,4 +141,18 @@ class PagesController < ApplicationController
|
|||
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
end
|
||||
|
||||
def variables
|
||||
keys = Foodsoft::ExpansionVariables.variables.keys
|
||||
@variables = Hash[keys.map {|k| [k, Foodsoft::ExpansionVariables.get(k)]}]
|
||||
render 'variables'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def catch_special_pages
|
||||
if params[:id] == 'Help:Foodsoft_variables'
|
||||
variables
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,5 +85,6 @@
|
|||
%td(colspan=2)
|
||||
%ul
|
||||
%li!= link_to t('.help.link_table'), '//www.mediawiki.org/wiki/Help:Tables', target: '_blank'
|
||||
%li!= link_to t('.help.link_variables'), page_path('Help:Foodsoft_variables'), target: '_blank'
|
||||
%li!= link_to t('.help.link_lists'), '//www.mediawiki.org/wiki/Help:Lists', target: '_blank'
|
||||
%li!= link_to t('.help.link_templates'), '//www.mediawiki.org/wiki/Help:Templates', target: '_blank'
|
||||
|
|
16
plugins/wiki/app/views/pages/variables.html.haml
Normal file
16
plugins/wiki/app/views/pages/variables.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- title t '.title'
|
||||
|
||||
%p= t '.description'
|
||||
|
||||
%table.table.table-hover
|
||||
%thead
|
||||
%tr
|
||||
%th= t '.variable'
|
||||
%th= t '.value'
|
||||
%tbody
|
||||
- @variables.each do |key, value|
|
||||
%tr
|
||||
%td
|
||||
%tt= "{{#{key}}}"
|
||||
%td
|
||||
= value
|
Loading…
Reference in a new issue