voog-kit 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.markdown +142 -0
- data/Rakefile +1 -0
- data/bin/kit +212 -0
- data/lib/voog/dtk/filemanager.rb +784 -0
- data/lib/voog/dtk/guard.rb +147 -0
- data/lib/voog/dtk/notifier.rb +34 -0
- data/lib/voog/dtk/version.rb +5 -0
- data/lib/voog/dtk.rb +131 -0
- data/spec/fixtures/.DS_Store +0 -0
- data/spec/fixtures/.voog +3 -0
- data/spec/fixtures/.voog2 +7 -0
- data/spec/fixtures/images/bullet.png +0 -0
- data/spec/fixtures/layout.json +12 -0
- data/spec/fixtures/layout_asset.json +15 -0
- data/spec/fixtures/layout_assets.json +7 -0
- data/spec/fixtures/layouts.json +9 -0
- data/spec/fixtures/manifest.json +17 -0
- data/spec/models/dtk/config_spec.rb +82 -0
- data/spec/models/dtk/filemanager_spec.rb +524 -0
- data/spec/spec_helper.rb +38 -0
- data/voog-kit.gemspec +34 -0
- metadata +238 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e6be6c5d6e0b104cd4adefae47899ece91bad8b
|
4
|
+
data.tar.gz: 08cc5e8d94edff48ea1ce71bcec8b38ef004fca3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 313f9abe7994f98dc7056742bb9f918f5144550c7fc25f61619e6a76fce810db231ffa221da6f7134517d53ea81edb56fcb259216914403d1cc2ecae34001de4
|
7
|
+
data.tar.gz: fd80df3755d5e201a4df59ce73f5290ee63b822ac831b7d5e19809b357411ff6c54f528f894ed40a70d0b4abb7fed94fb15bce50b6a87bfe7c0a2dd95d511130
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Priit Haamer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Voog Developer Toolkit
|
2
|
+
|
3
|
+
The Voog Designer Toolkit is a simple Ruby script that simplifies the editing
|
4
|
+
of [Voog site](http://www.voog.com) templates. It acts as a push-pull mechanism that allows you to
|
5
|
+
fetch all layout files, work on them locally and upload them without having to
|
6
|
+
use the browser-based code editor.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Install the Voog toolkit gem:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ gem install voog-kit
|
14
|
+
```
|
15
|
+
|
16
|
+
This installs the main tool, `kit`, which is added to your system's $PATH, which
|
17
|
+
means it can be run from anywhere in your system.
|
18
|
+
|
19
|
+
If you want to explicitly use latest version of the [Voog API client](https://github.com/Edicy/voog.rb):
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ git pull https://github.com/Edicy/voog.rb voog-api
|
23
|
+
$ cd voog-api
|
24
|
+
$ bundle install
|
25
|
+
$ rake install
|
26
|
+
```
|
27
|
+
|
28
|
+
## Basic commands
|
29
|
+
|
30
|
+
* `init` - Initializes the local folder structure and files for a site
|
31
|
+
* `manifest` - Generates a `manifest.json` file from the site's layout and asset files
|
32
|
+
* `check` - Cross-checks the generated manifest to your local files to see if anything is missing
|
33
|
+
* `pull` - Fetches the layout and layout asset files for the given site
|
34
|
+
* `push` - Synchronizes your local changes with Voog
|
35
|
+
* `watch` - Watches for file changes in the current directory
|
36
|
+
* `help` - Shows a list of commands or help for one command
|
37
|
+
|
38
|
+
Most commands need to know your site's URL and you personal API token to properly authorize all
|
39
|
+
requests. For this you can either provide them with `--token/-t` and `--host/-h`
|
40
|
+
flags, e.g `kit pull -t afcf30182aecfc8155d390d7d4552d14 -h mysite.voog.com`. If there's a '.voog' file
|
41
|
+
present in the current folder, it takes the options from there.
|
42
|
+
|
43
|
+
There's also a `--site/-s` argument that is used to choose a configuration block from the `.voog` file.
|
44
|
+
|
45
|
+
Example `.voog` file:
|
46
|
+
|
47
|
+
```
|
48
|
+
[site1]
|
49
|
+
host=mysite.voog.com
|
50
|
+
api_token=afcf30182aecfc8155d390d7d4552d14
|
51
|
+
[site2]
|
52
|
+
host=site2.customdomain.co
|
53
|
+
api_token=5d390d7d4552d14afcf30182aecfc815
|
54
|
+
```
|
55
|
+
|
56
|
+
To choose the second block, you can simply use `kit pull -s site2` or `kit pull --site=site2`.
|
57
|
+
If the site is not provided, **kit** will use the first block defined in the file.
|
58
|
+
When you provide the host, token and block name, it is then written to the configuration file, overwriting
|
59
|
+
any identically named blocks or creating a new one, if necessary.
|
60
|
+
|
61
|
+
If the configuration file isn't present and you provide the token, hostname and site name manually when invoking a
|
62
|
+
command, the file is then generated and the options are stored within so you don't have to provide them
|
63
|
+
later.
|
64
|
+
|
65
|
+
### init
|
66
|
+
|
67
|
+
This command either initializes an empty folder structure via `kit init empty`, clones the file and folder
|
68
|
+
structure of the Pripyat design (essentially a design boilerplate) via `kit init new` or uses the provided
|
69
|
+
hostname and API token to download existing layout files from the given site via just `kit init`.
|
70
|
+
|
71
|
+
### manifest
|
72
|
+
|
73
|
+
The manifest file is probably the most important file in the layout file structure. It holds metadata for each
|
74
|
+
and every file which ensures that all layout names and asset types are correct when pushing or pulling files.
|
75
|
+
`kit manifest` on its own generates a manifest from all current local files. As this is done purely from file
|
76
|
+
names, some generated data might be incorrect and, as such, may need manual correction.
|
77
|
+
|
78
|
+
If you're generating a
|
79
|
+
manifest for a site that already has layout files, it would be better to use the `--remote` flag to use remote
|
80
|
+
data instead. This takes the layout titles and asset content types that are already saved in Voog and mirrors
|
81
|
+
them in the manifest.
|
82
|
+
|
83
|
+
### pull
|
84
|
+
|
85
|
+
`kit pull` downloads all files from the site provided via the hostname and api_token options (or from the .voog
|
86
|
+
file). This overwrites all existing identically named local files.
|
87
|
+
|
88
|
+
By giving filenames or layout/component titles as arguments to `kit pull`, it instead downloads only those (and,
|
89
|
+
again, overwrites current local files). For example, `kit pull shadow.png MainMenu` would download the file *images/shadow.png*
|
90
|
+
and the *MainMenu* component.
|
91
|
+
|
92
|
+
### push
|
93
|
+
|
94
|
+
`kit push` is the counterpart to `pull`. This takes the provided files or folders and uploads them to the provided
|
95
|
+
site, overwriting existing files. Although `pull` searches by filename, `push` arguments need to be local file paths.
|
96
|
+
For example, `kit push images/shadow.png layouts/mainmenu.tpl` works, `kit push shadow.png MainMenu` does not.
|
97
|
+
|
98
|
+
### watch
|
99
|
+
|
100
|
+
This command starts a watcher that monitors the current folder and its subfolders and triggers `kit push` every time
|
101
|
+
a file changes. This is most useful for styling your site as all style changes are instantly uploaded and visible in
|
102
|
+
the browser.
|
103
|
+
|
104
|
+
`watch` also looks for newly created files and file removals, updates the manifest accordingly and triggers `kit push`.
|
105
|
+
|
106
|
+
### help
|
107
|
+
|
108
|
+
This command shows helpful information about the tool or its subcommands. Invoking `kit help` shows a list of possible
|
109
|
+
options and commands with a brief description. `kit help <command>` shows information about that command.
|
110
|
+
|
111
|
+
### Sample local folder structure
|
112
|
+
|
113
|
+
```
|
114
|
+
./
|
115
|
+
assets/
|
116
|
+
custom_font.woff
|
117
|
+
components/
|
118
|
+
mainmenu.tpl
|
119
|
+
sidebar.tpl
|
120
|
+
footer.tpl
|
121
|
+
images/
|
122
|
+
background.jpg
|
123
|
+
javascripts/
|
124
|
+
custom_script.js
|
125
|
+
spinner.js
|
126
|
+
layouts/
|
127
|
+
front_page.tpl
|
128
|
+
blog.tpl
|
129
|
+
products.tpl
|
130
|
+
stylesheets/
|
131
|
+
style.css
|
132
|
+
.voog
|
133
|
+
manifest.json
|
134
|
+
```
|
135
|
+
|
136
|
+
## Contributing
|
137
|
+
|
138
|
+
1. Fork it
|
139
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
140
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
141
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
142
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/kit
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# TODO: Not needed after bundled as gem
|
4
|
+
require 'guard'
|
5
|
+
require 'gli'
|
6
|
+
|
7
|
+
$LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
require 'voog/dtk'
|
11
|
+
require 'voog/dtk/guard'
|
12
|
+
require 'voog/dtk/filemanager'
|
13
|
+
require 'voog/dtk/notifier'
|
14
|
+
require 'voog_api'
|
15
|
+
|
16
|
+
include GLI::App
|
17
|
+
|
18
|
+
sort_help :manually
|
19
|
+
|
20
|
+
program_desc 'A tool that manages uploading and downloading Voog layout files'
|
21
|
+
|
22
|
+
debug_args = [:debug, { negatable: false, default_value: false, desc: 'Show additional information on exceptions' }]
|
23
|
+
verbose_args = [:verbose, { negatable: false, default_value: false, desc: 'Show additional information while running' }]
|
24
|
+
silent_args = [:silent, { default_value: false, negatable: false, desc: 'Hide all information text while running' }]
|
25
|
+
hostname_args = [:h, :host, :hostname, { desc: 'Provide a hostname', arg_name: :HOST }]
|
26
|
+
api_token_args = [:t, :token, :api_token, { desc: 'Provide an API token', arg_name: :API_TOKEN }]
|
27
|
+
site_args = [:s, :site, { arg_name: :SITE, default_value: nil, desc: 'Specify which site block to use when parsing the .voog file' }]
|
28
|
+
|
29
|
+
flag *hostname_args
|
30
|
+
flag *api_token_args
|
31
|
+
flag *site_args
|
32
|
+
|
33
|
+
switch *debug_args
|
34
|
+
switch *verbose_args
|
35
|
+
switch *silent_args
|
36
|
+
version Voog::Dtk::VERSION
|
37
|
+
|
38
|
+
desc 'Initializes the local folder structure and files for a site'
|
39
|
+
long_desc "The init command takes a hostname and an api token
|
40
|
+
as arguments, fetches the structure of the site and
|
41
|
+
recreates it locally in the same folder the command
|
42
|
+
was evoked in.\n
|
43
|
+
If the hostname and/or api-token aren't provided via command-line
|
44
|
+
arguments, the tool looks for a .voog file in the current working
|
45
|
+
directory that has those. See the readme for more information
|
46
|
+
(http://github.com/Edicy/voog-kit)"
|
47
|
+
command :init do |c|
|
48
|
+
c.switch *debug_args
|
49
|
+
c.switch *verbose_args
|
50
|
+
c.switch *silent_args
|
51
|
+
c.flag *hostname_args
|
52
|
+
c.flag *api_token_args
|
53
|
+
c.flag *site_args
|
54
|
+
c.action do |global_options, options, args|
|
55
|
+
@filemanager.create_folders
|
56
|
+
@filemanager.create_files
|
57
|
+
end
|
58
|
+
|
59
|
+
c.command :empty do |e|
|
60
|
+
e.action do |e|
|
61
|
+
Voog::Dtk.write_config('','',false)
|
62
|
+
@filemanager.create_folders
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
c.command :new do |n|
|
67
|
+
n.action do |n|
|
68
|
+
@filemanager.fetch_boilerplate
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'Looks for missing files and folders'
|
74
|
+
command :check do |c|
|
75
|
+
c.switch *debug_args
|
76
|
+
c.switch *verbose_args
|
77
|
+
c.switch *silent_args
|
78
|
+
c.flag *hostname_args
|
79
|
+
c.flag *api_token_args
|
80
|
+
c.flag *site_args
|
81
|
+
c.action do |global_options, options, args|
|
82
|
+
@filemanager.check
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'Fetches the layout and layout asset files for the given site'
|
87
|
+
long_desc 'If no arguments are provided, the \'pull\' command fetches all
|
88
|
+
layout files and layout assets and (re-)generates a manifest file.
|
89
|
+
If filenames are provided, it fetches only those and updates the
|
90
|
+
manifest with only those files. The provided names can be either
|
91
|
+
filenames or layout/component titles.'
|
92
|
+
command :pull do |c|
|
93
|
+
c.switch *debug_args
|
94
|
+
c.switch *verbose_args
|
95
|
+
c.switch *silent_args
|
96
|
+
c.flag *hostname_args
|
97
|
+
c.flag *api_token_args
|
98
|
+
c.flag *site_args
|
99
|
+
c.action do |global_options, options, args|
|
100
|
+
unless args.empty? # if filenames are given, pull specified files and generate new manifest
|
101
|
+
@filemanager.pull_files(args)
|
102
|
+
else # otherwise pull everything and generate new manifest
|
103
|
+
@filemanager.create_folders
|
104
|
+
@filemanager.create_files
|
105
|
+
@filemanager.generate_remote_manifest
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
desc 'Updates remote files with local changes'
|
111
|
+
long_desc "The 'push' command takes the space-separated list of filenames and
|
112
|
+
uploads them, if possible, to Voog. When uploading layout files (layouts
|
113
|
+
or components), the command looks for the manifest.json file to find which
|
114
|
+
files correspond to which remote layouts."
|
115
|
+
command :push do |c|
|
116
|
+
c.switch *debug_args
|
117
|
+
c.switch *verbose_args
|
118
|
+
c.switch *silent_args
|
119
|
+
c.flag *hostname_args
|
120
|
+
c.flag *api_token_args
|
121
|
+
c.flag *site_args
|
122
|
+
c.action do |global_options, options, args|
|
123
|
+
@filemanager.upload_files args
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "Generates a manifest.json file from the site's layout and asset files."
|
128
|
+
long_desc "This looks through the current directory's subdirectories and files
|
129
|
+
within them to compile a 'manifest.json' file. This is used for keeping
|
130
|
+
metadata about layout files that can't easily be attached to files
|
131
|
+
themselves. When creating the manifest, you might have to manually
|
132
|
+
edit it to correspond to possible remote differences. When invoking the
|
133
|
+
command with the --remote flag, the manifest is instead generated from
|
134
|
+
remote files which, again, might not correspond to your local file structure."
|
135
|
+
command :manifest do |c|
|
136
|
+
c.switch *debug_args
|
137
|
+
c.switch *verbose_args
|
138
|
+
c.switch *silent_args
|
139
|
+
c.flag *hostname_args
|
140
|
+
c.flag *api_token_args
|
141
|
+
c.flag *site_args
|
142
|
+
c.switch(
|
143
|
+
[:r, :remote],
|
144
|
+
default_value: false,
|
145
|
+
negatable: false,
|
146
|
+
desc: 'generate manifest from remote files'
|
147
|
+
)
|
148
|
+
c.action do |global_options, options, args|
|
149
|
+
if options.fetch(:remote, @config[:remote])
|
150
|
+
@filemanager.generate_remote_manifest
|
151
|
+
else
|
152
|
+
@filemanager.generate_local_manifest
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
desc 'Watches for file changes and pushes them automatically'
|
158
|
+
command :watch do |c|
|
159
|
+
c.switch *debug_args
|
160
|
+
c.switch *verbose_args
|
161
|
+
c.switch *silent_args
|
162
|
+
c.flag *hostname_args
|
163
|
+
c.flag *api_token_args
|
164
|
+
c.flag *site_args
|
165
|
+
c.action do |global_options, options, args|
|
166
|
+
Voog::Dtk::Guuard.new(@filemanager).run
|
167
|
+
sleep 0.5 while ::Guard.running
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
pre do |global, command, options, args|
|
172
|
+
@config_block = global.fetch(:site, nil) || options.fetch(:site, nil)
|
173
|
+
@debug = global.fetch(:debug, false) || options.fetch(:debug, false)
|
174
|
+
|
175
|
+
silent = global.fetch(:silent, false) || options.fetch(:silent, false)
|
176
|
+
verbose = global.fetch(:verbose, false) || options.fetch(:verbose, false)
|
177
|
+
|
178
|
+
@notifier = Voog::Dtk::Notifier.new($stderr, silent)
|
179
|
+
|
180
|
+
host = global.fetch(:host, nil) || options.fetch(:host, nil)
|
181
|
+
api_token = global.fetch(:token, nil) || options.fetch(:token, nil)
|
182
|
+
|
183
|
+
if host && api_token && @config_block
|
184
|
+
Voog::Dtk.write_config(host, api_token, @config_block)
|
185
|
+
end
|
186
|
+
|
187
|
+
@config = Voog::Dtk.read_config @config_block
|
188
|
+
|
189
|
+
if Voog::Dtk::config_exists? || Voog::Dtk::global_config_exists?
|
190
|
+
unless [:new, :empty, :check].include? command.name
|
191
|
+
fail 'Hostname not found from arguments or from configuration file'.red unless host || @config[:host]
|
192
|
+
fail 'API token not found from arguments or from configuration file'.red unless api_token || @config[:api_token]
|
193
|
+
end
|
194
|
+
else
|
195
|
+
unless [:new, :empty, :check].include? command.name
|
196
|
+
fail 'Configuration file not found!'.red unless host && api_token
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
host ||= @config[:host]
|
201
|
+
api_token ||= @config[:api_token]
|
202
|
+
|
203
|
+
client = Voog::Client.new(host, api_token)
|
204
|
+
@filemanager = Voog::Dtk::FileManager.new(client, verbose, silent)
|
205
|
+
end
|
206
|
+
|
207
|
+
on_error do |exception|
|
208
|
+
Voog::Dtk.handle_exception(exception, @debug, @notifier)
|
209
|
+
false
|
210
|
+
end
|
211
|
+
|
212
|
+
exit run(ARGV)
|