smooster 0.1.81 → 0.2.1
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/README.md +3 -0
- data/lib/smooster/application.rb +5 -1
- data/lib/smooster/cli/executable.rb +24 -3
- data/lib/smooster/deploy/page.rb +69 -0
- data/lib/smooster/deploy/pages.rb +49 -0
- data/lib/smooster/version.rb +1 -1
- data/lib/smooster.rb +4 -0
- data/smooster.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 319f2bf2727611b53db7b538ce5b4be8839fd0ba
|
|
4
|
+
data.tar.gz: 80ba17c26da7d73631ca2a7228ceb8eb60d30375
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 719c35cf83dee877165fe430e62d028c4916d504bc738ad76b943820ccd9e912223a3dfad8fab65da3a4a2962ee16e28297f5fb64be29010ed35df28fee10733
|
|
7
|
+
data.tar.gz: 70aeca8276ca2429a9cd480c99c8965c829e2be5aad31d87b66858dff806032eb78d49d53ddd8b035cff6756951ade6e5cc0f75d1a4963dfec8a3da0935e43ad
|
data/README.md
CHANGED
|
@@ -39,6 +39,9 @@ This is a ruby gem
|
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
41
|
|
|
42
|
+
###0.2.1
|
|
43
|
+
* Added Page create feature. smooster deploy initial will first upload medias, templates and then create a page for each uploaded template
|
|
44
|
+
|
|
42
45
|
###0.1.8
|
|
43
46
|
* MAJOR: Changed smooster api v2 for site_templates and media_assets from ids to smo_ids
|
|
44
47
|
|
data/lib/smooster/application.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Smooster
|
|
|
3
3
|
include Singleton
|
|
4
4
|
include ActiveModel::Model
|
|
5
5
|
|
|
6
|
-
attr_accessor :config, :user_config, :site_templates_store, :media_assets_store
|
|
6
|
+
attr_accessor :config, :user_config, :site_templates_store, :media_assets_store, :pages_store
|
|
7
7
|
|
|
8
8
|
def self.start
|
|
9
9
|
self.instance
|
|
@@ -28,6 +28,10 @@ module Smooster
|
|
|
28
28
|
@media_assets_store ||= YAML::Store.new("#{self.base_dir}/.smo/media_assets.yml")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def pages_store
|
|
32
|
+
@pages_store ||= YAML::Store.new("#{self.base_dir}/.smo/pages.yml")
|
|
33
|
+
end
|
|
34
|
+
|
|
31
35
|
def config
|
|
32
36
|
@config ||= YAML::Store.new("#{self.base_dir}/.smo/configure.yml")
|
|
33
37
|
end
|
|
@@ -40,11 +40,12 @@ module Smooster
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
desc "deploy [TYPE]", "deploy your project to the smooster cloud DEFAULT=assets [assets,templates,all]"
|
|
43
|
+
desc "deploy [TYPE]", "deploy your project to the smooster cloud DEFAULT=assets [assets,templates,all,initial]"
|
|
44
|
+
method_option :validator, type: :boolean, default: false, desc: "If set to true and INITIAL than all pages will be opened in the browser with html validator"
|
|
44
45
|
def deploy(type="assets")
|
|
45
46
|
puts "Starting push to smooster..."
|
|
46
47
|
|
|
47
|
-
if type == "assets" || type == "all"
|
|
48
|
+
if type == "assets" || type == "all" || type == "initial"
|
|
48
49
|
Smooster::Deploy::MediaAsset.all.each do |ma|
|
|
49
50
|
status = "[deployed]".colorize(:blue)
|
|
50
51
|
status = "[unchanged]".colorize(:green) if ma.checksum.to_s == ma.load_checksum.to_s
|
|
@@ -53,7 +54,7 @@ module Smooster
|
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
|
|
56
|
-
if type == "templates" || type == "all"
|
|
57
|
+
if type == "templates" || type == "all" || type == "initial"
|
|
57
58
|
Smooster::Deploy::SiteTemplate.all.each do |st|
|
|
58
59
|
status = "[deployed]".colorize(:blue)
|
|
59
60
|
status = "[unchanged]".colorize(:green) if st.checksum.to_s == st.load_checksum.to_s
|
|
@@ -62,6 +63,26 @@ module Smooster
|
|
|
62
63
|
end
|
|
63
64
|
end
|
|
64
65
|
|
|
66
|
+
if type == "initial"
|
|
67
|
+
urls = []
|
|
68
|
+
Smooster::Deploy::SiteTemplate.all.each do |st|
|
|
69
|
+
status = "[create]".colorize(:blue)
|
|
70
|
+
#status = "[exists]".colorize(:green) if st.checksum.to_s == st.load_checksum.to_s
|
|
71
|
+
p = Smooster::Deploy::Page.new({:title => st.title, :filename => st.title, :site_template_id => st.smo_id})
|
|
72
|
+
p.upload
|
|
73
|
+
urls << p.url
|
|
74
|
+
puts "#{p.filename} #{status}"
|
|
75
|
+
end
|
|
76
|
+
urls.each do |url|
|
|
77
|
+
puts "#{url}"
|
|
78
|
+
url_encoded = CGI.escape(url)
|
|
79
|
+
if options[:validator]
|
|
80
|
+
Launchy.open("http://validator.w3.org/check?uri=#{url_encoded}&charset=%28detect+automatically%29&doctype=Inline&group=0")
|
|
81
|
+
sleep 1
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
65
86
|
puts "#{type} done!"
|
|
66
87
|
end
|
|
67
88
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module Smooster
|
|
2
|
+
module Deploy
|
|
3
|
+
class Page
|
|
4
|
+
include ActiveModel::Model
|
|
5
|
+
include ActiveModel::Serializers::JSON
|
|
6
|
+
#extend Smooster::Deploy::Pages
|
|
7
|
+
|
|
8
|
+
attr_accessor :title, :filename, :site_template_id, :smo_id, :url
|
|
9
|
+
|
|
10
|
+
def attributes
|
|
11
|
+
{'title' => title, 'filename' => filename, 'site_template_id' => site_template_id, 'smo_id' => smo_id, 'url' => url}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def store
|
|
15
|
+
Smooster::Application.instance.pages_store
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def load_smo_id
|
|
19
|
+
store.transaction { store[self.site_template_id][:smo_id] if store[self.site_template_id].present? }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def filename=(filename)
|
|
23
|
+
@filename = sanitize_filename(filename)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def upload
|
|
27
|
+
#return false if self.checksum.to_s == self.load_checksum.to_s
|
|
28
|
+
|
|
29
|
+
if self.smo_id.present?
|
|
30
|
+
#response = RestClient.put "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/site_templates/#{self.smo_id}", {:site_template => {:body => self.body, :title => self.title}}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'}
|
|
31
|
+
else
|
|
32
|
+
begin
|
|
33
|
+
response = RestClient.post "#{Smooster::Application.instance.api_url()}/#{Smooster::Application.instance.site_id()}/folders/root/pages", {:page => {:title => self.title, :filename => self.filename, :site_template_id => self.site_template_id, :folder_id => "root"}}, {"Authorization" => 'Token token="'+ Smooster::Application.instance.api_key() +'"', "Accept" => 'application/vnd.smoosterid.v2'}
|
|
34
|
+
data = JSON.parse(response)
|
|
35
|
+
self.url = data['url']
|
|
36
|
+
self.smo_id = data['smo_id']
|
|
37
|
+
self.save
|
|
38
|
+
rescue => e
|
|
39
|
+
Smooster::Application.instance.logger.error "Error in page create for #{self.title} / #{self.filename}!: #{e} / #{e.backtrace.inspect}"
|
|
40
|
+
puts "This page failed to create: #{self.title} / #{self.filename}".colorize(:red)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def save
|
|
47
|
+
store.transaction do
|
|
48
|
+
store[self.site_template_id] = {:smo_id => self.smo_id}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def sanitize_filename(filename)
|
|
53
|
+
# Split the name when finding a period which is preceded by some
|
|
54
|
+
# character, and is followed by some character other than a period,
|
|
55
|
+
# if there is no following period that is followed by something
|
|
56
|
+
# other than a period (yeah, confusing, I know)
|
|
57
|
+
fn = filename.split /(?<=.)\.(?=[^.])(?!.*\.[^.])/m
|
|
58
|
+
|
|
59
|
+
# We now have one or two parts (depending on whether we could find
|
|
60
|
+
# a suitable period). For each of these parts, replace any unwanted
|
|
61
|
+
# sequence of characters with an underscore
|
|
62
|
+
fn.map! { |s| s.gsub /[^a-z0-9\-]+/i, '-' }
|
|
63
|
+
|
|
64
|
+
# Finally, join the parts with a period and return the result
|
|
65
|
+
return fn.join '.'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Smooster
|
|
2
|
+
module Deploy
|
|
3
|
+
module Pages
|
|
4
|
+
|
|
5
|
+
def collection
|
|
6
|
+
collection = []
|
|
7
|
+
response.each do |file|
|
|
8
|
+
body = File.read(file)
|
|
9
|
+
template = SiteTemplate.new({:body => body, :path => file, :checksum => Digest::MD5.hexdigest(body)})
|
|
10
|
+
template.smo_id = template.load_smo_id if template.load_smo_id.present?
|
|
11
|
+
source = Nokogiri::HTML(body)
|
|
12
|
+
template.title = source.css('title').first.inner_html
|
|
13
|
+
collection << template
|
|
14
|
+
end
|
|
15
|
+
collection
|
|
16
|
+
end
|
|
17
|
+
alias_method :all, :collection
|
|
18
|
+
|
|
19
|
+
def response
|
|
20
|
+
@response ||= initialize_collection
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def reload!
|
|
24
|
+
@response = initialize_collection
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def upload_all
|
|
28
|
+
self.all.each do |template|
|
|
29
|
+
template.upload
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def method_missing(name, *args, &block)
|
|
34
|
+
if collection.respond_to? name
|
|
35
|
+
collection.send(name, *args)
|
|
36
|
+
else
|
|
37
|
+
super
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
def initialize_collection
|
|
43
|
+
Dir.glob("#{Smooster::Application.instance.base_dir}/#{Smooster::Application.instance.html_folder()}/**/*.html")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
data/lib/smooster/version.rb
CHANGED
data/lib/smooster.rb
CHANGED
|
@@ -4,6 +4,8 @@ require 'rest_client'
|
|
|
4
4
|
require 'nokogiri'
|
|
5
5
|
require "yaml/store"
|
|
6
6
|
require 'logger'
|
|
7
|
+
require 'cgi'
|
|
8
|
+
require 'launchy'
|
|
7
9
|
|
|
8
10
|
#base
|
|
9
11
|
require 'smooster/rest-client/rest-client-purge'
|
|
@@ -11,6 +13,8 @@ require 'smooster/rest-client/rest-client-purge'
|
|
|
11
13
|
#deploy
|
|
12
14
|
require 'smooster/deploy/site_templates'
|
|
13
15
|
require 'smooster/deploy/site_template'
|
|
16
|
+
require 'smooster/deploy/pages'
|
|
17
|
+
require 'smooster/deploy/page'
|
|
14
18
|
require 'smooster/deploy/media_assets'
|
|
15
19
|
require 'smooster/deploy/media_asset'
|
|
16
20
|
|
data/smooster.gemspec
CHANGED
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.add_dependency("activemodel")
|
|
24
24
|
spec.add_dependency("rest-client")
|
|
25
25
|
spec.add_dependency("colorize")
|
|
26
|
+
spec.add_dependency("launchy")
|
|
26
27
|
spec.add_dependency("nokogiri", ["~> 1.5"])
|
|
27
28
|
|
|
28
29
|
spec.add_development_dependency "pry"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smooster
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastian Maier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: launchy
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: nokogiri
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -199,6 +213,8 @@ files:
|
|
|
199
213
|
- lib/smooster/cli/executable.rb
|
|
200
214
|
- lib/smooster/deploy/media_asset.rb
|
|
201
215
|
- lib/smooster/deploy/media_assets.rb
|
|
216
|
+
- lib/smooster/deploy/page.rb
|
|
217
|
+
- lib/smooster/deploy/pages.rb
|
|
202
218
|
- lib/smooster/deploy/site_template.rb
|
|
203
219
|
- lib/smooster/deploy/site_templates.rb
|
|
204
220
|
- lib/smooster/rest-client/rest-client-purge.rb
|