siterest 0.1.0.pre1 → 0.1.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0.pre1
1
+ 0.1.0.pre4
@@ -8,8 +8,6 @@ module Siterest
8
8
  self.command, *self.args = args
9
9
 
10
10
  self.command ||= 'render'
11
-
12
-
13
11
  end
14
12
 
15
13
  def put(string, newline=true)
@@ -21,7 +19,7 @@ module Siterest
21
19
  puts "#{self.command} Command"
22
20
 
23
21
  unless File.exist?(config_file)
24
- config
22
+ setup
25
23
  else
26
24
  self.send(command)
27
25
  end
@@ -32,7 +30,9 @@ module Siterest
32
30
  Server.run! :host => 'localhost', :port => 8888
33
31
  end
34
32
 
35
- def config
33
+ def setup
34
+ FileUtils.mkdir_p("#{ENV['HOME']}/.siterest/")
35
+
36
36
  put "Let's setup your SiteRest, visit follow url if you don't have a account"
37
37
  put "http://www.siterest.com"
38
38
 
@@ -47,7 +47,7 @@ module Siterest
47
47
  save_config(:api_token => token, :server_url => server)
48
48
  end
49
49
 
50
- def setup
50
+ def data
51
51
  FileUtils.cp_r(File.dirname(__FILE__) + '/../../site/data', 'data')
52
52
  end
53
53
 
@@ -79,27 +79,41 @@ module Siterest
79
79
  end
80
80
  end
81
81
 
82
+ def help
83
+ put <<-TEXT
82
84
 
83
- def client
84
- Client.new
85
+ Siterest commands
86
+ =====================
87
+
88
+ setup # Setup siterest access token
89
+ push [site] # Push local design to siterest site (use subdomain) you specified.
90
+ pull [site] # Pull a siterest site (use subdomain) design (assets and templates) to current folder
91
+ data # Generate a example data folder
92
+
93
+ TEXT
85
94
  end
86
95
 
87
- def home_directory
88
- ENV['HOME']
89
- end
96
+ private
97
+ def client
98
+ Client.new
99
+ end
90
100
 
91
- def config_file
92
- "#{ENV['HOME']}/.siterest/config.yml"
93
- end
101
+ def home_directory
102
+ ENV['HOME']
103
+ end
94
104
 
95
- def save_config(config)
96
- File.open(config_file, "w") do|file|
97
- file.puts(config.to_yaml)
105
+ def config_file
106
+ "#{ENV['HOME']}/.siterest/config.yml"
98
107
  end
99
- end
100
108
 
101
- def load_config
102
- YAML.load_file(config_file)
103
- end
109
+ def save_config(config)
110
+ File.open(config_file, "w") do|file|
111
+ file.puts(config.to_yaml)
112
+ end
113
+ end
114
+
115
+ def load_config
116
+ YAML.load_file(config_file)
117
+ end
104
118
  end
105
119
  end
@@ -13,6 +13,12 @@ class Page < OpenStruct
13
13
  pages
14
14
  end
15
15
 
16
+ def self.find(permalink)
17
+ path = Dir.glob("data/pages/#{permalink}.md").first or raise "Page not found"
18
+
19
+ self.build(path)
20
+ end
21
+
16
22
  def self.recursive_build(start_path, cache)
17
23
  Dir.glob("#{start_path}/*").map do |path|
18
24
  if File.directory?(path)
@@ -31,27 +37,17 @@ class Page < OpenStruct
31
37
  attributes = build_content(path)
32
38
  url = path.gsub(%r(data/pages/(.+).md)){|m| $1 }
33
39
  permalink = url.split('/').last
34
-
35
- self.new attributes.merge(:url => url, :permalink => permalink)
36
- end
37
-
38
- def self.find(permalink)
39
- path = Dir.glob("data/pages/#{permalink}.md").first or raise "Page not found"
40
-
41
- attributes = build_content(path)
42
- url = path.gsub(%r(data/pages/(.+).md)){|m| $1 }
43
- permalink = url.split('/').last
44
40
 
45
41
  if permalink == 'home'
46
- permalink = nil
47
42
  url = ''
48
43
  end
49
44
 
50
- url = "/" + url
51
-
52
- self.new attributes.merge(:url => url, :permalink => permalink)
45
+ self.new attributes.merge(
46
+ 'url' => "/"+ url,
47
+ 'permalink' => permalink
48
+ )
53
49
  end
54
-
50
+
55
51
  def self.build_content(filename)
56
52
  source = File.read(filename)
57
53
  meta, content = source.split(/---\n(.+?)---/sm)[1,2]
data/lib/siterest.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
 
3
- require "bundler"
4
- Bundler.setup
3
+ # require "bundler"
4
+ # Bundler.setup
5
5
 
6
6
  require 'yaml'
7
7
  require 'h2o'
@@ -40,13 +40,13 @@ module Siterest
40
40
  end
41
41
 
42
42
  def self.token
43
- @token ||= config[:api_token]
43
+ config[:api_token]
44
44
  rescue
45
45
  raise "You need to setup API key, run siterest setup"
46
46
  end
47
47
 
48
48
  def self.url
49
- @token ||= config[:server_url]
49
+ config[:server_url]
50
50
  end
51
51
 
52
52
  def self.site_resource_url
data/readme.md CHANGED
@@ -4,83 +4,25 @@ SiteRest client - building website is now happier
4
4
  - siterest command with various options to communicate to the server
5
5
 
6
6
 
7
+ Requirement
8
+ ---
7
9
 
8
10
  API Token
9
-
10
- API URL
11
-
12
- Access core resources
13
- http://api.siterest.com/
14
-
15
- Access site resources
16
-
17
- http://api.siterest.com/sites/{subdomain}/templates
18
11
 
12
+ You will need a active API token
13
+
19
14
 
20
15
  Commands
21
- ===
22
-
23
- setup
24
16
  ---
25
17
 
26
- > siterest setup
27
-
28
- Enter your SiteRest credenticals
29
- Email: [subjective@gmail.com]
30
- Password: [*******]
31
-
32
- then credential and config are saved to following config file
33
-
34
- ~/.siterest.yml
35
- current : taylorluk
36
- email : [subjective@gmail.com]
37
-
38
- design:pull [name]
39
- ----------------
40
-
41
- first time
42
-
43
- git clone git@siterest.com:sitename
44
-
45
- pull latest content from the website
18
+ ### config
46
19
 
47
- git reset --hard
48
- git pull git@siterest.com:sitename
49
20
 
50
- conflict:
21
+ ### setup
51
22
 
52
- overwrite local copy of file if it is already on remote server.
23
+ Setup default sample data folder
53
24
 
54
- design:push [name]
55
- ------------------
56
25
 
57
- push all local changes to remote server
26
+ ### pull :subdomain
58
27
 
59
- git add .
60
- git commit -m "Site update [messages]"
61
-
62
- git push git@siterest.com:sitename
63
-
64
-
65
-
66
- Low priority features
67
- ==================
68
-
69
-
70
- create
71
- ------------------
72
-
73
- > siterest create
74
- We are going to create new website for you.
75
-
76
- Title: My new we website
77
- Subdomain: something
78
-
79
- git-config username, email
80
-
81
-
82
- backup
83
- ---
84
-
85
- import
86
- ---
28
+ ### push :subdomain
@@ -10,3 +10,6 @@ Hello world
10
10
  What every you do and don't panic
11
11
 
12
12
 
13
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
14
+
15
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
data/siterest.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{siterest}
8
- s.version = "0.1.0.pre1"
8
+ s.version = "0.1.0.pre4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Taylor luk"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siterest
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988184
4
+ hash: -1876988169
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 0
10
- - pre1
11
- version: 0.1.0.pre1
10
+ - pre4
11
+ version: 0.1.0.pre4
12
12
  platform: ruby
13
13
  authors:
14
14
  - Taylor luk