Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amendments
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LQDN Adminsys
amendments
Commits
915b73a4
Commit
915b73a4
authored
Mar 31, 2013
by
Michael Witrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accept template as option
parent
74a3682c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
extract_amendments.rb
extract_amendments.rb
+8
-6
server.rb
server.rb
+6
-2
No files found.
extract_amendments.rb
View file @
915b73a4
...
...
@@ -147,9 +147,10 @@ class AmendmentExtractor
end
debug
"rendering amendments"
template
=
ERB
.
new
File
.
read
(
'template.erb'
),
nil
,
'-'
template_text
=
options
[
:template
]
||
File
.
read
(
'template.erb'
)
template
=
ERB
.
new
template_text
,
4
,
'-'
erb_binding
=
OpenStruct
.
new
(
amendments:
amendments
).
instance_eval
{
binding
}
erb_binding
=
OpenStruct
.
new
(
amendments:
amendments
).
instance_eval
{
binding
}
.
taint
output
=
template
.
result
(
erb_binding
)
end
end
...
...
@@ -160,7 +161,8 @@ if $0 == __FILE__
extra_args
=
cli
'--xml-dump'
=>
lambda
{
|
path
|
options
[
:xml_dump_path
]
=
path
},
'-d --debug'
=>
lambda
{
$DEBUG
=
true
},
'-1 --one'
=>
lambda
{
options
[
:parse_only_one
]
=
true
},
'-n --number'
=>
lambda
{
|
num
|
options
[
:parse_only_num
]
=
num
}
'-n --number'
=>
lambda
{
|
num
|
options
[
:parse_only_num
]
=
num
},
'-t --template'
=>
lambda
{
|
file
|
options
[
:template
]
=
File
.
read
(
file
)
}
opendocument_path
=
extra_args
.
first
raise
"usage: #$0 <OpenDocument file>"
unless
opendocument_path
...
...
server.rb
View file @
915b73a4
...
...
@@ -12,7 +12,7 @@ get '/' do
end
post
'/extract'
do
result
=
AmendmentExtractor
.
new
.
extract
(
params
[
'file'
][
:tempfile
].
path
)
result
=
AmendmentExtractor
.
new
.
extract
(
params
[
'file'
][
:tempfile
].
path
,
template:
params
[
'template'
]
)
haml
:extract
,
locals:
{
result:
result
}
end
...
...
@@ -39,9 +39,13 @@ __END__
%label.control-label{:for => "file"} ODT File
.controls
%input#file{type: "file", name: "file"}
.control-group
%label.control-label{:for => "template"} Template
.controls
%textarea.input-block-level#template{rows: 20, name: "template"}= params[:template] || File.read('template.erb')
.control-group
.controls
%button.btn.btn-primary{:type => "submit"} Extract
@@ extract
%textarea
{rows: 20, style: 'width: 100%'
}= Rack::Utils.escape_html(result)
%textarea
.input-block-level{rows: 20
}= Rack::Utils.escape_html(result)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment