Skip to content

Commit 7399bd2

Browse files
Merge pull request #1 from vvmruder/redmine_3.2.0
Redmine 3.2.0
2 parents 00e5c40 + e8d371c commit 7399bd2

File tree

14 files changed

+155
-64
lines changed

14 files changed

+155
-64
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ DocPu, Document publishing plugin
44
This plugin enables PDF export and generation for Redmine wiki pages using the LaTeX typesetting system. But it is even more than an simple PDF exporter since it uses the LaTeX text and figure layout engine.
55

66
Originally this redmine plugin was created by Christian Raschko (sponsored by [ATV-Elektronik](http://atv-elektronik.co.at/)). It was intended to be used for 1.1.x verisions of redmine and below.
7-
Since this plugin creates eye catching documents and of cause can be extended a little more I decided to adopt the code and make it valid for use in __redmine 2.6.x__ versions.
7+
Since this plugin creates eye catching documents and of cause can be extended a little more I decided to adopt the code and make it valid for use in __redmine 3.2.x__ versions.
88

99
Mainly all features as described below should work. You may find formatting in Redmine's wiki-syntax which isn't covered yet. If so-feel free to contact me.
1010

@@ -28,14 +28,19 @@ Features
2828
Dependencies
2929
============
3030

31-
DocPu uses and extends the [RedCloth4](http://redcloth.org/) LaTeX export module, which is a converter for the Textile markup language. The system which hosts redmine should also have an working installation of LaTeX. Since the code highlighting is done by pygments, this python package should be installed too. This version of the plugin is made to work with __redmine 2.6.x__. This indicate a dependency to [rails 3.2](http://guides.rubyonrails.org/v3.2.21/3_2_release_notes.html) as you can see [here](http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Ruby-interpreter). For older redmines you can refer to this [version](http://www.redmine.org/plugins/redmine_doc_pu) of the plugin.
31+
DocPu uses and extends the [RedCloth4](http://redcloth.org/) LaTeX export module, which is a converter for the Textile markup language. The system which hosts redmine should also have an working installation of LaTeX. Since the code highlighting is done by pygments, this python package should be installed too. This version of the plugin is made to work with __redmine 3.2.x__. This indicate a dependency to [rails 4.2.5](http://guides.rubyonrails.org/4_2_release_notes.html) as you can see [here](http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Ruby-interpreter). For older redmines you can refer to this [version](http://www.redmine.org/plugins/redmine_doc_pu) of the plugin.
32+
33+
List of Dependencies in a quick view:
34+
* redmine 3.2.0 (tested with ruby 2.0, rails 4.2.5, RedCloth 4.2.9)
35+
* Tex (tested with pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014))
36+
* Packeges which are important due to creation process of the PDF inside the plugin (newfloat, minted, caption, ulem, graphicx, float, multirow, makeidx, hyperref, tabularx, footnote, scrhack)
3237

3338
Installing RedCloth4
3439
--------------------
3540

3641
Currently Redmine uses RedCloth3, so you have to additionally install RedCloth4.
3742
The simplest solution is by typing gem install RedCloth, but this only works if you have a compiler set-up, since some parts are written in C code.
38-
For windows users a pre compiled gem package can be downloaded from the repository. Download it first and install it via eg. gem install RedCloth-4.2.2-x86-mswin32-60.gem
43+
For windows users a pre compiled gem package can be downloaded from the repository.
3944

4045
LaTeX
4146
-----
@@ -47,6 +52,7 @@ On Windows machines you can download and install the [MikTex](http://miktex.org/
4752

4853
DocPu Requires the following LaTeX packages, be sure you have them installed as well:
4954

55+
* newfloat
5056
* tabularx
5157
* listings
5258
* ulem
@@ -57,6 +63,8 @@ DocPu Requires the following LaTeX packages, be sure you have them installed as
5763
* hyperref
5864
* minted
5965
* caption
66+
* footnote
67+
* scrhack
6068

6169
### Testing LaTeX
6270

@@ -154,6 +162,8 @@ The image position can be fixed or floated. Fixed images occur at the text posit
154162

155163
Normally you have the standard LaTeX [image types](https://en.wikibooks.org/wiki/LaTeX/Importing_Graphics#Supported_image_formats) available for use.
156164

165+
Note that all images are scaled to fit in the text width space with keeping the spect ratio if they are to large for the page.
166+
157167
## Tables
158168

159169
DocPu supports the Redmine/Textile table syntax with table span and heading.
@@ -162,3 +172,11 @@ DocPu supports the Redmine/Textile table syntax with table span and heading.
162172
# Template handling
163173

164174
The templates in the plugins template directory are simply LeTeX-Templates. Please refer to [this](https://en.wikibooks.org/wiki/LaTeX) guide to learn more about LaTeX and how to use it.
175+
176+
It is really important, that you have a look at the templates which are included in this plugin. There you can have a look how a template must be written to match the criteria set by this plugin. We designed around this pattern several special looking templates, which are working well. You should be able to do so as well. But keep in mind to NOT DELETE/EDIT ANY CONTENT/PACKAGES which is given in this templates. You can copy one of them (keeping all stuff which is in it) and use the copy to add your own styling. Again: If you delete/edit any thing of the given parameters it will probably not work. But you have enough options to build a nice looking template on top of the existing pattern.
177+
178+
# Known Problems
179+
180+
* Footnotes in tables are placed directly under the table and not to the end of the page (this is due to LaTeX-dependet problems => you may google for it).
181+
* Sometimes the index will not be created well (it helps to build the document 2-3 times again => the number of warnings should decrease)
182+
* to get rid of the warnings and sometimes the errors it can be helpful to rebuild the document 2-3 times before having a look on the templates (also use the clean function in the build view to delete all generated files if you are facing any problems)

app/controllers/doc_pu_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ class DocPuController < ApplicationController
1010

1111
# Show all documents
1212
def index
13-
@documents = DocPuDocument.find_all_by_project_id(@project)
13+
@documents = DocPuDocument.where(project_id: @project)
1414
end
1515

1616

1717
# Create new document
1818
def new
19+
1920
@templates_list = DocPuTemplates.new(Rails.root.join(Setting.plugin_redmine_doc_pu['template_dir'])).list
2021
@doc = DocPuDocument.new
2122
@doc.project = @project
2223
@doc.user = User.current
2324
if request.post?
2425
# Save object
25-
@doc.attributes = checkbox_to_boolean(params[:doc])
26+
@doc.attributes = checkbox_to_boolean(params.require(:doc).permit!)
2627
if @doc.save
2728
flash[:notice] = t(:flash_document_saved)
2829
redirect_to :action => :edit, :project_id => @project, :id => @doc
@@ -34,10 +35,10 @@ def new
3435

3536
# Edit document
3637
def edit
37-
@doc = DocPuDocument.find(params[:id])
38-
if request.put?
38+
@doc = DocPuDocument.find(params[:id])
39+
if request.patch?
3940
# Update document
40-
@doc.attributes = checkbox_to_boolean(params[:doc])
41+
@doc.attributes = checkbox_to_boolean(params.require(:doc).permit!)
4142
flash[:notice] = t(:flash_document_updated) if @doc.save
4243
end
4344

app/controllers/doc_pu_wiki_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def new
1717
if request.post?
1818
# Save object
1919
reorder_pages(@doc_pu.doc_pu_wiki_pages.all)
20-
@doc_pu_wiki = @doc_pu.doc_pu_wiki_pages.create(checkbox_to_boolean params[:doc_pu_wiki])
20+
@doc_pu_wiki = @doc_pu.doc_pu_wiki_pages.create(checkbox_to_boolean params.require(:doc_pu_wiki).permit!)
2121
@doc_pu_wiki.wiki_page_order = get_new_page_order()
2222
@doc_pu_wiki.wiki_page_version = 0
2323
if @doc_pu_wiki.save
@@ -34,7 +34,7 @@ def edit
3434
@doc_pu_wiki = DocPuWikiPage.find(params[:id])
3535
if request.put?
3636
# Update object
37-
@doc_pu_wiki.attributes = checkbox_to_boolean(params[:doc_pu_wiki])
37+
@doc_pu_wiki.attributes = checkbox_to_boolean(params.require(:doc_pu_wiki).permit!)
3838
if @doc_pu_wiki.save
3939
flash[:notice] = t(:flash_page_updated)
4040
redirect_to :controller => :doc_pu, :action => :edit, :project_id => @project, :id => @doc_pu

app/models/doc_pu_document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DocPuDocument < ActiveRecord::Base
1010

1111
belongs_to :user
1212
belongs_to :project
13-
has_many :doc_pu_wiki_pages, :dependent => :destroy, :order => 'wiki_page_order'
13+
has_many :doc_pu_wiki_pages, :dependent => :destroy
1414

1515
validates_presence_of :name, :template, :user_id, :project_id
1616
validates_uniqueness_of :name

app/views/doc_pu/_form.html.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
<p><%= f.check_box :latex_table_border %> <%= acronym_info_tag t(:info_latex_table_border) %></p>
2222
<p><%= f.check_box :latex_image_ref %> <%= acronym_info_tag t(:info_latex_image_ref) %></p>
2323
</td>
24+
<td class="doc_pu_edit_table_column">
25+
<p><%= f.check_box :latex_table_of_contents %> <%= acronym_info_tag t(:info_latex_table_of_contents) %></p>
26+
<p><%= f.check_box :latex_list_of_figures %> <%= acronym_info_tag t(:info_latex_list_of_figures) %></p>
27+
<p><%= f.check_box :latex_list_of_tables %> <%= acronym_info_tag t(:info_latex_list_of_tables) %></p>
28+
<p><%= f.check_box :latex_list_of_listings %> <%= acronym_info_tag t(:info_latex_list_of_listings) %></p>
29+
<p><%= f.check_box :latex_generate_index %> <%= acronym_info_tag t(:info_latex_generate_index) %></p>
30+
</td>
2431
</tr>
2532
</table>
2633
<div align=left><%= submit_tag l(:button_save) %></div>

config/locales/de.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ de:
1818
field_latex_index_importance: "Wichtige Wörter indizieren"
1919
field_latex_table_border: "Rahmen für Tabellen"
2020
field_latex_image_ref: "Bilder refernzieren"
21+
field_latex_list_of_listings: "Codeverzeichnis"
22+
field_latex_table_of_contents: "Inhaltsverzeichnis"
23+
field_latex_list_of_figures: "Abbildungsverzeichnis"
24+
field_latex_list_of_tables: "Tabellenverzeichnis"
25+
field_latex_generate_index: "Index"
2126
field_wiki_page: "Wiki Seite"
2227
field_chapter_name: "Kapitel Name"
2328
field_use_doc_flags: "Dokument Flags verwenden"
@@ -74,6 +79,11 @@ de:
7479
info_latex_index_importance: ""
7580
info_latex_table_border: "Stellt Tabellenlinien dar."
7681
info_latex_image_ref: "Erzeuge Bildverzeichnis"
82+
info_latex_list_of_listings: "Erzeugt ein Verzeichnis aller Code-Beispiele. Dieses wird am Anfang des Dokumentes eingefügt."
83+
info_latex_list_of_figures: "Erzeugt eine Verzeichnis aller Abbildungen. Dieses wird am Anfang des Dokumentes eingefügt."
84+
info_latex_list_of_tables: "Erzeugt eine Verzeichnis aller Tabellen. Dieses wird am Anfang des Dokumentes eingefügt."
85+
info_latex_table_of_contents: "Erzeugt ein Inhaltsverzeichnis für das gesamte Dokument. Dieses wird am Anfang des Dokumentes eingefügt."
86+
info_latex_generate_index: "Erzeugt einen Index von hervorgehobenen Wörtern (dies sind alle Wörter die mit \\*WORT\\* fett gedruckt werden). Es wird am Ende des Dokumentes eingefügt."
7787
button_test: "Test"
7888
field_latex_bin: "LaTeX Binärdatei (pdflatex)"
7989
field_makindex_bin: "makeindex Binärdatei"

config/routes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
match 'doc_pu', :controller => 'doc_pu', :action => 'index', :via => :get
22
match 'doc_pu/new', :controller => 'doc_pu', :action => 'new', :via => [:get, :post]
3-
match 'doc_pu/edit', :controller => 'doc_pu', :action => 'edit', :via => [:get, :post, :put]
3+
match 'doc_pu/edit', :controller => 'doc_pu', :action => 'edit', :via => [:get, :post, :patch]
44
match 'doc_pu/open', :controller => 'doc_pu', :action => 'open', :via => [:get, :post]
55
match 'doc_pu/build', :controller => 'doc_pu', :action => 'build', :via => [:get, :post]
66
match 'doc_pu/build_remote', :controller => 'doc_pu', :action => 'build_remote', :via => [:get, :post]
@@ -12,7 +12,7 @@
1212

1313
match 'doc_pu_wiki', :controller => 'doc_pu_wiki', :action => 'index', :via => [:get]
1414
match 'doc_pu_wiki/new', :controller => 'doc_pu_wiki', :action => 'new', :via => [:get, :post]
15-
match 'doc_pu_wiki/edit', :controller => 'doc_pu_wiki', :action => 'edit', :via => [:get, :post, :put]
15+
match 'doc_pu_wiki/edit', :controller => 'doc_pu_wiki', :action => 'edit', :via => [:get, :post, :patch]
1616
match 'doc_pu_wiki/delete', :controller => 'doc_pu_wiki', :action => 'delete', :via => [:get, :post]
1717
match 'doc_pu_wiki/edit_order', :controller => 'doc_pu_wiki', :action => 'edit_order', :via => [:get, :post]
1818

init.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name 'Redmine DocPu plugin'
1111
author 'Christian Raschko'
1212
description 'A wiki export and document publishing tool, sponsored by: ATV-Elektronik and modified for further use by: GIS-Fachstelle BL'
13-
version '0.0.4'
13+
version '2.0.0'
1414
url 'https://github.com/vvmruder/redmine_doc_pu'
1515

1616
# Settings
@@ -22,7 +22,7 @@
2222
:partial => 'settings/doc_pu_settings'
2323

2424
# Redmine version
25-
requires_redmine :version_or_higher => '2.6.0'
25+
requires_redmine :version_or_higher => '3.2.0'
2626

2727
# Create project module
2828
project_module :doc_pu do

lib/latex_doc.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,49 @@ def to_latex
6464
self.wiki_pages.each do |page|
6565
doc_txt += page.to_latex
6666
end
67+
intro_content = false
68+
pre_text = ""
69+
70+
if self.latex_table_of_contents
71+
# Add table of contents to the begin of the document
72+
with_table_of_content = "\\tableofcontents\n\n"
73+
pre_text << with_table_of_content
74+
intro_content = true
75+
end
76+
77+
if self.latex_list_of_figures
78+
# Add list of figures to the begin of the document
79+
with_list_of_figures = "\\listoffigures\n\n"
80+
pre_text << with_list_of_figures
81+
intro_content = true
82+
end
83+
84+
if self.latex_list_of_tables
85+
# Add list of tables to the begin of the document
86+
with_list_of_tables = "\\listoftables\n\n"
87+
pre_text << with_list_of_tables
88+
intro_content = true
89+
end
90+
91+
if self.latex_list_of_listings
92+
# Add list of code listings to the begin of the document
93+
with_list_of_listings = "\\listoflistings\n\n"
94+
pre_text << with_list_of_listings
95+
intro_content = true
96+
end
97+
98+
if intro_content
99+
with_roman_numbers = "\n\n\\pagenumbering{roman}\n\n\\setcounter{page}{1}\n\n"
100+
pre_text = with_roman_numbers << pre_text
101+
pre_text << "\n\n\\cleardoublepage\\pagenumbering{arabic}\n\n\\setcounter{page}{1}\n\n"
102+
doc_txt = pre_text << doc_txt
103+
end
104+
105+
if self.latex_generate_index
106+
# Add list of code listings to the begin of the document
107+
with_index = "\n\n\\printindex"
108+
doc_txt << with_index
109+
end
67110
doc_txt
68111
end
69112

lib/latex_flags.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ module ModuleLatexFlags
1010
:latex_index_emphasis => true,
1111
:latex_index_importance => true,
1212
:latex_table_border => true,
13-
:latex_image_ref => false
13+
:latex_image_ref => false,
14+
:latex_list_of_listings => false,
15+
:latex_list_of_figures => false,
16+
:latex_list_of_tables => false,
17+
:latex_table_of_contents => false,
18+
:latex_generate_index => false
1419
}
1520

1621

0 commit comments

Comments
 (0)