wax_tasks 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/lunr.rb ADDED
@@ -0,0 +1,24 @@
1
+ # lunr task specs
2
+ describe 'wax:lunr' do
3
+ it 'constructs an index object' do
4
+ idx = quiet_stdout { Index.new }
5
+ expect { idx.collections.all? }
6
+ end
7
+ it 'passes when invoked' do
8
+ passes = quiet_stdout { system('bundle exec rake wax:lunr') }
9
+ expect(passes).to eq(true)
10
+ end
11
+ it 'writes a lunr index' do
12
+ index = File.open('./js/lunr-index.json', 'r').read
13
+ expect(index.length).to be > 1000
14
+ end
15
+ it 'generates a lunr ui' do
16
+ ui = File.open('./js/lunr-ui.js', 'r').read
17
+ expect(ui.length).to be > 100
18
+ end
19
+ context 'when a ui already exists' do
20
+ it 'skips over it' do
21
+ expect { Index.new.write }.to output(/.*Skipping.*/).to_stdout
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ # pagemaster task specs
2
+ describe 'wax:pagemaster' do
3
+ it 'constructs pagemaster collections' do
4
+ expect { PM_COLLECTIONS.all? }
5
+ end
6
+ context 'when invoked as a task' do
7
+ it 'passes' do
8
+ passes = quiet_stdout { system("bundle exec rake wax:pagemaster #{ARGS.join ' '}") }
9
+ expect(passes).to eq(true)
10
+ end
11
+ it 'generates pages to the correct directories' do
12
+ PM_COLLECTIONS.each do |c|
13
+ pages = Dir.glob("#{c.page_dir}/*.md")
14
+ expect(pages.length).to be > 0
15
+ Fake.content(pages) # add content to pages to test lunr indexing
16
+ end
17
+ end
18
+ end
19
+ context 'when processed directly' do
20
+ it 'still passes' do
21
+ FileUtils.rm_r "./collections/_#{ARGS.first}"
22
+ expect { quiet_stdout { PM_COLLECTIONS.first.generate_pages } }.not_to raise_error
23
+ end
24
+ end
25
+ context 'when given a collection arg not in config' do
26
+ it 'throws a configuration error' do
27
+ expect { quiet_stdout { PagemasterCollection.new('not_a_collection') } }.to raise_error(SystemExit)
28
+ end
29
+ end
30
+ context 'when trying to genrate pages that already exist' do
31
+ it 'skips them' do
32
+ expect { PM_COLLECTIONS.first.generate_pages }.to output(/.*Skipping.*/).to_stdout
33
+ end
34
+ end
35
+ context 'when given a bad config' do
36
+ it 'throws a key error' do
37
+ opts = { site_config: {} }
38
+ expect { PagemasterCollection.new(ARGS.first, opts) }.to raise_error(KeyError)
39
+ end
40
+ end
41
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,130 +1,40 @@
1
- require 'simplecov'
2
- SimpleCov.start
3
-
4
- require_relative 'fake/data'
5
- require_relative 'fake/site'
6
-
7
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
8
- require 'wax_tasks'
9
-
10
- silence_output do
11
- Fake.site
12
- Fake.data
13
- end
14
-
15
- site_config = WaxTasks.site_config
16
- bad_src_config = {
17
- 'collections' => {
18
- 'test' => {
19
- 'source' => 'test.jpg'
20
- }
21
- }
22
- }
23
- missing_src_config = {
24
- 'collections' => {
25
- 'test' => {
26
- 'source' => 'test.csv'
27
- }
28
- }
29
- }
1
+ # toggle stdout/stderr verbosity
2
+ QUIET = true
30
3
 
31
- describe 'wax:pagemaster' do
32
- args = site_config['collections'].map { |c| c[0] }
33
- args.each do |collection_name|
34
- silence_output { WaxTasks.pagemaster(collection_name, site_config) }
35
- end
36
- it 'generates pages to the correct directories' do
37
- args.each do |a|
38
- dir = Pagemaster.target_dir(a, site_config)
39
- pages = Dir.glob("#{dir}/*.md")
40
- expect(pages.length).to be > 0
41
- Fake.content(pages)
42
- end
43
- end
44
- context 'when given a collection arg not in config' do
45
- collection_name = 'not_a_collection'
46
- it 'throws a configuration error' do
47
- expect { silence_output { WaxTasks.pagemaster(collection_name, site_config) } }.to raise_error(SystemExit)
48
- end
49
- end
50
- context 'when given config with bad source' do
51
- collection_name = bad_src_config['collections'].first[0]
52
- it 'throws ingest error' do
53
- expect { silence_output { WaxTasks.pagemaster(collection_name, bad_src_config) } }.to raise_error(SystemExit)
54
- end
55
- end
56
- context 'when given config with missing source' do
57
- collection_name = missing_src_config['collections'].first[0]
58
- it 'throws io error' do
59
- expect { silence_output { WaxTasks.pagemaster(collection_name, missing_src_config) } }.to raise_error(SystemExit)
60
- end
61
- end
62
- context 'when trying to genrate pages that already exist' do
63
- it 'skips them' do
64
- expect { WaxTasks.pagemaster(args.first, site_config) }.to output(/.*Skipping.*/).to_stdout
65
- end
66
- end
4
+ # use codecov + add requirements
5
+ require 'simplecov'
6
+ SimpleCov.start do
7
+ add_filter 'spec'
8
+ add_filter 'utilities'
9
+ add_filter 'branch'
67
10
  end
68
11
 
69
- describe 'wax:lunr' do
70
- silence_output { WaxTasks.lunr(site_config) }
71
- it 'generates a lunr index' do
72
- index = File.open('./js/lunr-index.json', 'r').read
73
- expect(index.length).to be > 1000
74
- end
75
- it 'generates a lunr ui' do
76
- ui = File.open('./js/lunr-ui.js', 'r').read
77
- expect(ui.length).to be > 100
78
- end
79
- context 'when a ui already exists' do
80
- it 'skips over it' do
81
- expect { WaxTasks.lunr(site_config) }.to output(/.*Skipping.*/).to_stdout
82
- end
83
- end
84
- end
12
+ require_relative './../lib/wax_tasks'
13
+ require_relative 'fake/site'
85
14
 
86
- describe 'wax:iiif' do
87
- collection_name = site_config['collections'].first[0]
88
- images = Dir.glob('./_data/iiif/*.jpg')
89
- iiif_src_dir = "./_data/iiif/#{collection_name}"
15
+ # setup
16
+ quiet_stdout { Fake.site }
90
17
 
91
- FileUtils.mkdir_p(iiif_src_dir)
92
- images.each { |f| FileUtils.cp(File.expand_path(f), iiif_src_dir) }
93
- silence_output { WaxTasks.iiif(collection_name, site_config) }
18
+ # constants
19
+ SITE_CONFIG = WaxTasks.site_config
20
+ ARGS = SITE_CONFIG[:collections].map { |c| c[0] }
21
+ PM_COLLECTIONS = quiet_stdout { ARGS.map { |a| PagemasterCollection.new(a) } }
22
+ IIIF_COLLECTIONS = ARGS.map { |a| IiifCollection.new(a) }
94
23
 
95
- it 'generates collections' do
96
- expect(File.exist?("./iiif/#{collection_name}/collection/top.json")).to be true
97
- end
98
- it 'generates manifests' do
99
- expect(File.exist?("./iiif/#{collection_name}/1/manifest.json")).to be true
100
- end
101
- it 'generates derivatives' do
102
- expect(Dir.exist?("./iiif/#{collection_name}/images")).to be true
103
- end
104
- it 'generates image variants' do
105
- [250, 600, 1140].each do |size|
106
- expect(File.exist?("./iiif/#{collection_name}/images/1-1/full/#{size},/0/default.jpg")).to be true
107
- end
108
- end
109
- context 'when looking for a missing dir' do
110
- it 'throws an io error' do
111
- collection_name = 'not_a_collection'
112
- expect { silence_output { WaxTasks.iiif(collection_name, site_config) } }.to raise_error(SystemExit)
113
- end
114
- end
115
- end
24
+ # run specs
25
+ require_relative 'pagemaster'
26
+ require_relative 'lunr'
27
+ require_relative 'iiif'
116
28
 
117
29
  describe 'jekyll' do
118
30
  it 'builds successfully' do
119
- silence_output { Bundler.with_clean_env { system('bundle exec jekyll build') } }
31
+ quiet_stdout { Bundler.with_clean_env { system('bundle exec jekyll build') } }
120
32
  end
121
33
  end
122
34
 
123
35
  describe 'wax:jspackage' do
124
- before(:all) do
125
- silence_output { system('bundle exec rake wax:jspackage') }
126
- end
127
36
  it 'writes a package.json file' do
37
+ quiet_stdout { system('bundle exec rake wax:jspackage') }
128
38
  package = File.open('package.json', 'r').read
129
39
  expect(package.length > 90)
130
40
  end
@@ -132,6 +42,6 @@ end
132
42
 
133
43
  describe 'wax:test' do
134
44
  it 'passes html-proofer' do
135
- silence_output { system('bundle exec rake wax:test') }
45
+ quiet_stdout { system('bundle exec rake wax:test') }
136
46
  end
137
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wax_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marii Nyrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0.5'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0.5'
139
125
  description: Rake tasks for minimal iiif exhibition sites with Jekyll.
140
126
  email:
141
127
  - m.nyrop@columbia.edu
@@ -144,17 +130,23 @@ extensions: []
144
130
  extra_rdoc_files: []
145
131
  files:
146
132
  - Gemfile
147
- - lib/modules/iiif.rb
148
- - lib/modules/lunr.rb
149
- - lib/modules/pagemaster.rb
150
- - lib/tasks/iiif.rake
151
- - lib/tasks/jspackage.rake
152
- - lib/tasks/lunr.rake
153
- - lib/tasks/pagemaster.rake
154
- - lib/tasks/push_gh.rake
155
- - lib/tasks/push_static.rake
156
- - lib/tasks/test.rake
133
+ - lib/wax/branch.rb
134
+ - lib/wax/collection.rb
135
+ - lib/wax/iiif_collection.rb
136
+ - lib/wax/index.rb
137
+ - lib/wax/lunr_collection.rb
138
+ - lib/wax/pagemaster_collection.rb
139
+ - lib/wax/tasks/iiif.rake
140
+ - lib/wax/tasks/jspackage.rake
141
+ - lib/wax/tasks/lunr.rake
142
+ - lib/wax/tasks/pagemaster.rake
143
+ - lib/wax/tasks/push.rake
144
+ - lib/wax/tasks/test.rake
145
+ - lib/wax/utilities.rb
157
146
  - lib/wax_tasks.rb
147
+ - spec/iiif.rb
148
+ - spec/lunr.rb
149
+ - spec/pagemaster.rb
158
150
  - spec/spec_helper.rb
159
151
  homepage: https://github.com/minicomp/wax_tasks
160
152
  licenses:
@@ -183,3 +175,6 @@ specification_version: 4
183
175
  summary: Rake tasks for minimal exhibitions.
184
176
  test_files:
185
177
  - spec/spec_helper.rb
178
+ - spec/iiif.rb
179
+ - spec/pagemaster.rb
180
+ - spec/lunr.rb
data/lib/modules/iiif.rb DELETED
@@ -1,39 +0,0 @@
1
- require 'colorized_string'
2
- require 'json'
3
- require 'wax_iiif'
4
-
5
- # module for generating IIIF derivatives + json from local images
6
- module Iiif
7
- def self.process(name, site_config)
8
- inpath = "./_data/iiif/#{name}"
9
- unless Dir.exist?(inpath)
10
- abort "Source path '#{inpath}' does not exist. Exiting.".magenta
11
- end
12
- FileUtils.mkdir_p("./iiif/#{name}", verbose: false)
13
- build_opts = {
14
- base_url: "#{site_config['baseurl']}/iiif/#{name}",
15
- output_dir: "./iiif/#{name}",
16
- verbose: true,
17
- variants: { med: 600, lg: 1140 }
18
- }
19
- builder = IiifS3::Builder.new(build_opts)
20
- builder.load(make_records(name, inpath))
21
- builder.process_data(true)
22
- end
23
-
24
- def self.make_records(name, inpath)
25
- counter = 1
26
- records = []
27
- Dir["#{inpath}/*"].sort!.each do |imagefile|
28
- basename = File.basename(imagefile, '.*').to_s
29
- record_opts = {
30
- id: basename,
31
- path: imagefile,
32
- label: "#{name} #{basename}"
33
- }
34
- counter += 1
35
- records << IiifS3::ImageRecord.new(record_opts)
36
- end
37
- records
38
- end
39
- end
data/lib/modules/lunr.rb DELETED
@@ -1,123 +0,0 @@
1
- require 'colorized_string'
2
- require 'json'
3
-
4
- # module for generating elasticlunr index and default jquery ui
5
- module Lunr
6
- def self.write_index(site_config)
7
- index = index(site_config)
8
- FileUtils.mkdir_p('js')
9
- index = "---\nlayout: none\n---\n" + index
10
- path = 'js/lunr-index.json'
11
- File.open(path, 'w') { |file| file.write(index) }
12
- puts "Writing lunr index to #{path}".cyan
13
- end
14
-
15
- def self.index(site_config)
16
- collections = collections_to_index(site_config)
17
- collections_dir = site_config['collections_dir'].to_s
18
-
19
- index = []
20
- count = 0
21
-
22
- collections.each do |collection|
23
- dir = "_#{collection[:name]}"
24
- dir.prepend("#{collections_dir}/") unless collections_dir.empty?
25
- pages = Dir.glob(dir + '/*.md')
26
- get_content = collection[:lunr_index].key?('content') ? collection[:lunr_index]['content'] : false
27
- fields = collection[:lunr_index]['fields']
28
- # catch
29
- abort "There are no pages in '#{dir}'".magenta if pages.empty?
30
- abort "There are no fields for #{collection.name}.".magenta if fields.empty?
31
- puts "Loading #{pages.length} pages from #{dir}"
32
- # index each page in collection
33
- pages.each do |page|
34
- index << page_hash(page, fields, get_content, count)
35
- count += 1
36
- end
37
- end
38
- JSON.pretty_generate(index)
39
- end
40
-
41
- def self.write_ui(site_config)
42
- ui_str = ui(site_config)
43
- ui = "---\nlayout: none\n---\n" + ui_str
44
- path = 'js/lunr-ui.js'
45
- if File.exist?(path)
46
- puts "Lunr UI already exists at #{path}. Skipping".cyan
47
- else
48
- File.open(path, 'w') { |file| file.write(ui) }
49
- puts "Writing lunr ui to #{path}".cyan
50
- end
51
- end
52
-
53
- def self.ui(site_config)
54
- # set up index
55
- ui = "$.getJSON(\"{{ site.baseurl }}/js/lunr-index.json\", function(index_json) {\nwindow.index = new elasticlunr.Index;\nwindow.store = index_json;\nindex.saveDocument(false);\nindex.setRef('lunr_id');"
56
- # add fields to index
57
- total_fields = total_fields(site_config)
58
- total_fields.each { |field| ui += "\nindex.addField('#{field}');" }
59
- # add docs
60
- ui += "\n// add docs\nfor (i in store){index.addDoc(store[i]);}"
61
- # gui
62
- ui += "\n$('input#search').on('keyup', function() {\nvar results_div = $('#results');\nvar query = $(this).val();\nvar results = index.search(query, { boolean: 'AND', expand: true });\nresults_div.empty();\nif (results.length > 10) {\nresults_div.prepend(\"<p><small>Displaying 10 of \" + results.length + \" results.</small></p>\");\n}\nfor (var r in results.slice(0, 9)) {\nvar ref = results[r].ref;\nvar item = store[ref];"
63
- # add fields as display vars
64
- total_fields.each { |field| ui += "var #{field} = item.#{field};\n" }
65
- ui += "var result = '<div class=\"result\"><b><a href=\"' + item.link + '\">' + title + '</a></b></p></div>';\nresults_div.append(result);\n}\n});\n});"
66
- ui
67
- end
68
-
69
- def self.collections_to_index(site_config)
70
- to_index = site_config['collections'].find_all { |c| c[1].key?('lunr_index') }
71
- to_index.map! { |c| c[0] }
72
- abort 'There are no valid collections to index.'.magenta if to_index.nil?
73
- collections = []
74
- to_index.each do |c|
75
- collections << WaxTasks.collection(c, site_config)
76
- end
77
- collections
78
- end
79
-
80
- def self.total_fields(site_config)
81
- total_fields = ['pid']
82
- site_config['collections'].each do |c|
83
- if c[1].key?('lunr_index') && c[1]['lunr_index'].key?('fields')
84
- total_fields = total_fields.concat(c[1]['lunr_index']['fields'])
85
- total_fields << 'content' if c[1]['lunr_index']['content']
86
- end
87
- end
88
- total_fields.uniq
89
- end
90
-
91
- def self.page_hash(page, fields, get_content, count)
92
- yaml = YAML.load_file(page)
93
- hash = {
94
- 'lunr_id' => count,
95
- 'link' => "{{'" + yaml.fetch('permalink') + "' | relative_url }}",
96
- 'collection' => yaml.fetch('permalink').to_s[%r{^\/([^\/]*)\/}].tr('/', '')
97
- }
98
- fields.each { |f| hash[f] = rm_diacritics(thing2string(yaml[f])) }
99
- hash['content'] = rm_diacritics(clean(File.read(page))) if get_content
100
- hash
101
- end
102
-
103
- def self.clean(str)
104
- str.gsub!(/\A---(.|\n)*?---/, '') # remove yaml front matter
105
- str.gsub!(/{%(.*)%}/, '') # remove functional liquid
106
- str.gsub!(%r{<\/?[^>]*>}, '') # remove html
107
- str.gsub!('\\n', '') # remove newlines
108
- str.gsub!(/\s+/, ' ') # remove extra space
109
- str.tr!('"', "'") # replace double quotes with single
110
- str
111
- end
112
-
113
- def self.rm_diacritics(str)
114
- to_replace = 'ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž'
115
- replaced_by = 'AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz'
116
- str.tr(to_replace, replaced_by)
117
- end
118
-
119
- def self.thing2string(thing)
120
- thing = thing.join(' || ') if thing.is_a?(Array)
121
- thing.to_s
122
- end
123
- end
@@ -1,73 +0,0 @@
1
- require 'colorized_string'
2
- require 'csv'
3
- require 'fileutils'
4
- require 'json'
5
- require 'yaml'
6
-
7
- # module for generating markdown collection pages from csv/json/yaml records
8
- module Pagemaster
9
- def self.generate(collection, site_config)
10
- records = ingest(collection[:source])
11
- dir = target_dir(collection[:name], site_config)
12
- permalink_style = WaxTasks.permalink_style(site_config)
13
-
14
- completed = 0
15
- skipped = 0
16
-
17
- records.each_with_index do |item, index|
18
- pagename = WaxTasks.slug(item.fetch('pid'))
19
- pagepath = dir + '/' + pagename + '.md'
20
- if File.exist?(pagepath)
21
- puts "#{pagename}.md already exits. Skipping."
22
- skipped += 1
23
- else
24
- item['permalink'] = '/' + collection[:name] + '/' + pagename + permalink_style
25
- item['layout'] = collection[:layout]
26
- item['order'] = padded_int(index, records.length) if collection[:keep_order]
27
- File.open(pagepath, 'w') { |f| f.write(item.to_yaml.to_s + '---') }
28
- completed += 1
29
- end
30
- end
31
-
32
- puts "\n#{completed} pages were generated to #{dir} directory.".cyan
33
- puts "\n#{skipped} pre-existing items were skipped.".cyan
34
- rescue StandardError => e
35
- abort "Failure after #{completed} pages, likely from missing pid.".magenta + "\n#{e}"
36
- end
37
-
38
- def self.ingest(source)
39
- src = "_data/#{source}"
40
- opts = { headers: true, encoding: 'utf-8' }
41
-
42
- case File.extname(src)
43
- when '.csv' then data = CSV.read(src, opts).map(&:to_hash)
44
- when '.json' then data = JSON.parse(File.read(src))
45
- when '.yml' then data = YAML.load_file(src)
46
- else abort "Source #{src} must be .csv, .json, or .yml.".magenta
47
- end
48
-
49
- puts "Processing #{src}...."
50
- validate(data)
51
- rescue StandardError => e
52
- abort "Cannot load #{src}. check for typos and rebuild.".magenta + "\n#{e}"
53
- end
54
-
55
- def self.padded_int(index, max_idx)
56
- index.to_s.rjust(Math.log10(max_idx).to_i + 1, '0')
57
- end
58
-
59
- def self.validate(data)
60
- pids = data.map { |d| d['pid'] }
61
- duplicates = pids.detect { |p| pids.count(p) > 1 } || []
62
- abort "Fix duplicate pids: \n#{duplicates}".magenta unless duplicates.empty?
63
- data
64
- end
65
-
66
- def self.target_dir(collection_name, site_config)
67
- collections_dir = site_config['collections_dir'].to_s
68
- dir = collections_dir.empty? ? '_' : collections_dir + '/_'
69
- dir += collection_name
70
- FileUtils.mkdir_p(dir)
71
- dir
72
- end
73
- end
data/lib/tasks/iiif.rake DELETED
@@ -1,11 +0,0 @@
1
- require 'colorized_string'
2
- require 'wax_tasks'
3
-
4
- namespace :wax do
5
- task :iiif do
6
- args = ARGV.drop(1).each { |a| task a.to_sym }
7
- abort "Please specify a collections after 'wax:iiif'".magenta if args.empty?
8
- site_config = WaxTasks.site_config
9
- args.each { |collection_name| WaxTasks.iiif(collection_name, site_config) }
10
- end
11
- end
@@ -1,26 +0,0 @@
1
- require 'colorized_string'
2
- require 'json'
3
-
4
- require 'wax_tasks'
5
-
6
- namespace :wax do
7
- desc 'write a simple package.json'
8
- task :jspackage do
9
- site_config = WaxTasks.site_config
10
- package = {
11
- 'name' => site_config['title'],
12
- 'version' => '1.0.0',
13
- 'description' => site_config['description'],
14
- 'dependencies' => {}
15
- }
16
- names = []
17
- site_config['js'].each do |dependency|
18
- name = dependency[0]
19
- names << name
20
- version = dependency[1]['version']
21
- package['dependencies'][name] = '^' + version
22
- end
23
- File.open('package.json', 'w') { |file| file.write(package.to_json) }
24
- puts "Writing #{names} to simple package.json.".cyan
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- require 'colorized_string'
2
- require 'wax_tasks'
3
-
4
- namespace :wax do
5
- desc 'generate collection md pages from yaml or csv data source'
6
- task :pagemaster do
7
- args = ARGV.drop(1).each { |a| task a.to_sym }
8
- abort "Please specify a collection after 'wax:pagemaster'".magenta if args.empty?
9
- args.each do |collection_name|
10
- site_config = WaxTasks.site_config
11
- WaxTasks.pagemaster(collection_name, site_config)
12
- end
13
- end
14
- end
@@ -1,43 +0,0 @@
1
- require 'colorized_string'
2
- require 'jekyll'
3
- require 'wax_tasks'
4
-
5
- namespace :wax do
6
- namespace :push do
7
- desc 'build site with gh-baseurl and push to gh-pages branch'
8
- task :gh do
9
- if ENV['CI']
10
- REPO_SLUG = ENV['TRAVIS_REPO_SLUG']
11
- USER = REPO_SLUG.split('/')[0]
12
- REPO_NAME = '1' + REPO_SLUG.split('/')[1]
13
- TOKEN = ENV['ACCESS_TOKEN']
14
- COMMIT_MSG = "Site updated via #{ENV['TRAVIS_COMMIT']}".freeze
15
- ORIGIN = "https://#{USER}:#{TOKEN}@github.com/#{REPO_SLUG}.git".freeze
16
- puts "Deploying to gh-oages branch from Travis as #{USER}"
17
- else
18
- ORIGIN = `git config --get remote.origin.url`.freeze
19
- COMMIT_MSG = "Site updated at #{Time.now.utc}".freeze
20
- puts 'Deploying to gh-pages branch from local task'
21
- end
22
- config = WaxTasks.site_config
23
- FileUtils.rm_rf('_site')
24
-
25
- opts = {
26
- 'source' => '.',
27
- 'destination' => '_site',
28
- 'config' => '_config.yml',
29
- 'baseurl' => config['gh-baseurl'] || REPO_NAME.to_s
30
- }
31
-
32
- Jekyll::Site.new(Jekyll.configuration(opts)).process
33
- Dir.mktmpdir do |tmp|
34
- FileUtils.cp_r '_site/.', tmp
35
- Dir.chdir tmp
36
- system 'git init'
37
- system "git add . && git commit -m '#{COMMIT_MSG}'"
38
- system "git remote add origin #{ORIGIN}"
39
- system 'git push origin master:refs/heads/gh-pages --force'
40
- end
41
- end
42
- end
43
- end
@@ -1,35 +0,0 @@
1
- require 'wax_tasks'
2
-
3
- namespace :wax do
4
- namespace :push do
5
- desc 'push built site to s3 branch'
6
- task :static do
7
- if ENV['CI']
8
- puts "Build type=#{ENV['TRAVIS_EVENT_TYPE']}"
9
- unless ENV['TRAVIS_BRANCH'] == 'master'
10
- puts "Skipping deploy from branch #{ENV['TRAVIS_BRANCH']}"
11
- next
12
- end
13
- REPO_SLUG = ENV['TRAVIS_REPO_SLUG']
14
- USER = REPO_SLUG.split('/')[0]
15
- TOKEN = ENV['ACCESS_TOKEN']
16
- COMMIT_MSG = "Site updated via #{ENV['TRAVIS_COMMIT']}".freeze
17
- ORIGIN = "https://#{USER}:#{TOKEN}@github.com/#{REPO_SLUG}.git".freeze
18
- puts "Deploying to s3 branch from Travis as #{USER}"
19
- else
20
- ORIGIN = `git config --get remote.origin.url`.freeze
21
- COMMIT_MSG = "Site updated at #{Time.now.utc}".freeze
22
- puts 'Deploying to s3 branch from local task'
23
- end
24
-
25
- Dir.mktmpdir do |tmp|
26
- FileUtils.cp_r '_site/.', tmp
27
- Dir.chdir tmp
28
- system 'git init'
29
- system "git add . && git commit -m '#{COMMIT_MSG}'"
30
- system "git remote add origin #{ORIGIN}"
31
- system 'git push origin master:refs/heads/s3 --force'
32
- end
33
- end
34
- end
35
- end