Skip to content

Commit 60af23b

Browse files
committed
base PDF filename on original filename
1 parent 3e86868 commit 60af23b

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22

33
A collection of useful legal clauses for coding consultants or employees to put into their contracts. Written and/or solicited by <a href="http://alexchaffee.com">Alex Chaffee</a>. Available at <https://github.com/alexch/clauses>.
44

5-
Similar clauses at <https://gist.github.com/postmodern/3242224>
6-
75
Disclaimer: I AM NOT A LAWYER. You should run all this by your own legal counsel.
86

7+
## Automatic contract generation
8+
9+
1. write a contract using [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
10+
2. use [`{{mustache}}`](https://mustache.github.io/) inside your document's body
11+
3. set variables in your document's header (a bunch of `name:value` lines, terminated with a blank line)
12+
4. run them through `process.rb` like this:
13+
14+
./process.rb contract.md
15+
16+
and like magic, a PDF version will appear!
17+
18+
## License
19+
920
<p xmlns:dct="http://purl.org/dc/terms/">
1021
<a rel="license"
1122
href="http://creativecommons.org/publicdomain/zero/1.0/">
@@ -21,6 +32,7 @@ Disclaimer: I AM NOT A LAWYER. You should run all this by your own legal counsel
2132

2233
## Similar Projects
2334

35+
* <https://gist.github.com/postmodern/3242224>
2436
* <https://stuffandnonsense.co.uk/projects/contract-killer/>
2537
* <http://www.docracy.com/>
2638

contract.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
duration: one month
88
max_hours: twenty (20)
99
rate: 100
10-
deposit: 1000
1110
late_fee: five percent (5%)
1211
net_days: ten (10)
1312

@@ -25,8 +24,8 @@ Consultant will not perform or invoice Client for Services in excess of {{max_ho
2524

2625
2. Fees & Expenses.
2726
Client shall pay Consultant at the rate of ${{rate}} per hour for the Services, and reimburse Consultant for reasonable out-of-pocket expenses incurred in connection with the Services.
28-
An initial deposit of ${{deposit}} will be due prior to the commencement of the Services, and fees will be deducted from such deposit until it is exhausted.
29-
Consultant will transmit an invoice to Client every two weeks, and Client will pay Consultant all amounts due within {{net_days}} days of receipt of such invoice.
27+
{{#deposit}}An initial deposit of ${{deposit}} will be due prior to the commencement of the Services, and fees will be deducted from such deposit until it is exhausted.
28+
{{/deposit}}Consultant will transmit an invoice to Client every two weeks, and Client will pay Consultant all amounts due within {{net_days}} days of receipt of such invoice.
3029
Late payments shall be subject to a late payment fee of {{late_fee}} of the amount due.
3130

3231
3. Intellectual Property.

contract.pdf

-67.9 KB
Binary file not shown.

process.rb

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def usage
1111

1212
source = ARGV[0] || usage
1313

14+
source = Pathname.new(source)
15+
output_path = File.join(source.dirname, source.basename.to_s.split('.')[0..-2].join('.') + '.pdf')
16+
1417
body = source.is_a?(IO) ? source.read : File.read(source)
1518

1619
# parse headers
@@ -71,7 +74,7 @@ def usage
7174
require 'pdfkit'
7275
kit = PDFKit.new(html, :page_size => 'Letter')
7376
kit.stylesheets << "contract-style.css"
74-
file = kit.to_file("contract.pdf")
77+
file = kit.to_file(output_path)
7578

7679
ap file
7780
`open #{file.path}`

0 commit comments

Comments
 (0)