stastic 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stastic/commands/base.rb +25 -0
- data/lib/stastic/commands/create.rb +0 -1
- data/lib/stastic/commands/help.rb +1 -1
- data/lib/stastic/commands/list.rb +1 -5
- data/lib/stastic/commands/publish.rb +20 -8
- data/lib/stastic/generator.rb +1 -1
- data/lib/stastic/generators/staticmatic.rb +65 -0
- data/lib/stastic.rb +1 -1
- metadata +4 -10
@@ -91,6 +91,31 @@ module Stastic::Command
|
|
91
91
|
puts
|
92
92
|
exit
|
93
93
|
end
|
94
|
+
|
95
|
+
def print_site_info(site, marker = " ")
|
96
|
+
printf("%-2s%-30s http://%s\n", marker, site['name'], default_domain(site))
|
97
|
+
print_custom_domains(site)
|
98
|
+
end
|
99
|
+
|
100
|
+
def default_domain(site)
|
101
|
+
if site['domains']
|
102
|
+
domain = site['domains'].detect { |domain| domain['default'] }
|
103
|
+
return domain['host'] if domain
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def print_custom_domains(site)
|
108
|
+
if site['domains']
|
109
|
+
domains = site['domains'].select{|domain| !domain['default']}
|
110
|
+
if !domains.empty?
|
111
|
+
domains.each do |domain|
|
112
|
+
printf("%-2s%30s http://%s\n", "", "--custom domain--", domain['host'])
|
113
|
+
end
|
114
|
+
puts
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
94
119
|
end
|
95
120
|
end
|
96
121
|
|
@@ -23,7 +23,7 @@ Available Commands
|
|
23
23
|
stastic domains:add <domain> # Add a domain to the site (example.com)
|
24
24
|
stastic domains:remove <domain> # Remove a domain from the site
|
25
25
|
stastic preview # Start local HTTP server
|
26
|
-
stastic set site_root
|
26
|
+
stastic set site_root=<path> # Set the path for your document root folder (defaults to ./)
|
27
27
|
|
28
28
|
EOF
|
29
29
|
end
|
@@ -12,7 +12,7 @@ module Stastic::Command
|
|
12
12
|
|
13
13
|
puts header
|
14
14
|
response['sites'].each do |site|
|
15
|
-
|
15
|
+
print_site_info(site, site['id'] == Stastic::Config.site_id ? "*" : " ")
|
16
16
|
end
|
17
17
|
puts
|
18
18
|
end
|
@@ -28,10 +28,6 @@ Your Stastic Sites
|
|
28
28
|
EOF
|
29
29
|
end
|
30
30
|
|
31
|
-
def site_info(site, marker = " ")
|
32
|
-
printf("%-2s%-30s http://%s.stastic.com\n", marker, site['name'], site['name'])
|
33
|
-
end
|
34
|
-
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
@@ -7,28 +7,40 @@ module Stastic::Command
|
|
7
7
|
|
8
8
|
private
|
9
9
|
def publish
|
10
|
-
|
10
|
+
print_pre_message("Detecting...")
|
11
11
|
generator = Stastic::Generator.detect
|
12
|
-
|
12
|
+
printf("%s %s\n", "[OK]", generator.desc)
|
13
13
|
|
14
|
-
|
14
|
+
print_pre_message("Building...")
|
15
15
|
generator.build
|
16
|
+
printf("[OK]\n")
|
16
17
|
|
17
|
-
|
18
|
+
print_pre_message("Packaging...")
|
18
19
|
archive_path = generator.package
|
20
|
+
bytes = File.new(archive_path).stat.size
|
21
|
+
printf("[OK] %.1f KB\n", bytes/1024.0)
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
print_pre_message("Uploading...")
|
24
|
+
s = Time.now
|
25
|
+
response = upload(archive_path)
|
26
|
+
printf("[OK] %.1f seconds\n", Time.now - s)
|
27
|
+
puts
|
28
|
+
puts "Your site is published:"
|
29
|
+
print_site_info(response)
|
30
|
+
puts
|
22
31
|
|
23
32
|
end
|
24
33
|
|
25
34
|
def upload(archive_path)
|
26
|
-
print "Uploading your archive...\n"
|
27
35
|
reponse = with_valid_site do
|
28
36
|
Stastic::Client.publish(Stastic::Config.site_id, archive_path)
|
29
37
|
end
|
30
|
-
puts "Complete\n"
|
31
38
|
end
|
32
39
|
|
40
|
+
def print_pre_message(msg)
|
41
|
+
printf("%-33s", msg)
|
42
|
+
STDOUT.flush
|
43
|
+
end
|
44
|
+
|
33
45
|
end
|
34
46
|
end
|
data/lib/stastic/generator.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
module Stastic::Generator
|
2
|
+
module Staticmatic
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def desc
|
6
|
+
"Staticmatic Generator"
|
7
|
+
end
|
8
|
+
|
9
|
+
def detect
|
10
|
+
FileTest.exists?('config/site.rb') &&
|
11
|
+
FileTest.exists?("src/pages") && File.directory?("src/pages")
|
12
|
+
end
|
13
|
+
|
14
|
+
def site_root
|
15
|
+
Stastic::Config.site_root || "site"
|
16
|
+
end
|
17
|
+
|
18
|
+
def build
|
19
|
+
verify_gem
|
20
|
+
system("staticmatic build .")
|
21
|
+
end
|
22
|
+
|
23
|
+
def package
|
24
|
+
Stastic::Generator.package(site_root)
|
25
|
+
end
|
26
|
+
|
27
|
+
def preview
|
28
|
+
verify_gem
|
29
|
+
system("staticmatic preview .")
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def gem_installed?
|
35
|
+
begin
|
36
|
+
gem "staticmatic"
|
37
|
+
true
|
38
|
+
rescue LoadError
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def verify_gem
|
44
|
+
if !gem_installed?
|
45
|
+
puts install_instructions
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def install_instructions
|
51
|
+
<<-EOF
|
52
|
+
The Staticmatic Gem can not be found on your GEM_PATH.
|
53
|
+
GEM_PATH=#{ENV['GEM_PATH']}
|
54
|
+
|
55
|
+
To Install Staticmatic:
|
56
|
+
------------------
|
57
|
+
|
58
|
+
sudo gem install staticmatic
|
59
|
+
|
60
|
+
EOF
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/lib/stastic.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Brian Smith
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-06 00:00:00 -08:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 6
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 1
|
46
43
|
segments:
|
47
44
|
- 1
|
48
45
|
- 5
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 3
|
62
58
|
segments:
|
63
59
|
- 0
|
64
60
|
version: "0"
|
@@ -72,7 +68,6 @@ dependencies:
|
|
72
68
|
requirements:
|
73
69
|
- - ">="
|
74
70
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
71
|
segments:
|
77
72
|
- 0
|
78
73
|
version: "0"
|
@@ -106,6 +101,7 @@ files:
|
|
106
101
|
- lib/stastic/generator.rb
|
107
102
|
- lib/stastic/generators/default.rb
|
108
103
|
- lib/stastic/generators/jekyll.rb
|
104
|
+
- lib/stastic/generators/staticmatic.rb
|
109
105
|
- lib/stastic.rb
|
110
106
|
- lib/trollop.rb
|
111
107
|
- bin/stastic
|
@@ -126,7 +122,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
122
|
requirements:
|
127
123
|
- - ">="
|
128
124
|
- !ruby/object:Gem::Version
|
129
|
-
hash: 3
|
130
125
|
segments:
|
131
126
|
- 0
|
132
127
|
version: "0"
|
@@ -135,7 +130,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
130
|
requirements:
|
136
131
|
- - ">="
|
137
132
|
- !ruby/object:Gem::Version
|
138
|
-
hash: 21
|
139
133
|
segments:
|
140
134
|
- 1
|
141
135
|
- 0
|