skypager 0.1.2 → 0.2.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 +4 -4
- data/Rakefile +0 -11
- data/bin/skypager +16 -10
- data/lib/skypager.rb +1 -69
- data/lib/skypager/cli.rb +14 -0
- data/lib/skypager/cli/01_extensions.rb +25 -0
- data/lib/skypager/cli/config.rb +41 -0
- data/lib/skypager/proxy.rb +0 -10
- data/lib/skypager/version.rb +1 -1
- data/skypager.gemspec +1 -15
- metadata +9 -216
- data/ARCHITECTURE.md +0 -34
- data/CONTRIBUTING.md +0 -7
- data/LICENSE.txt +0 -22
- data/bin/bootstrap.sh +0 -29
- data/examples/.gitignore +0 -4
- data/examples/blog-site/.gitignore +0 -18
- data/examples/blog-site/.pryrc +0 -4
- data/examples/blog-site/Gemfile +0 -8
- data/examples/blog-site/config.rb +0 -17
- data/examples/blog-site/data/dropbox.json +0 -1
- data/examples/blog-site/source/images/background.png +0 -0
- data/examples/blog-site/source/images/middleman.png +0 -0
- data/examples/blog-site/source/index.html.erb +0 -10
- data/examples/blog-site/source/javascripts/all.js +0 -1
- data/examples/blog-site/source/layouts/layout.erb +0 -19
- data/examples/blog-site/source/posts/introduction-to-skypager.html.md +0 -23
- data/examples/blog-site/source/posts/skypager-and-dnsimple-and-amazon-web-services-combo.html.md +0 -9
- data/examples/blog-site/source/stylesheets/all.css +0 -55
- data/examples/blog-site/source/stylesheets/normalize.css +0 -375
- data/examples/gallery-site/.gitignore +0 -18
- data/examples/gallery-site/.pryrc +0 -4
- data/examples/gallery-site/Gemfile +0 -11
- data/examples/gallery-site/config.rb +0 -38
- data/examples/gallery-site/data/dropbox.json +0 -1
- data/examples/gallery-site/data/galleries.json +0 -1
- data/examples/gallery-site/source/gallery.html.erb +0 -7
- data/examples/gallery-site/source/images/background.png +0 -0
- data/examples/gallery-site/source/images/galleries/cristian-gallery-1/001.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/cristian-gallery-1/002.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/cristian-gallery-1/003.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/cristian-gallery-1/004.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/luca-gallery-1/001.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/luca-gallery-1/002.JPG +0 -0
- data/examples/gallery-site/source/images/galleries/luca-gallery-1/003.jpg +0 -0
- data/examples/gallery-site/source/images/galleries/luca-gallery-1/004.JPG +0 -0
- data/examples/gallery-site/source/images/middleman.png +0 -0
- data/examples/gallery-site/source/index.html.erb +0 -10
- data/examples/gallery-site/source/javascripts/all.js +0 -1
- data/examples/gallery-site/source/layouts/layout.erb +0 -20
- data/examples/gallery-site/source/stylesheets/all.css +0 -0
- data/examples/gallery-site/source/stylesheets/normalize.css +0 -375
- data/examples/gallery-site/source/tutorial.md +0 -151
- data/lib/skypager/builder.rb +0 -158
- data/lib/skypager/cli/commands/build.rb +0 -64
- data/lib/skypager/cli/commands/config.rb +0 -58
- data/lib/skypager/cli/commands/create.rb +0 -98
- data/lib/skypager/cli/commands/deploy.rb +0 -62
- data/lib/skypager/cli/commands/edit.rb +0 -32
- data/lib/skypager/cli/commands/list.rb +0 -12
- data/lib/skypager/cli/commands/setup.rb +0 -153
- data/lib/skypager/cli/commands/site.rb +0 -22
- data/lib/skypager/cli/commands/sync.rb +0 -20
- data/lib/skypager/data.rb +0 -8
- data/lib/skypager/data/excel_spreadsheet.rb +0 -8
- data/lib/skypager/data/google_spreadsheet.rb +0 -227
- data/lib/skypager/data/request.rb +0 -12
- data/lib/skypager/data/source.rb +0 -194
- data/lib/skypager/data/source_routes_proxy.rb +0 -30
- data/lib/skypager/dns.rb +0 -69
- data/lib/skypager/extension.rb +0 -271
- data/lib/skypager/middleman/commands/data.rb +0 -0
- data/lib/skypager/middleman/commands/deploy.rb +0 -0
- data/lib/skypager/middleman/commands/sync.rb +0 -0
- data/lib/skypager/sync.rb +0 -23
- data/lib/skypager/sync/amazon.rb +0 -181
- data/lib/skypager/sync/dropbox.rb +0 -173
- data/lib/skypager/sync/dropbox/delta.rb +0 -67
- data/lib/skypager/sync/folder.rb +0 -266
- data/lib/skypager/sync/github.rb +0 -55
- data/lib/skypager/sync/google.rb +0 -143
- data/spec/dummy/site-one/.gitignore +0 -18
- data/spec/dummy/site-one/Gemfile +0 -14
- data/spec/dummy/site-one/config.rb +0 -13
- data/spec/dummy/site-one/source/images/background.png +0 -0
- data/spec/dummy/site-one/source/images/middleman.png +0 -0
- data/spec/dummy/site-one/source/index.html.erb +0 -10
- data/spec/dummy/site-one/source/javascripts/all.js +0 -1
- data/spec/dummy/site-one/source/layouts/layout.erb +0 -19
- data/spec/dummy/site-one/source/stylesheets/all.css +0 -55
- data/spec/dummy/site-one/source/stylesheets/normalize.css +0 -375
- data/spec/lib/skypager/builder/server_spec.rb +0 -5
- data/spec/lib/skypager/configuration_spec.rb +0 -12
- data/spec/lib/skypager/data_spec.rb +0 -5
- data/spec/lib/skypager/site_spec.rb +0 -44
- data/spec/lib/skypager_spec.rb +0 -9
- data/spec/skypager-test-config.rb.example +0 -22
- data/spec/spec_helper.rb +0 -49
- data/spec/support/fixtures/cwd_config.json +0 -3
- data/spec/support/fixtures/home_config.json +0 -1
- data/spec/support/json_helper.rb +0 -7
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# Using the skypager gem to build dynamic, data driven sites with middleman
|
|
2
|
-
|
|
3
|
-
Skypager takes an already powerful website creation tool 'Middleman' and adds a few key integrations
|
|
4
|
-
with services like Dropbox and Google Drive / Google Documents, as well as Amazon S3, Cloudfront, and DNSimple.
|
|
5
|
-
|
|
6
|
-
This automates a ton of boring setup chores and allows designers and developers to crank out dynamic, data driven websites
|
|
7
|
-
without having to worry too much about servers. And since these websites are all technically 'static', and backed by a global CDN,
|
|
8
|
-
Skypager websites will be fast as hell.
|
|
9
|
-
|
|
10
|
-
The skypager gem is open source. If you want to automate your builds and releases every time files change on Dropbox or any time data changes in a Google Spreadsheet, you
|
|
11
|
-
can either run the skypager build server on your own server or you can sign up on skypager.io and we will set all of that up for you as well.
|
|
12
|
-
|
|
13
|
-
## Using the skypager gem in your own projecs
|
|
14
|
-
|
|
15
|
-
In this tutorial, we are going to use the skypager gem and the skypager middleman extension to build a photo gallery website.
|
|
16
|
-
|
|
17
|
-
The information about our photo galleries is going to be stored in a google spreadsheet. The photo galleries themselves, are going to be stored on Dropbox.
|
|
18
|
-
|
|
19
|
-
- 1) create a new middleman project
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
middleman init
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
- 2) add the skypager gem, and activate it in your config.rb
|
|
26
|
-
|
|
27
|
-
```ruby
|
|
28
|
-
# Gemfile
|
|
29
|
-
|
|
30
|
-
gem 'skypager', github: "architects/skypager", branch: "master"
|
|
31
|
-
|
|
32
|
-
# config.rb
|
|
33
|
-
|
|
34
|
-
activate :skypager
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
- 3) setup the google drive and dropbox integrations. this requires you
|
|
38
|
-
to create applications in the respective developer consoles for google
|
|
39
|
-
and dropbox
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
alias be='bundle exec'
|
|
43
|
-
be skypager setup
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
- 4) once your applications are setup, you can create a google
|
|
47
|
-
spreadsheet datasource. the spreadsheet data source will be used to
|
|
48
|
-
generate dynamic pages and content to be displayed with our html
|
|
49
|
-
templates
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
be skypager create datasource galleries
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
follow the prompts, selecting 'google spreadsheet' and enter in
|
|
56
|
-
some fields for this data source.
|
|
57
|
-
|
|
58
|
-
for this example we will use:
|
|
59
|
-
|
|
60
|
-
`title description cover_image status release_date`
|
|
61
|
-
|
|
62
|
-
this will end up creating the following line in our `config.rb`
|
|
63
|
-
|
|
64
|
-
```ruby
|
|
65
|
-
# config.rb
|
|
66
|
-
|
|
67
|
-
data_source :galleries, :type => "google", :key => "..."
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
- 5) in order to get pretty urls from our data source, we are going to
|
|
71
|
-
configure the data source to make 'slugs' out of the title column.
|
|
72
|
-
|
|
73
|
-
edit the config.rb file:
|
|
74
|
-
|
|
75
|
-
```ruby
|
|
76
|
-
# config.rb
|
|
77
|
-
|
|
78
|
-
data_source :galleries, :type => "google", :key => "...", :slug_column => 'title'
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
- 6) with this done, we will now have access to the galleries data
|
|
82
|
-
source from within any template, or from within the `config.rb` file
|
|
83
|
-
itself which means we can use the data source to generate dynamic
|
|
84
|
-
urls such as: `/galleries/my-gallery-title` which will display the
|
|
85
|
-
info in the spreasheet.
|
|
86
|
-
|
|
87
|
-
- 7) let's open up the actual spreadsheet and add some rows to it.
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
be skypager edit datasource galleries
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
this will open up the spreadsheet in your browser for you.
|
|
94
|
-
|
|
95
|
-
- 8) with some actual data in our spreadsheet, lets get a couple of
|
|
96
|
-
pages rendered with it. open up the `source/index.html.erb` file and
|
|
97
|
-
put in the following content.
|
|
98
|
-
|
|
99
|
-
```erb
|
|
100
|
-
<h1>Galleries</h1>
|
|
101
|
-
|
|
102
|
-
<ul>
|
|
103
|
-
<% data.galleries.each do |gallery| %>
|
|
104
|
-
<li>
|
|
105
|
-
<p><%= gallery.title %></p>
|
|
106
|
-
</li>
|
|
107
|
-
<% end %>
|
|
108
|
-
</ul>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
here we are accessing the data from the galleries spreadsheet in our template
|
|
112
|
-
by iterating over `data.galleries` and listing each one. If we edit the spreadsheet,
|
|
113
|
-
and add a new row, and then refresh the page, you will see the new data show up.
|
|
114
|
-
|
|
115
|
-
**note:** if you don't see data showing up, you can restart your development server. in development,
|
|
116
|
-
skypager attempts to keep up to date, but in order not to keep nagging the server we do
|
|
117
|
-
some checking and sometimes this might make data stale.
|
|
118
|
-
|
|
119
|
-
- 9) we can create separate pages for each row in the spreadsheet.
|
|
120
|
-
|
|
121
|
-
```ruby
|
|
122
|
-
# config.rb
|
|
123
|
-
map_data_source(:galleries, :url => "/galleries/:slug", :to => "gallery.html.erb", :as => :gallery)
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
this will dynamically add routes for every row in the galleries data source, and display that individual
|
|
127
|
-
row using the `gallery.html.erb` template
|
|
128
|
-
|
|
129
|
-
since we added the `slug_column` option and set it to title, then it will turn our title column data
|
|
130
|
-
into a friendly url. for example: `My Awesome Gallery` becomes available at `/galleries/my-awesome-gallery`
|
|
131
|
-
|
|
132
|
-
editing the `source/gallery.html.erb` template file:
|
|
133
|
-
|
|
134
|
-
```erb
|
|
135
|
-
<h1><%= gallery.title %></h1>
|
|
136
|
-
<%= image_tag(gallery.cover_image) %>
|
|
137
|
-
<p><%= gallery.description %></p>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
and now editing the `source/index.html.erb` template file we can link to our galleries.
|
|
141
|
-
|
|
142
|
-
```erb
|
|
143
|
-
<a href="/galleries/<%= gallery.slug %>">
|
|
144
|
-
<%= gallery.title %>
|
|
145
|
-
</a>
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Using dropbox as a media store for your website content
|
|
149
|
-
|
|
150
|
-
- 10) a gallery isn't much without some images. in this tutorial, we are going to integrate with Dropbox to store our
|
|
151
|
-
image files.
|
data/lib/skypager/builder.rb
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
module Skypager
|
|
2
|
-
class Builder
|
|
3
|
-
|
|
4
|
-
attr_reader :app,
|
|
5
|
-
:source,
|
|
6
|
-
:logger,
|
|
7
|
-
:options
|
|
8
|
-
|
|
9
|
-
def initialize(app, options={})
|
|
10
|
-
@app = app
|
|
11
|
-
@options = options.reverse_merge(clean: true, verbose: true)
|
|
12
|
-
@source_dir = app.source_path
|
|
13
|
-
@build_dir = app.build_path
|
|
14
|
-
@to_clean = Set.new
|
|
15
|
-
|
|
16
|
-
@logger = app.logger
|
|
17
|
-
@rack = ::Rack::Test::Session.new(app.class.to_rack_app)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def build(force=false)
|
|
21
|
-
return unless force || needs_build?
|
|
22
|
-
|
|
23
|
-
queue_current_paths if should_clean?
|
|
24
|
-
execute!
|
|
25
|
-
clean! if should_clean?
|
|
26
|
-
|
|
27
|
-
app.site.requires_build!(false)
|
|
28
|
-
app.deploy! if app.auto_deploy?
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
protected
|
|
32
|
-
|
|
33
|
-
def clean!
|
|
34
|
-
@to_clean.each do |f|
|
|
35
|
-
FileUtils.rm_rf(f)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
Dir[@build_dir.join('**', '*')].select { |d| File.directory?(d) }.each do |d|
|
|
39
|
-
FileUtils.rm_rf(d) if Pathname(d).children.empty?
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def should_clean?
|
|
44
|
-
options[:clean]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def queue_current_paths
|
|
48
|
-
return unless app.build_path.exist?
|
|
49
|
-
|
|
50
|
-
paths = ::Middleman::Util.all_files_under(app.build_path).map(&:realpath).select(&:file?)
|
|
51
|
-
|
|
52
|
-
@to_clean += paths.select do |path|
|
|
53
|
-
path.to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
return unless RUBY_PLATFORM =~ /darwin/
|
|
57
|
-
|
|
58
|
-
# handle UTF-8-MAC filename on MacOS
|
|
59
|
-
@to_clean = @to_clean.map { |path| path.to_s.encode('UTF-8', 'UTF-8-MAC') }
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def needs_build?
|
|
63
|
-
@needs_build = app.data_sources.values.any? do |ds|
|
|
64
|
-
ds.fresh_on_server?
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# TODO
|
|
68
|
-
# Add support for google drive folders, github folder changes
|
|
69
|
-
@needs_build = @needs_build || app.syncables.any? do |syncable|
|
|
70
|
-
syncable.dropbox? && syncable.has_remote_changes?
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
@needs_build
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def execute!
|
|
77
|
-
sort_order = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .ico .webp .woff .otf .ttf .eot .js .css)
|
|
78
|
-
|
|
79
|
-
app.sitemap.resources.select do |resource|
|
|
80
|
-
resource.ext == '.css'
|
|
81
|
-
end.each(&method(:build_resource))
|
|
82
|
-
|
|
83
|
-
app.files.find_new_files((@source_dir + app.images_dir).relative_path_from(app.root_path))
|
|
84
|
-
app.sitemap.ensure_resource_list_updated!
|
|
85
|
-
|
|
86
|
-
resources = app.sitemap.resources.sort_by do |r|
|
|
87
|
-
sort_order.index(r.ext) || 100
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
if @build_dir.expand_path.relative_path_from(@source_dir).to_s =~ /\A[.\/]+\Z/
|
|
91
|
-
raise ":build_dir (#{@build_dir}) cannot be a parent of :source_dir (#{@source_dir})"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
resources.reject do |resource|
|
|
95
|
-
resource.ext == '.css'
|
|
96
|
-
end.each(&method(:build_resource))
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def build_resource(resource)
|
|
101
|
-
return if options[:glob] && !File.fnmatch(options[:glob], resource.destination_path)
|
|
102
|
-
|
|
103
|
-
output_path = render_to_file(resource)
|
|
104
|
-
|
|
105
|
-
return unless should_clean? && output_path.exist?
|
|
106
|
-
|
|
107
|
-
if RUBY_PLATFORM =~ /darwin/
|
|
108
|
-
# handle UTF-8-MAC filename on MacOS
|
|
109
|
-
|
|
110
|
-
@to_clean.delete(output_path.realpath.to_s.encode('UTF-8', 'UTF-8-MAC'))
|
|
111
|
-
else
|
|
112
|
-
@to_clean.delete(output_path.realpath)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def render_to_file(resource)
|
|
117
|
-
output_file = @build_dir + resource.destination_path.gsub('%20', ' ')
|
|
118
|
-
|
|
119
|
-
if resource.binary?
|
|
120
|
-
if !output_file.exist?
|
|
121
|
-
#base.say_status :create, output_file, :green
|
|
122
|
-
elsif FileUtils.compare_file(resource.source_file, output_file)
|
|
123
|
-
#base.say_status :identical, output_file, :blue
|
|
124
|
-
return output_file
|
|
125
|
-
else
|
|
126
|
-
#base.say_status :update, output_file, :yellow
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
output_file.dirname.mkpath
|
|
130
|
-
FileUtils.cp(resource.source_file, output_file)
|
|
131
|
-
else
|
|
132
|
-
begin
|
|
133
|
-
response = @rack.get(URI.escape(resource.request_path))
|
|
134
|
-
|
|
135
|
-
if response.status == 200
|
|
136
|
-
Pathname(output_file).open("w+") {|fh| fh.write binary_encode(response.body) }
|
|
137
|
-
else
|
|
138
|
-
handle_error(output_file, response.body)
|
|
139
|
-
end
|
|
140
|
-
rescue => e
|
|
141
|
-
handle_error(output_file, "#{e}\n#{e.backtrace.join("\n")}", e)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
output_file
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def handle_error(file_name, response, *args)
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def binary_encode(string)
|
|
153
|
-
string.force_encoding('ascii-8bit') if string.respond_to?(:force_encoding)
|
|
154
|
-
string
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
end
|
|
158
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
if defined?(Slim::Engine)
|
|
2
|
-
Slim::Engine.disable_option_validator!
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
command 'build' do |c|
|
|
6
|
-
c.syntax = "skypager build"
|
|
7
|
-
c.description = "performs a build on the site"
|
|
8
|
-
|
|
9
|
-
c.option "--force", nil, 'Whether or not we should force a build'
|
|
10
|
-
|
|
11
|
-
$enable_skypager_sync_from_command = true
|
|
12
|
-
|
|
13
|
-
c.action do |args, options|
|
|
14
|
-
require 'rack/test'
|
|
15
|
-
require 'skypager/builder'
|
|
16
|
-
|
|
17
|
-
app = Skypager.app
|
|
18
|
-
builder = Skypager::Builder.new(app, clean: true, verbose: true)
|
|
19
|
-
|
|
20
|
-
if app.site.requires_build? || options.force.present?
|
|
21
|
-
puts "== Building site: #{ app.site.name }"
|
|
22
|
-
builder.build(options.force.present?)
|
|
23
|
-
else
|
|
24
|
-
puts "== Site is not marked to be built. Skipping unless the --force flag is passed"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
command 'run build server' do |c|
|
|
30
|
-
c.syntax = 'skypager run build server [OPTIONS]'
|
|
31
|
-
c.description = 'run the skypager webhook handler'
|
|
32
|
-
|
|
33
|
-
c.option '--port', Fixnum, 'What port should this run on?'
|
|
34
|
-
c.option '--host', String, 'What host should this run on?'
|
|
35
|
-
|
|
36
|
-
c.action do |args, options|
|
|
37
|
-
require 'rack'
|
|
38
|
-
require 'skypager/builder/server'
|
|
39
|
-
|
|
40
|
-
opts = {
|
|
41
|
-
Host: options.host || '0.0.0.0',
|
|
42
|
-
Port: options.port || 3000
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Rack::Handler::WEBrick.run(Skypager::Builder::Server.new, opts) do |server|
|
|
46
|
-
[:INT, :TERM].each { |sig| trap(sig) { server.stop } }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
command 'generate builder crontab' do |c|
|
|
53
|
-
c.syntax = 'skypager generate builder crontab'
|
|
54
|
-
c.description = 'generates a crontab which will build sites that are marked to be built'
|
|
55
|
-
|
|
56
|
-
c.action do |args, options|
|
|
57
|
-
lines = Skypager::Site.sites.map do |site|
|
|
58
|
-
"*/5 * * * * cd #{ site.root } && bundle exec skypager build"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
puts "== run 'crontab -e' as root and add the following content:\n\n\n"
|
|
62
|
-
puts lines.join("\n")
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
command 'config localize' do |c|
|
|
2
|
-
c.syntax = "skypager config localize"
|
|
3
|
-
c.description = "sets up a local skypager config file for this project"
|
|
4
|
-
|
|
5
|
-
c.action do |args, options|
|
|
6
|
-
path = Skypager.config.cwd_config_path
|
|
7
|
-
|
|
8
|
-
unless path.exist?
|
|
9
|
-
path.open("w+") do |fh|
|
|
10
|
-
fh.write(Skypager.config.home_config.to_json)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
command 'config' do |c|
|
|
17
|
-
c.syntax = 'skypager config [options]'
|
|
18
|
-
c.description = 'list skypager configuration settings'
|
|
19
|
-
|
|
20
|
-
c.action do |_args, _options|
|
|
21
|
-
Skypager::Configuration.initialize!
|
|
22
|
-
|
|
23
|
-
Skypager.config.show
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
command 'config get' do |c|
|
|
28
|
-
c.syntax = 'skypager config:get [options]'
|
|
29
|
-
c.description = 'view a skypager configuration setting'
|
|
30
|
-
|
|
31
|
-
c.action do |args, _options|
|
|
32
|
-
Skypager::Configuration.initialize!
|
|
33
|
-
|
|
34
|
-
puts Skypager.config.get(args.first)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
command 'config set' do |c|
|
|
39
|
-
c.syntax = 'skypager config:set KEY=VALUE KEY=VALUE [options]'
|
|
40
|
-
c.description = 'manipulate skypager configuration settings'
|
|
41
|
-
|
|
42
|
-
c.option '--global', nil, 'Set the configuration globally'
|
|
43
|
-
|
|
44
|
-
c.action do |args, _options|
|
|
45
|
-
Skypager::Configuration.initialize!
|
|
46
|
-
|
|
47
|
-
args.select { |pair| pair.match(/=/) }
|
|
48
|
-
.map { |pair| pair.split('=') }
|
|
49
|
-
.each do |group|
|
|
50
|
-
key, value = group
|
|
51
|
-
Skypager.config.set(key, value, false, global: !!(_options.global))
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
Skypager.config.save!
|
|
55
|
-
|
|
56
|
-
Skypager.config.show
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
create_command = lambda do |c|
|
|
2
|
-
c.syntax = 'skypager create data source NAME [options]'
|
|
3
|
-
c.description = "Create a data source"
|
|
4
|
-
|
|
5
|
-
c.option "--type", nil, "What type of data source? google-spreadsheet, dropbox-excel, rest-endpoint"
|
|
6
|
-
c.option "--spreadsheet-name", nil, "What is the spreadsheet name? will be used to find the key"
|
|
7
|
-
c.option "--dropbox-path", nil, "What is the path to the excel?"
|
|
8
|
-
c.option "--fields", "", "comma separated list of fields"
|
|
9
|
-
c.option "--collaborators", "", "comma separated list of email address to share this data source with"
|
|
10
|
-
|
|
11
|
-
c.action do |args, options|
|
|
12
|
-
name = args.first
|
|
13
|
-
|
|
14
|
-
options.default :fields => "",
|
|
15
|
-
:collaborators => ""
|
|
16
|
-
|
|
17
|
-
name ||= ask("What should the name of this data source be?", String)
|
|
18
|
-
|
|
19
|
-
type = options.type
|
|
20
|
-
type ||= choose("Where will this data be stored?", "Google Spreadsheet", "Excel on Dropbox")
|
|
21
|
-
|
|
22
|
-
types = {
|
|
23
|
-
"Google Spreadsheet" => "google",
|
|
24
|
-
"Excel on Dropbox" => "dropbox-excel",
|
|
25
|
-
"REST API Endpoint" => "rest-endpoint"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type = types.fetch(type) { type }
|
|
29
|
-
fields = options.fields.split(",").map(&:strip)
|
|
30
|
-
collaborators = options.collaborators.split(",").map(&:strip)
|
|
31
|
-
|
|
32
|
-
if fields.empty?
|
|
33
|
-
fields = ask("Enter the names of the columns. Make sure to use underscore_instead_of_space:", Array)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
case type
|
|
37
|
-
|
|
38
|
-
when "google"
|
|
39
|
-
spreadsheet = Skypager::Data::GoogleSpreadsheet.create_from_data([], title: name, headers: fields, skypager_config_info: true)
|
|
40
|
-
|
|
41
|
-
if !collaborators.empty?
|
|
42
|
-
spreadsheet.share_write_access_with(*collaborators)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
when "dropbox-excel"
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
command 'create datasource' do |c|
|
|
52
|
-
create_command.call(c)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
command 'create data source' do |c|
|
|
56
|
-
create_command.call(c)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
command 'create syncable' do |c|
|
|
60
|
-
c.syntax = 'skypager create synced folder NAME [options]'
|
|
61
|
-
c.description = "Create a synced folder"
|
|
62
|
-
|
|
63
|
-
c.option "--type", nil, "What service is holding the folder? dropbox, google-drive"
|
|
64
|
-
c.option "--skip-config", nil, 'Skip modifying the config'
|
|
65
|
-
|
|
66
|
-
c.action do |args, options|
|
|
67
|
-
type = options.type
|
|
68
|
-
type ||= choose("What service is holding the folder?", "Google Drive", "Dropbox")
|
|
69
|
-
|
|
70
|
-
types = {
|
|
71
|
-
"Google Drive" => "google-drive",
|
|
72
|
-
"Dropbox" => "dropbox"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if defined?(::Middleman)
|
|
76
|
-
app = ::Middleman::Application.server.inst do
|
|
77
|
-
set :environment, 'development'
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
type = types.fetch(type) { type }
|
|
82
|
-
|
|
83
|
-
if type == "dropbox"
|
|
84
|
-
Skypager::Sync::Dropbox.create_site_folder(app.site_name)
|
|
85
|
-
|
|
86
|
-
puts "\n\n"
|
|
87
|
-
local_path = ask("Enter a relative path to the folder in this project that you would like to sync with Dropbox. e.g. source/images or source", String)
|
|
88
|
-
puts "\n\n"
|
|
89
|
-
remote_path = ask("Enter the remote path. leave blank to use the same", String)
|
|
90
|
-
remote_path = local_path if remote_path.to_s.length == 0
|
|
91
|
-
|
|
92
|
-
Skypager.dropbox.sync_folders(local_path, remote_path, app: app, append_config: !!!options.skip_config)
|
|
93
|
-
|
|
94
|
-
elsif type == "google-drive"
|
|
95
|
-
Skypager::Sync::Google.create_site_folder(app.site_name)
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|