hackademic 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfacecaab2ef9d8d0e912d678cae7d156aecd5a2
4
- data.tar.gz: 0dd4b487bc8fea19592afb54e99c2648d4994733
3
+ metadata.gz: 03ddbab38fc0b8902f15efa0443042b5b7553a2c
4
+ data.tar.gz: f227c94397e739676433b066a110439f8898335d
5
5
  SHA512:
6
- metadata.gz: 59e40e27994b84796d59c19f58dd6dcf3d81359932d91d65f0bf7e01800e712f6bfe895f59c86339d138afc8bd8f09e3935ddfcc9253748b68a65468b13ee3ef
7
- data.tar.gz: a347a1d3f93e31fcf9afb3ca3bae06ed6fcf87b6222633cb50bb9cb18d8aab06f52b44565cc8b51a8d108a27d2156c15254a3c7895580c74f4d43fe0d52f578d
6
+ metadata.gz: d08c72bb63e5e53fd4f615316b21f07b538e22da437794b1ad734c598bd708ebe81a962f19633d790e7b745da7fc75e17ae4471bfad5aae5bb983304773ab837
7
+ data.tar.gz: deea42467d8169c25b6305a6c91635b0156c43c735b6d59c907bfd498ee6705daabb52b5766514bfb974da5f8b48b9977cb0f54f8518d5af950efdb738b10abf
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.0
4
+
5
+ * Docx generation now defaults to using LibreOffice as a way to get more control over the output via an odt template.
6
+ * Refactoring and clean-ups.
7
+
3
8
  ## 0.2.9
4
9
 
5
10
  * Can now specify pandoc variables for pdf generation directly in the Config.yml
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/hackademic'
3
3
 
4
- Hackademic.start
4
+ HackademicCLI.start
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hackademic'
3
- s.version = '0.2.9'
4
- s.date = '2016-01-03'
3
+ s.version = '0.3.0'
4
+ s.date = '2016-02-28'
5
5
  s.summary = "Create and manage your academic workflow"
6
6
  s.description = "Hackademic manages your plain-text academic workflow."
7
7
  s.authors = ["Matthew Petty"]
@@ -2,10 +2,15 @@ require "rubygems"
2
2
  require "yaml"
3
3
  require "thor"
4
4
  require 'active_support'
5
- require_relative 'hackademy/sync'
6
- require_relative 'hackademy/compile'
5
+ require_relative 'hackademic/config'
6
+ require_relative 'hackademic/sync'
7
+ require_relative 'hackademic/compile'
8
+ require_relative 'hackademic/new'
7
9
 
8
- class Hackademic < Thor
10
+ # TODO: Un-spaghetti-fy this project
11
+ # TODO: Handle missing Config.yml variables nicely
12
+
13
+ class HackademicCLI < Thor
9
14
 
10
15
  include Thor::Actions
11
16
 
@@ -13,10 +18,10 @@ class Hackademic < Thor
13
18
  source_root "#{Pathname.new(__FILE__).dirname}"
14
19
 
15
20
  register Sync, :sync, "sync [subcommand]", "Synchronize!"
16
- register Hackademy::New, :new, "new [PROJECT]", "Create something new!"
21
+ register Hackademic::New, :new, "new [PROJECT]", "Create something new!"
17
22
 
18
23
  desc 'compile [FORMAT]', 'Type "hackademic help compile" to see choices'
19
- subcommand 'compile', ::Hackademy::Compile
24
+ subcommand 'compile', ::Hackademic::Compile
20
25
 
21
26
  desc "list", "List the current projects in #{HACKADEMIC_DIRECTORY}"
22
27
  def list
@@ -49,6 +54,7 @@ class Hackademic < Thor
49
54
  template "../templates/default.asciidoc", ENV["HOME"] + "/.pandoc/templates/default.asciidoc"
50
55
  template "../templates/default.html5", ENV["HOME"] + "/.pandoc/templates/default.html5"
51
56
  template "../templates/default.latex", ENV["HOME"] + "/.pandoc/templates/default.latex"
57
+ template "../templates/default.odt", ENV["HOME"] + "/.pandoc/templates/default.odt"
52
58
  end
53
59
 
54
60
  desc "setup [FOLDER]", "Setup a new Hackademic repository at [FOLDER]"
@@ -1,6 +1,4 @@
1
- require_relative "hackademy"
2
-
3
- module Hackademy
1
+ module Hackademic
4
2
  class Compile < Thor
5
3
 
6
4
  include Thor::Actions
@@ -23,16 +21,20 @@ module Hackademy
23
21
 
24
22
  desc "show_pdf_command", "Show the pandoc command for pdf generation"
25
23
  def show_pdf_command
26
- p config.pandoc
27
24
  say pdf_command, :blue
28
25
  end
29
26
 
27
+ desc "show_docx_command", "Show the pandoc command for docx generation"
28
+ def show_docx_command
29
+ say docx_command, :blue
30
+ end
31
+
30
32
  desc "docx", "compile a docx"
31
33
  def docx
32
34
  check_installation
33
35
  read_draft_file
34
36
  write_master_markdown_file
35
- %x[pandoc #{config.output_directory}/#{config.transcluded_draft} --from=markdown+#{pandoc_from_options.join("+")} --filter pandoc-citeproc --bibliography=#{config.bibliography} --csl=#{config.citation_style} --reference-docx=#{config.docx_template} -s -o "#{config.output_directory}/#{config.draft_name.gsub(/\..*$/,'')}.docx"]
37
+ system docx_command
36
38
  say "Writing out DOCX file: #{config.output_directory}/#{config.draft_name.gsub(/\..*$/, '')}.docx"
37
39
  end
38
40
 
@@ -51,6 +53,29 @@ module Hackademy
51
53
  "#{config.output_directory}/#{config.draft_name.gsub(/\..*$/,'')}.tex"
52
54
  end
53
55
 
56
+ def libre_office_binary
57
+ config.libre_office_binary || "/Applications/LibreOffice.app/Contents/MacOS/soffice"
58
+ end
59
+
60
+ def docx_command
61
+ if File.exists?(libre_office_binary)
62
+ command = ""
63
+ # Use pandoc to create an ODT file"
64
+ command << %[pandoc #{config.output_directory}/#{config.transcluded_draft} --from=markdown+#{pandoc_from_options.join("+")} --filter pandoc-citeproc --bibliography=#{config.bibliography} --csl=#{config.citation_style} -s -o temp.odt]
65
+ command << " && "
66
+ # Use LibreOffice to create a DOCX file"
67
+ command << "#{libre_office_binary} --invisible --convert-to docx temp.odt"
68
+ command << " && "
69
+ # Remove the un-necessary odt file
70
+ command << "rm temp.odt"
71
+ command << " && "
72
+ # Rename the temp.docx and move it into the Versions directory
73
+ command << "mv temp.docx #{config.output_directory}/#{config.draft_name.gsub(/\..*$/,'')}.docx"
74
+ else
75
+ %[pandoc #{config.output_directory}/#{config.transcluded_draft} --from=markdown+#{pandoc_from_options.join("+")} --filter pandoc-citeproc --bibliography=#{config.bibliography} --csl=#{config.citation_style} --reference-docx=#{config.docx_template} -s -o "#{config.output_directory}/#{config.draft_name.gsub(/\..*$/,'')}.docx"]
76
+ end
77
+ end
78
+
54
79
  def pdf_command
55
80
  cmd = %{pandoc \
56
81
  --template=#{config.pdf_template} \
@@ -61,8 +86,10 @@ module Hackademy
61
86
  -o "#{config.output_directory}/#{config.draft_name.gsub(/\..*$/,'')}.pdf" \
62
87
  #{config.output_directory}/#{config.transcluded_draft} \
63
88
  }
64
- config.pandoc_variables.each do |key, val|
65
- cmd << %{-V #{key}="#{val}"}
89
+ if config.pandoc_variables.is_a? Hash
90
+ config.pandoc_variables.each do |key, val|
91
+ cmd << %{-V #{key}="#{val}"}
92
+ end
66
93
  end
67
94
  cmd.gsub(/\s+/, ' ')
68
95
  end
@@ -100,7 +127,7 @@ module Hackademy
100
127
  contents.scan(/{{(.*)}}/).flatten.each do |f|
101
128
  original_f = f
102
129
  f = f[config.drafts_dir] ? f.gsub(config.drafts_dir, '') : "#{config.drafts_dir}/#{f}"
103
- Hackademic.new.say "...Including #{f}...", :cyan
130
+ HackademicCLI.new.say "...Including #{f}...", :cyan
104
131
  if File.exists?(f)
105
132
  content = File.open(f).read + "\n"
106
133
  @draft = @draft.gsub("{{#{original_f}}}", content)
@@ -139,7 +166,7 @@ module Hackademy
139
166
  ]
140
167
  end
141
168
 
142
- def config; Hackademy.config; end
169
+ def config; Hackademic.config; end
143
170
  }
144
171
 
145
172
  end
@@ -1,6 +1,4 @@
1
- require_relative 'new'
2
-
3
- module Hackademy
1
+ module Hackademic
4
2
 
5
3
  def self.config;
6
4
  @config ||= Config.new
@@ -1,6 +1,6 @@
1
1
  require 'pathname'
2
2
 
3
- module Hackademy
3
+ module Hackademic
4
4
 
5
5
  class New < Thor
6
6
 
File without changes
@@ -0,0 +1,73 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
3
+ <office:font-face-decls>
4
+ <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
5
+ </office:font-face-decls>
6
+ <office:styles>
7
+ <style:style style:name="Italic" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>
8
+ <style:style style:name="Bold" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
9
+ </office:styles>
10
+
11
+ $automatic-styles$
12
+
13
+ $for(header-includes)$
14
+ $header-includes$
15
+ $endfor$
16
+
17
+ <office:body>
18
+ <office:text>
19
+
20
+ $if(memo)$
21
+
22
+ <text:p text:style-name="Memo header">To:<text:tab/>$to$</text:p>
23
+ <text:p text:style-name="Memo header">From:<text:tab/>$for(author)$$author.name$$if(author.email)$ ($author.email$)$endif$$sep$, $endfor$</text:p>
24
+ <text:p text:style-name="Memo header">Date:<text:tab/>$date$</text:p>
25
+ <text:p text:style-name="Memo header last">Subject:<text:tab/><text:span text:style-name="Bold">$title$</text:span></text:p>
26
+
27
+ $else$
28
+
29
+ $if(published)$
30
+ <text:h text:style-name="Published message">$published$</text:h>
31
+ $endif$
32
+
33
+ $if(title)$
34
+ <text:h text:style-name="Title">$title$</text:h>
35
+ $endif$
36
+
37
+ $if(blinded)$
38
+
39
+ <!-- Blinded by the light -->
40
+
41
+ $else$
42
+
43
+ $for(author)$
44
+ <text:p text:style-name="Author">$author.name$</text:p>
45
+ <text:p text:style-name="Affiliation">$author.affiliation$</text:p>
46
+ <text:p text:style-name="Email">$author.email$</text:p>
47
+ $endfor$
48
+
49
+ $endif$
50
+
51
+ $if(date)$
52
+ <text:p text:style-name="Date">$date$</text:p>
53
+ $endif$
54
+
55
+ $if(abstract)$
56
+ <text:p text:style-name="Abstract"><text:span text:style-name="Bold">Abstract:</text:span> $abstract$</text:p>
57
+ $endif$
58
+
59
+ $endif$
60
+
61
+ $for(include-before)$
62
+ $include-before$
63
+ $endfor$
64
+
65
+ $body$
66
+
67
+ $for(include-after)$
68
+ $include-after$
69
+ $endfor$
70
+
71
+ </office:text>
72
+ </office:body>
73
+ </office:document-content>
@@ -0,0 +1,17 @@
1
+ ---
2
+ hackademic:
3
+ bibliography: Resources/References.bib
4
+ drafts_dir: "_WORKING_"
5
+ draft_name: DRAFT.md
6
+ pandoc:
7
+ variables:
8
+ date: <%= Time.now.strftime("%m/%d/%Y") %>
9
+ transcluded_draft: DRAFT-COMPLETE.md
10
+ output_directory: Versions
11
+ citation_style: Resources/csl/american-sociological-association.csl
12
+ docx_template: Resource/templates/pandoc-word-template.docx
13
+ latex_template: Resources/templates/xelatex.template
14
+ html_template: Resources/templates/default.html5
15
+ pdf_template: Resources/templates/default.html5
16
+ support_directory: Resources
17
+ libre_office_binary: /Applications/LibreOffice.app/Contents/MacOS/soffice
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackademic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Petty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Hackademic manages your plain-text academic workflow.
14
14
  email: matt@kizmeta.com
@@ -25,10 +25,11 @@ files:
25
25
  - bin/hackademic
26
26
  - hackademic.gemspec
27
27
  - lib/hackademic.rb
28
- - lib/hackademy/compile.rb
29
- - lib/hackademy/hackademy.rb
30
- - lib/hackademy/new.rb
31
- - lib/hackademy/sync.rb
28
+ - lib/hackademic/.compile.rb.swp
29
+ - lib/hackademic/compile.rb
30
+ - lib/hackademic/config.rb
31
+ - lib/hackademic/new.rb
32
+ - lib/hackademic/sync.rb
32
33
  - templates/CHANGELOG.md.tt
33
34
  - templates/Config.yml.tt
34
35
  - templates/DRAFT.md.tt
@@ -38,8 +39,10 @@ files:
38
39
  - templates/default.asciidoc
39
40
  - templates/default.html5
40
41
  - templates/default.latex
42
+ - templates/default.odt
41
43
  - templates/pandoc-word-template.docx
42
44
  - templates/xelatex.template
45
+ - test/Resources/Config.yml
43
46
  homepage: http://github.com/kizmeta/hackademic
44
47
  licenses:
45
48
  - MIT