locomotivecms_builder 1.0.0.alpha7 → 1.0.0.alpha8

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/.gitignore CHANGED
@@ -1,12 +1,8 @@
1
1
  .DS_Store
2
- <<<<<<< HEAD
3
- site
4
2
  tests
5
3
  .sass-cache
6
4
  .rbenv-gemsets
7
- =======
8
5
  /site
9
- >>>>>>> wip
10
6
  *.gem
11
7
  *.rbc
12
8
  .bundle
@@ -0,0 +1,30 @@
1
+ require 'thor/group'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+
5
+ module Locomotive
6
+ module Builder
7
+ module Generators
8
+ module Site
9
+
10
+ class Base < Thor::Group
11
+
12
+ include Thor::Actions
13
+
14
+ argument :name
15
+ argument :target_path
16
+
17
+ def self.source_root
18
+ File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'generators', self.name.demodulize.underscore)
19
+ end
20
+
21
+ def destination
22
+ File.join(target_path, name)
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ module Locomotive
2
+ module Builder
3
+ module Generators
4
+ module Site
5
+
6
+ class Blank < Base
7
+
8
+ def copy_sources
9
+ directory('.', self.destination, { recursive: true }, {
10
+ name: self.name,
11
+ version: Locomotive::Builder::VERSION
12
+ })
13
+ end
14
+
15
+ end
16
+
17
+ Locomotive::Builder::Generators::Site.register(:blank, Blank, %{
18
+ A blank LocomotiveCMS site with the minimal files.
19
+ })
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ module Locomotive
2
+ module Builder
3
+ module Generators
4
+ module Site
5
+
6
+ class Bootstrap < Base
7
+
8
+ def copy_sources
9
+ directory('.', self.destination, { recursive: true }, {
10
+ name: self.name,
11
+ version: Locomotive::Builder::VERSION
12
+ })
13
+ end
14
+
15
+ def choose_haml_over_html
16
+ if yes?('Do you prefer HAML templates ?')
17
+ remove_file File.join(self.destination, 'app/views/pages/index.liquid')
18
+ remove_file File.join(self.destination, 'app/views/pages/404.liquid')
19
+ remove_file File.join(self.destination, 'app/views/snippets/footer.liquid')
20
+ else
21
+ remove_file File.join(self.destination, 'app/views/pages/index.liquid.haml')
22
+ remove_file File.join(self.destination, 'app/views/pages/404.liquid.haml')
23
+ remove_file File.join(self.destination, 'app/views/snippets/footer.liquid.haml')
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ Locomotive::Builder::Generators::Site.register(:bootstrap, Bootstrap, %{
30
+ A LocomotiveCMS site powered by Twitter bootstrap (v2.2.2).
31
+ })
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,81 @@
1
+ require 'open-uri'
2
+ require 'zip/zipfilesystem'
3
+
4
+ module Locomotive
5
+ module Builder
6
+ module Generators
7
+ module Site
8
+
9
+ class Unzip < Base
10
+
11
+ def prepare
12
+ remove_file join('tmp')
13
+ empty_directory join('tmp')
14
+ end
15
+
16
+ def ask_for_location
17
+ @location = ask('What is the location (on the filesystem or url) of the zip file ?')
18
+ raise GeneratorException.new('Please enter a location') if @location.blank?
19
+ end
20
+
21
+ def download_or_copy
22
+ @template_path = join('tmp', File.basename(@location))
23
+
24
+ if @location =~ /^https?:\/\//
25
+ say "downloading...#{@location}"
26
+ create_file @template_path, open(@location).read
27
+ else
28
+ say "copying...#{@location}"
29
+ create_file @template_path, open(@location, 'rb') { |io| io.read }
30
+ end
31
+ end
32
+
33
+ def unzip
34
+ say "unzipping...#{@template_path}"
35
+
36
+ begin
37
+ Zip::ZipFile.open(@template_path) do |zipfile|
38
+ zipfile.each do |file|
39
+ next if file.name =~ /^__MACOSX/
40
+ zipfile.extract(file, join('tmp', file.name))
41
+
42
+ @path = $1 if file.name =~ /(.*)\/config\/site.yml$/
43
+ end
44
+ end
45
+ rescue Exception => e
46
+ raise GeneratorException.new("Unable to unzip the archive")
47
+ end
48
+
49
+ raise GeneratorException.new('Not a valid LocomotiveCMS site') if @path.blank?
50
+ end
51
+
52
+ def copy_sources
53
+ self.class.source_root = File.expand_path(join('tmp', @path, '/'))
54
+ say "copying files from #{self.class.source_root} / #{self.destination}"
55
+ directory('.', self.destination, { recursive: true })
56
+ end
57
+
58
+ def self.source_root
59
+ # only way to change the source root from the instance
60
+ @@source_root
61
+ end
62
+
63
+ def self.source_root=(value)
64
+ @@source_root = value
65
+ end
66
+
67
+ protected
68
+
69
+ def join(*args)
70
+ File.join(self.destination, *args)
71
+ end
72
+
73
+ end
74
+
75
+ Locomotive::Builder::Generators::Site.register(:unzip, Unzip, %{
76
+ Unzip a local or remote (http, https, ftp) zipped LocomotiveCMS site.
77
+ })
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,5 +1,5 @@
1
1
  module Locomotive
2
2
  module Builder
3
- VERSION = '1.0.0.alpha7'
3
+ VERSION = '1.0.0.alpha8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: locomotivecms_builder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.0.0.alpha7
5
+ version: 1.0.0.alpha8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Didier Lafforgue
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-03 00:00:00.000000000 Z
13
+ date: 2013-02-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  type: :runtime
@@ -358,6 +358,7 @@ files:
358
358
  - lib/locomotive/builder/generators/site/base.rb
359
359
  - lib/locomotive/builder/generators/site/blank.rb
360
360
  - lib/locomotive/builder/generators/site/bootstrap.rb
361
+ - lib/locomotive/builder/generators/site/unzip.rb
361
362
  - lib/locomotive/builder/generators/snippet.rb
362
363
  - lib/locomotive/builder/liquid.rb
363
364
  - lib/locomotive/builder/liquid/drops/base.rb
@@ -444,7 +445,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
444
445
  - !ruby/object:Gem::Version
445
446
  segments:
446
447
  - 0
447
- hash: -210573927176501707
448
+ hash: 2278383498909321201
448
449
  version: '0'
449
450
  required_rubygems_version: !ruby/object:Gem::Requirement
450
451
  none: false