docgenerator 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,128 @@
1
+ #
2
+ #Definition of elements for class DocGenerator_scrlettr2.rb
3
+ #used by for DocGenerator.rb
4
+ #
5
+ if __FILE__ == $0
6
+ require 'docgenerator'
7
+ end
8
+ #~ require 'date'
9
+
10
+ DocumentTemplate.add_template(
11
+ :scrlttr2, :latex, %q|<<prefix>>
12
+ \documentclass[<<classoptions>>]{scrlttr2}
13
+ \usepackage{babel}
14
+ \usepackage[ansinew]{inputenc}
15
+ \usepackage{hyperref}
16
+ % ----------------------------------------------------------------
17
+ <<head>>
18
+ % ----------------------------------------------------------------
19
+ \begin{document}
20
+ <<body>>
21
+ \end{document}
22
+ % ----------------------------------------------------------------
23
+ |)
24
+
25
+ #Example:
26
+ # letter = Letter.new( {
27
+ # :address => [ 'Name',
28
+ # 'Strasse',
29
+ # 'PLZ Ort'
30
+ # ].map{|e| [e, element(:br)] },
31
+ # :date => '',
32
+ # :opening => '~',
33
+ # :closing => '~',
34
+ # }).cr
35
+ class Letter < Environment
36
+ Element.add( [:letter], self )
37
+ add_attributes( {
38
+ :address => Attribute.create( [ :latex, :required ] ),
39
+ :date => Attribute.create( [ :latex ], [String] ), #Date?
40
+ :opening => Attribute.create( [ :latex, :required ] ),
41
+ :backaddress => Attribute.create( [ :latex ] ), # R�ucksendeadresse f�ur Fensterbriefumschl�age
42
+ #~ backaddressseparator Trennzeichen innerhalb der R�ucksendeadresse
43
+ #~ ccseparator Trennzeichen zwischen Verteilertitel und Verteiler
44
+ #~ customer Gesch�aftszeilenfeld �Kundennummer�
45
+ #~ emailseparator Trennzeichen zwischen E-Mail-Bezeichner und E-Mail-Adresse
46
+ #~ enclseparator Trennzeichen zwischen Anlagetitel und Anlagen
47
+ #~ faxseparator Trennzeichen zwischen Faxbezeichner und Faxnummer
48
+ :fromaddress => Attribute.create( [ :latex ] ), #Absenderadresse ohne Absendername
49
+ :frombank => Attribute.create( [ :latex ] ), #Bankverbindung des Absenders
50
+ :fromemail => Attribute.create( [ :latex ] ), #E-Mail-Adresse des Absenders
51
+ :fromfax => Attribute.create( [ :latex ] ), #Faxnummer des Absenders
52
+ :fromlogo => Attribute.create( [ :latex ] ), #Anweisungen zum Setzen des Absenderlogos
53
+ :fromname => Attribute.create( [ :latex ] ), #vollst�andiger Absendername
54
+ :fromphone => Attribute.create( [ :latex ] ), #Telefonnummer des Absenders
55
+ :fromurl => Attribute.create( [ :latex ] ), #eine URL des Absenders
56
+ :invoice => Attribute.create( [ :latex ] ), #Gesch�ftszeilenfeld �Rechnungsnummer�
57
+ #~ location erweiterte Absenderangabe
58
+ :myref => Attribute.create( [ :latex ] ), #Gesch�aftszeilenfeld �Mein Zeichen�
59
+ #~ place Ort
60
+ #~ placeseparator Trennzeichen zwischen Ort und Datum
61
+ #~ phoneseparator Trennzeichen zwischen Telefonbezeichner und Telefonnummer
62
+ #~ specialmail Versandart
63
+ :subject => Attribute.create( [ :latex ] ), #Betreff
64
+ #~ subjectseparator Trennzeichen zwischen Betrefftitel und Betreff
65
+ :title => Attribute.create( [ :latex ] ), #Brieftitel
66
+ #~ toname vollst�andiger Empf�angername
67
+ #~ toaddress Empf�angeradresse ohne Empf�angername
68
+ #~ yourmail Gesch�aftszeilenfeld �Ihr Schreiben�
69
+ #~ yourref
70
+ :signature => Attribute.create( [ :latex ] ), #Signatur unter Unterschrift und Gru�formel
71
+ :closing => Attribute.create( [ :latex, :required ] ),
72
+ }
73
+ )
74
+
75
+
76
+ def setkomavar( field )
77
+ if @attr[field].content.size > 0
78
+ return "\\setkomavar{#{field}}{#{@attr[field]}}\n"
79
+ else
80
+ return ''
81
+ end
82
+ end
83
+ def to_latex_environment( environment)
84
+ cmd = ''
85
+ cmd << "\n" if @crbefore
86
+ cmd << "\n\\begin{#{environment}}"
87
+ cmd << "{#{@attr[:address]}}\n"
88
+ #~ cmd << "{"
89
+ #~ cmd << @attr[:address].content.flatten.join( element(:br).to_latex)
90
+ #~ cmd << "}\n"
91
+ cmd << "\\date{#{@attr[:date]}}\n" if @attr[:date]
92
+ cmd << setkomavar( :backaddress )
93
+ cmd << setkomavar( :fromaddress )
94
+ cmd << setkomavar( :frombank )
95
+ cmd << setkomavar( :fromemail )
96
+ cmd << setkomavar( :fromfax )
97
+ cmd << setkomavar( :fromlogo )
98
+ cmd << setkomavar( :fromname )
99
+ cmd << setkomavar( :fromphone )
100
+ cmd << setkomavar( :fromurl )
101
+ cmd << setkomavar( :subject)
102
+ cmd << setkomavar( :invoice)
103
+ cmd << setkomavar( :myref)
104
+ cmd << "\\opening{#{@attr[:opening]}}\n"
105
+ cmd << @content.to_s
106
+ cmd = cmd.chomp + "\n"
107
+ cmd << setkomavar( :signature)
108
+ cmd << "\\closing{#{@attr[:closing]}}\n"
109
+ cmd << "\\end{#{environment}}\n"
110
+ cmd << "\n" if @crafter
111
+ return cmd
112
+ end
113
+ def to_latex( )
114
+ return to_latex_environment( 'letter' )
115
+ end
116
+ def to_html()
117
+ cmd = element( :div ).CR
118
+ #~ cmd << "\n" if @crbefore
119
+ cmd << anr = element(:p,{}, 'An' )
120
+ anr << element(:br)
121
+ @attr[:address].content.each{|a| anr << [a, element(:br) ] }
122
+ cmd << element(:p,{}, @attr[:opening] )
123
+ cmd << @content
124
+ cmd << element(:p,{}, @attr[:closing] )
125
+ #~ cmd << "\n" if @crafter
126
+ return cmd.to_s
127
+ end
128
+ end
@@ -0,0 +1,172 @@
1
+ #
2
+ #Support for scrpage2.sty.
3
+ #-
4
+ #
5
+ Element.create( [:clearscrheadings], {
6
+ }, false, {
7
+ :latex => '#{linebreak(@crbefore)}\clearscrheadings #{linebreak(@crafter)}',
8
+ })
9
+ Element.create( [:clearscrheadfoot], {
10
+ }, false, {
11
+ :latex => '#{linebreak(@crbefore)}\clearscrheadfoot #{linebreak(@crafter)}',
12
+ })
13
+ Element.create( [:clearscrplain], {
14
+ }, false, {
15
+ :latex => '#{linebreak(@crbefore)}\clearscrplain #{linebreak(@crafter)}',
16
+ })
17
+
18
+ #
19
+ #Values: scrheadings, scrplain
20
+ #
21
+ Element.create( [:pagestyle], {
22
+ }, true, {
23
+ :latex => '#{linebreak(@crbefore)}\pagestyle{#{@content}}#{linebreak(@crafter)}',
24
+ })
25
+
26
+ Element.create( [:manualmark], {
27
+ }, false, {
28
+ :latex => '#{linebreak(@crbefore)}\manualmark #{linebreak(@crafter)}',
29
+ })
30
+
31
+
32
+ Element.create( [:automark], {
33
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
34
+ }, true, {
35
+ :latex => '#{linebreak(@crbefore)}\automark#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
36
+ })
37
+
38
+ Element.create( [:lehead], {
39
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
40
+ }, true, {
41
+ :latex => '#{linebreak(@crbefore)}\lehead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
42
+ })
43
+
44
+ Element.create( [:cehead], {
45
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
46
+ }, true, {
47
+ :latex => '#{linebreak(@crbefore)}\cehead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
48
+ })
49
+ Element.create( [:rehead], {
50
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
51
+ }, true, {
52
+ :latex => '#{linebreak(@crbefore)}\rehead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
53
+ })
54
+ Element.create( [:lefoot], {
55
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
56
+ }, true, {
57
+ :latex => '#{linebreak(@crbefore)}\lefoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
58
+ })
59
+ Element.create( [:cefoot], {
60
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
61
+ }, true, {
62
+ :latex => '#{linebreak(@crbefore)}\cefoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
63
+ })
64
+ Element.create( [:refoot], {
65
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
66
+ }, true, {
67
+ :latex => '#{linebreak(@crbefore)}\refoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
68
+ })
69
+
70
+ Element.create( [:lohead], {
71
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
72
+ }, true, {
73
+ :latex => '#{linebreak(@crbefore)}\lohead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
74
+ })
75
+
76
+ Element.create( [:cohead], {
77
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
78
+ }, true, {
79
+ :latex => '#{linebreak(@crbefore)}\cohead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
80
+ })
81
+ Element.create( [:rohead], {
82
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
83
+ }, true, {
84
+ :latex => '#{linebreak(@crbefore)}\rohead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
85
+ })
86
+ Element.create( [:lofoot], {
87
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
88
+ }, true, {
89
+ :latex => '#{linebreak(@crbefore)}\lofoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
90
+ })
91
+ Element.create( [:cofoot], {
92
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
93
+ }, true, {
94
+ :latex => '#{linebreak(@crbefore)}\cofoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
95
+ })
96
+ Element.create( [:rofoot], {
97
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
98
+ }, true, {
99
+ :latex => '#{linebreak(@crbefore)}\rofoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
100
+ })
101
+
102
+
103
+ Element.create( [:ihead], {
104
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
105
+ }, true, {
106
+ :latex => '#{linebreak(@crbefore)}\ihead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
107
+ })
108
+ Element.create( [:chead], {
109
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
110
+ }, true, {
111
+ :latex => '#{linebreak(@crbefore)}\chead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
112
+ })
113
+ Element.create( [:ohead], {
114
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
115
+ }, true, {
116
+ :latex => '#{linebreak(@crbefore)}\ohead#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
117
+ })
118
+ Element.create( [:ifoot], {
119
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
120
+ }, true, {
121
+ :latex => '#{linebreak(@crbefore)}\ifoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
122
+ })
123
+ Element.create( [:cfoot], {
124
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
125
+ }, true, {
126
+ :latex => '#{linebreak(@crbefore)}\cfoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
127
+ })
128
+ Element.create( [:ofoot], {
129
+ :rightmark => Attribute.create( [ :latex ], [ String ] ),
130
+ }, true, {
131
+ :latex => '#{linebreak(@crbefore)}\ofoot#{texoptional(:rightmark)}{#{@content}}#{linebreak(@crafter)}',
132
+ })
133
+
134
+ #~ #
135
+ #
136
+ #~ class Captionof < Element
137
+ #~ #Make the key known to the complete key-list of elements.
138
+ #~ Element.add( [:captionof], Captionof)
139
+ #~ add_attributes( HTML_ATTR_ALL )
140
+ #~ add_attributes( {
141
+ #~ :float_type => Attribute.create( [ :latex, :required ], [ 'figure', 'table' ] ),
142
+ #~ :lst_entry => Attribute.create( [ ], [ String ] ),
143
+ #~ } )
144
+
145
+ #~ #Redefine standard output.
146
+ #~ #Options are given, if an option is avalaible.
147
+ #~ def to_latex()
148
+ #~ cmd = linebreak(@crbefore)
149
+ #~ cmd << "\\captionof{#{@attr[:float_type]}}"
150
+ #~ #Empty [] would return empty entry for list of figures,
151
+ #~ cmd << "[#{@attr[:lst_entry]}]" if @attr[:lst_entry].content?
152
+ #~ cmd << "{#{@content}}"
153
+ #~ cmd << linebreak(@crafter)
154
+ #~ return cmd
155
+ #~ end
156
+ #~ def htmltag(); 'span'; end #fixme
157
+ #~ def to_html()
158
+ #~ return ''
159
+ #~ end
160
+ #~ end #
161
+
162
+ __END__
163
+ pdf.head << element(:usepackage,{}, 'scrpage2' ).cr
164
+ pdf.head << element(:usepackage,{}, 'totpages' ).cr
165
+
166
+ pdf.head << element(:pagestyle,{}, 'scrheadings' ).cr
167
+ pdf.head << element(:automark, {}, 'section').cr
168
+
169
+ pdf.head << element(:clearscrheadings).cr
170
+ pdf.head << element(:ihead, {}, '\\headmark').cr
171
+ pdf.head << element(:ofoot,{}, '\\pagemark/\\ref{TotPages}').cr
172
+ pdf.head << element(:ifoot,{}, '\\url{http://www.lickert.net}').cr
@@ -0,0 +1,84 @@
1
+ #if ! $".include?('docgenerator.rb')
2
+ if ! defined?( Document )
3
+ require 'docgenerator'
4
+ end
5
+ #
6
+ #Used by
7
+ #-ODPAnalyser
8
+ #-Stummfilm/Bezugsquellen
9
+
10
+ #
11
+ #Small Administration class for websites and their description
12
+ #
13
+ class Url
14
+ def initialize( url, short=url, descr=nil, lastvisit = nil )
15
+ @url = url
16
+ @short = short
17
+ @short = url if ! @short
18
+ @descr = descr
19
+ @lastvisit = lastvisit
20
+ @mirrors = []
21
+ @@all << self
22
+ end
23
+ @@all = []
24
+ #Refresh the list of all URL.
25
+ def self.clear()
26
+ @@all = []
27
+ end
28
+ #Uri of the website
29
+ attr_accessor :url
30
+ #Short description
31
+ attr_accessor :short
32
+ #Description of the content
33
+ attr_accessor :descr
34
+ #Date of last visit/check
35
+ attr_accessor :lastvisit
36
+ #Short description is used as linktext
37
+ alias :linktext :short
38
+
39
+ def to_s()
40
+ return "#{self.url()}"
41
+ end
42
+ def to_element()
43
+ return element(:a, {:href=>self.url}, self.linktext())
44
+ end
45
+ #Output with all details.
46
+ #The ctrl-hash contains all elements which should be included.
47
+ def to_element_long( ctrl_in = {} )
48
+ ctrl = { :lastvisit => true,
49
+ :descr => :br,
50
+ :attach => nil,
51
+ }.update(ctrl_in)
52
+
53
+ el_long = [ self.to_element() ]
54
+ if ctrl[:lastvisit] and self.lastvisit
55
+ if self.lastvisit.respond_to?( :strftime )
56
+ el_long << " (#{self.lastvisit.strftime( '%Y-%m-%d' )})"
57
+ elsif self.lastvisit
58
+ el_long << " (#{self.lastvisit})"
59
+ end
60
+ end
61
+ if ctrl[:descr] and self.descr()
62
+ if element( ctrl[:descr] ).content?
63
+ el_long << element(ctrl[:descr], {}, self.descr ).cr
64
+ else
65
+ el_long << element(ctrl[:br]).cr if ctrl.include?(:br)
66
+ el_long << self.descr()
67
+ end
68
+ end
69
+ el_long << ctrl[:attach]
70
+ return el_long
71
+ end
72
+ #Return URL for usage inside a list.
73
+ def to_element_li()
74
+ return element(:li, {}, self.to_element_long() ).cr
75
+ end
76
+ #Return all collected URL in a docgenerator-list
77
+ def self.list( listtype = :ul, list = @@all )
78
+ li_list = element( listtype ).cr
79
+ list.each{|url| li_list << url.to_element_li }
80
+ return li_list
81
+ end
82
+ end
83
+
84
+
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: docgenerator
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.1
7
+ date: 2008-03-16 00:00:00 +01:00
8
+ summary: "The docgenerator-package allows the definition of documents and export to *LaTeX *HTML *Wiki (not very goog supported) *plain text (also not very good supported) This package is the base of *wiki2docgenerator - a wiki to TeX/HTML-Translator *Sitegenerator - A offline website generator ------------- Urspr\xFCnglich als TeX-Code-Generator gebaut ist das Paket inzwischen ein LaTeX, HTML, Wiki und Textgenerator geworden. Das Paket ist Basis eines \"Datei-Wiki\" und Sitegenerators."
9
+ require_paths:
10
+ - .
11
+ email: knut@lickert.net
12
+ homepage: http://ruby.lickert.net/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Knut Lickert
31
+ files:
32
+ - docgenerator.rb
33
+ - docgenerator_attribute.rb
34
+ - docgenerator_characters.rb
35
+ - docgenerator_css.rb
36
+ - docgenerator_document.rb
37
+ - docgenerator_element.rb
38
+ - docgenerator_elements.rb
39
+ - docgenerator_environments.rb
40
+ - docgenerator_footnote.rb
41
+ - docgenerator_lists.rb
42
+ - docgenerator_sections.rb
43
+ - docgenerator_tabular.rb
44
+ - docgenerator_template.rb
45
+ - packages/docgenerator_attachfile.rb
46
+ - packages/docgenerator_beamer.rb
47
+ - packages/docgenerator_caption.rb
48
+ - packages/docgenerator_hyperref.rb
49
+ - packages/docgenerator_listings.rb
50
+ - packages/docgenerator_pdfpages.rb
51
+ - packages/docgenerator_scrlettr2.rb
52
+ - packages/docgenerator_scrpage2.rb
53
+ - packages/docgenerator_url.rb
54
+ - examples/docgenerator_example.rb
55
+ test_files: []
56
+
57
+ rdoc_options: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ requirements: []
66
+
67
+ dependencies: []
68
+