siteleaf 0.8.1 → 0.8.3
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.
- data/bin/siteleaf +9 -9
- data/lib/siteleaf/client.rb +4 -4
- data/lib/siteleaf/entity.rb +1 -1
- data/lib/siteleaf/meta.rb +2 -2
- data/lib/siteleaf/page.rb +2 -2
- data/lib/siteleaf/server.rb +3 -2
- data/lib/siteleaf/site.rb +2 -2
- data/lib/siteleaf/user.rb +2 -2
- data/lib/siteleaf/version.rb +1 -1
- data/lib/siteleaf.rb +1 -1
- data/siteleaf.gemspec +2 -2
- metadata +18 -2
data/bin/siteleaf
CHANGED
@@ -18,15 +18,15 @@ def auth(re_auth = false)
|
|
18
18
|
password = $stdin.gets.chomp
|
19
19
|
system 'stty echo'
|
20
20
|
|
21
|
-
|
21
|
+
puts "Authorizing..."
|
22
22
|
|
23
|
-
if auth = Siteleaf::Client.auth(email, password) and auth.has_key?('api_key')
|
23
|
+
if auth = Siteleaf::Client.auth(email, password) and auth.is_a?(Hash) and auth.has_key?('api_key')
|
24
24
|
File.open(Siteleaf.settings_file,'w') do|file|
|
25
25
|
Marshal.dump({:api_key => auth['api_key'], :api_secret => auth['api_secret']}, file)
|
26
26
|
end
|
27
|
-
|
27
|
+
puts "=> Gem authorized." if re_auth
|
28
28
|
else
|
29
|
-
|
29
|
+
puts "Could not authorize, check your e-mail or password."
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -36,14 +36,14 @@ def config(site)
|
|
36
36
|
# See https://github.com/siteleaf/siteleaf-gem for documentation.
|
37
37
|
|
38
38
|
require 'siteleaf'
|
39
|
-
run Siteleaf::Server.new(site_id
|
39
|
+
run Siteleaf::Server.new(:site_id => '#{site.id}')" }
|
40
40
|
|
41
41
|
pow_path = "#{Etc.getpwuid.dir}/.pow"
|
42
|
-
if
|
42
|
+
if File.directory?(pow_path)
|
43
43
|
site_no_tld = site.domain.gsub(/\.[a-z]{0,4}$/i,'')
|
44
44
|
site_symlink = "#{pow_path}/#{site_no_tld}"
|
45
45
|
FileUtils.rm(site_symlink) if File.symlink?(site_symlink)
|
46
|
-
FileUtils.symlink(File.
|
46
|
+
FileUtils.symlink(File.dirname(__FILE__), site_symlink)
|
47
47
|
puts "=> Site configured with Pow, open `http://#{site_no_tld}.dev` to test site locally.\n"
|
48
48
|
else
|
49
49
|
puts "=> Site configured, run `siteleaf server` to test site locally.\n"
|
@@ -56,7 +56,7 @@ when '-v', '--version'
|
|
56
56
|
when '-h', '--help'
|
57
57
|
puts help
|
58
58
|
when 's', 'server'
|
59
|
-
if File.
|
59
|
+
if File.exist?('config.ru')
|
60
60
|
`rackup config.ru`
|
61
61
|
else
|
62
62
|
puts "No config found, run `siteleaf config yoursite.com`.\n"
|
@@ -74,7 +74,7 @@ when 'n', 'new'
|
|
74
74
|
auth
|
75
75
|
if site = Siteleaf::Site.create(:title => ARGV[1], :domain => ARGV[1])
|
76
76
|
dir = ARGV.size >= 3 ? ARGV[2] : ARGV[1]
|
77
|
-
Dir.mkdir(dir) unless
|
77
|
+
Dir.mkdir(dir) unless File.directory?(dir)
|
78
78
|
Dir.chdir(dir)
|
79
79
|
config site
|
80
80
|
else
|
data/lib/siteleaf/client.rb
CHANGED
@@ -32,16 +32,16 @@ module Siteleaf
|
|
32
32
|
def self.execute(method, path, payload = nil, params = nil)
|
33
33
|
Siteleaf.load_settings if !Siteleaf.api_key
|
34
34
|
request = RestClient::Request.new(:url => Siteleaf.api_url(path), :method => method, :payload => payload, :headers => { :params => params }, :user => Siteleaf.api_key, :password => Siteleaf.api_secret)
|
35
|
-
begin
|
35
|
+
#begin
|
36
36
|
response = request.execute
|
37
37
|
if response.headers[:content_type].to_s.include?('json')
|
38
38
|
return JSON.parse(response) # parse JSON
|
39
39
|
else
|
40
40
|
return response # raw
|
41
41
|
end
|
42
|
-
rescue => e
|
43
|
-
|
44
|
-
end
|
42
|
+
#rescue => e
|
43
|
+
# return e.inspect # error
|
44
|
+
#end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/siteleaf/entity.rb
CHANGED
@@ -44,7 +44,7 @@ module Siteleaf
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def attributes=(attributes = {})
|
47
|
-
attributes.each_pair { |k, v| k != "attributes" and
|
47
|
+
attributes.each_pair { |k, v| k != "attributes" and self.instance_variable_set("@#{k}", v) }
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.class_name
|
data/lib/siteleaf/meta.rb
CHANGED
data/lib/siteleaf/page.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class Page < Entity
|
3
3
|
|
4
|
-
attr_accessor :
|
5
|
-
|
4
|
+
attr_accessor :title, :body, :slug, :url, :parent_id, :site_id, :published_at, :meta
|
5
|
+
attr_reader :id, :created_at, :updated_at
|
6
6
|
|
7
7
|
def create_endpoint
|
8
8
|
"sites/#{self.site_id}/pages"
|
data/lib/siteleaf/server.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class Server
|
3
|
+
|
3
4
|
attr_accessor :site_id
|
4
5
|
|
5
6
|
def initialize(attributes = {})
|
@@ -25,7 +26,7 @@ module Siteleaf
|
|
25
26
|
templates.push("default.html")
|
26
27
|
|
27
28
|
templates.each do |t|
|
28
|
-
return File.read(t) if File.
|
29
|
+
return File.read(t) if File.exist?(t)
|
29
30
|
end
|
30
31
|
|
31
32
|
return nil
|
@@ -37,7 +38,7 @@ module Siteleaf
|
|
37
38
|
url = env['PATH_INFO']
|
38
39
|
path = url.gsub(/\/\z|\A\//, '') #strip beginning and trailing slashes
|
39
40
|
|
40
|
-
if !File.directory?(path) and File.
|
41
|
+
if !File.directory?(path) and File.exist?(path)
|
41
42
|
Rack::File.new(Dir.pwd).call(env)
|
42
43
|
else
|
43
44
|
template_data = nil
|
data/lib/siteleaf/site.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class Site < Entity
|
3
3
|
|
4
|
-
attr_accessor :
|
5
|
-
|
4
|
+
attr_accessor :title, :domain, :timezone
|
5
|
+
attr_reader :id, :user_id, :created_at, :updated_at
|
6
6
|
|
7
7
|
def self.find_by_domain(domain)
|
8
8
|
result = Client.get "sites", {"domain" => domain}
|
data/lib/siteleaf/user.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Siteleaf
|
2
2
|
class User < Entity
|
3
3
|
|
4
|
-
attr_accessor :
|
5
|
-
|
4
|
+
attr_accessor :email, :firstname, :lastname
|
5
|
+
attr_reader :id, :created_at, :updated_at
|
6
6
|
|
7
7
|
end
|
8
8
|
end
|
data/lib/siteleaf/version.rb
CHANGED
data/lib/siteleaf.rb
CHANGED
data/siteleaf.gemspec
CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = "Siteleaf Ruby interface"
|
13
13
|
gem.homepage = "http://siteleaf.com"
|
14
14
|
|
15
|
-
|
15
|
+
gem.required_ruby_version = '>= 1.8'
|
16
16
|
|
17
17
|
gem.add_dependency 'rest-client'
|
18
18
|
gem.add_dependency 'json'
|
19
|
-
|
19
|
+
gem.add_dependency 'rack'
|
20
20
|
|
21
21
|
gem.files = `git ls-files`.split($/)
|
22
22
|
gem.files += Dir.glob("lib/**/*.rb")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siteleaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rack
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description: A Ruby interface and command line utility for the Siteleaf API.
|
47
63
|
email:
|
48
64
|
- api@siteleaf.com
|
@@ -79,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
95
|
requirements:
|
80
96
|
- - ! '>='
|
81
97
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
98
|
+
version: '1.8'
|
83
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
100
|
none: false
|
85
101
|
requirements:
|