weebly 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ecc6e3974f07a4eb4936619fc0d10905ff6c00b9
4
+ data.tar.gz: 366ae2f809e86861effb0da8553ee41acb102fc4
5
+ SHA512:
6
+ metadata.gz: bee9eff003cfcff92388a04b3ab5a5627c700aef13d20cf04df75cfcf0aa3cb615aae37a327f3cce38664f438e04f2349ec1d7857910d434a2186f288c115236
7
+ data.tar.gz: ed8938e5b501ded489242727612a22340229f114dd4e9982463c565acc537095e32ea03312dcbb5b9e26d4c565beb97b69c174312ede3d815bacc21bcd776974
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in weebly.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Joshua Beitler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+ # Weebly
2
+
3
+ Sometimes, Weebly is a nice option to use for client websites when you simply
4
+ want to get something done quickly, or for situations in which you want to
5
+ allow your client to easily edit their site.
6
+
7
+ Unfortunately, Weebly's developer experience is quite poor, and has many odd
8
+ and strange requirements. This simple gem allows you to develop your theme
9
+ in a sane and (mostly) trouble-free environment.
10
+
11
+ ## Installation
12
+ ```
13
+ $ gem install weebly
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ### Referencing resources
19
+ When referencing resources in your site (eg: `href`, `src` attributes), you
20
+ *cannot include the full path!* Instead, simply include the file name, and
21
+ it will be found when the site is built. For this reason, you will want to
22
+ test your site by running `weebly server`, and not opening your files directly
23
+ in a browser.
24
+
25
+ ```html
26
+ <!-- Wrong. Do not do this! -->
27
+ <link rel="stylesheet" href="css/master.css">
28
+
29
+ <!-- Correct. Please do this instead. -->
30
+ <link rel="stylesheet" href="master.css">
31
+ ```
32
+
33
+ ## Commands
34
+
35
+ ### `weebly new <sitename>`
36
+ Will create a new site in the current directory with the name `sitename`.
37
+ This site will include a basic directory structure, with places for CSS, JS,
38
+ HTML layouts, and images.
39
+
40
+ ### `weebly build`
41
+ When run from a directory containing a site (eg: `sites/hello`, where `hello`
42
+ is the Weebly site`), this command will validate, clean up, and compress your
43
+ site to be Weebly-ready.
44
+
45
+ ### `weebly validate`
46
+ Will validate your site to ensure that it conforms to Weebly's standards.
47
+ (Searches for template tags, directory structure, etc.)
48
+
49
+ ### `weebly server`
50
+ Will run your site on a local webserver (defaults to `localhost:8000`) and
51
+ emulate the Weebly environment. Note: *simply opening `index.html` in your
52
+ web browser is not good practice, and will not even work in this case.
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it (http://github.com/joshbeitler/weebly/fork)
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ require "cucumber/rake/task"
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'weebly'
5
+ require 'commander/import'
6
+
7
+ program :version, Weebly::VERSION
8
+ program :description, 'Makes development of Weebly themes sane and simple'
9
+ program :help, 'Author', 'Joshua Beitler <joshbeitler@gmail.com>'
10
+
11
+ command :new do |c|
12
+ c.syntax = 'weebly new <name>'
13
+ c.description = 'Creates a new structured Weebly site'
14
+
15
+ c.option '--jquery', nil, 'Includes Jquery in the generated project'
16
+ c.option '--scss', nil, 'Includes SCSS support in the generated project'
17
+
18
+ c.action do |args, options|
19
+ Weebly::Weebly.create_site(args.first, options)
20
+ end
21
+ end
22
+
23
+ command :build do |c|
24
+ c.syntax = 'weebly build'
25
+ c.description = 'Compiles site structure and zips'
26
+
27
+ c.action do |args, options|
28
+ Weebly::Weebly.build_site
29
+ end
30
+ end
31
+
32
+ command :validate do |c|
33
+ c.syntax = 'weebly validate'
34
+ c.description = 'Ensures that project conforms to Weebly guidelines'
35
+
36
+ c.action do |args, options|
37
+ Weebly::Weebly.validate_site
38
+ end
39
+ end
40
+
41
+ command :server do |c|
42
+ c.syntax = 'weebly serve'
43
+ c.description = 'Launches a local web server for the current site'
44
+
45
+ c.action do |args, options|
46
+ Weebly::Weebly.serve_site
47
+ end
48
+ end
@@ -0,0 +1,110 @@
1
+ require 'weebly/version'
2
+ require 'zip'
3
+ require 'webrick'
4
+ require 'colorize'
5
+ require 'listen'
6
+
7
+ module Weebly
8
+ class Weebly
9
+ def self.create_site(dirname, opts)
10
+ if dirname == nil || dirname.length < 1
11
+ puts '=> Error: No name provided'.colorize(:red)
12
+ return
13
+ end
14
+
15
+ begin
16
+ Dir.mkdir dirname
17
+ rescue
18
+ puts "=> Error: Directory `#{dirname}` already exists".colorize(:red)
19
+ end
20
+
21
+ FileUtils::mkdir_p ["#{dirname}/css", "#{dirname}/js", "#{dirname}/img"]
22
+ FileUtils::touch([
23
+ "#{dirname}/css/main_style.css",
24
+ "#{dirname}/js/#{dirname}.js",
25
+ "#{dirname}/index.html",
26
+ "#{dirname}/.gitignore",
27
+ "#{dirname}/README.md",
28
+ "#{dirname}/AUTHORS.md"])
29
+
30
+ system("cd #{dirname} && git init")
31
+
32
+ puts "=> Created site `#{dirname}` successfully".colorize(:green)
33
+ end
34
+
35
+ def self.build_site
36
+ puts "=> Building site..."
37
+
38
+ if self.validate_site
39
+ puts "==> Site conforms".colorize(:green)
40
+ else
41
+ exit
42
+ end
43
+
44
+ if ! File.exist?("index.html")
45
+ puts "=> Error: Not a Weebly site".colorize(:red)
46
+ exit
47
+ end
48
+
49
+ dirname = File.split(Dir.getwd)[-1]
50
+ FileUtils.rmdir("/tmp/#{dirname}") if File.directory?("/tmp/#{dirname}")
51
+ FileUtils.rmdir("#bin") if File.directory?("#bin")
52
+ FileUtils.rm("#{dirname}.zip") if File.exist?("#{dirname}.zip")
53
+ FileUtils.mkdir_p ["/tmp/#{dirname}", "bin"]
54
+
55
+ FileUtils.cp(Dir["js/**/*"], "/tmp/#{dirname}/")
56
+ FileUtils.cp(Dir["css/**/*"], "/tmp/#{dirname}/")
57
+ FileUtils.cp(Dir["img/**/*"], "/tmp/#{dirname}/")
58
+ FileUtils.cp("index.html", "/tmp/#{dirname}/index.html")
59
+
60
+ Zip::File.open("bin/#{dirname}.zip", Zip::File::CREATE) do |zip|
61
+ Dir["/tmp/#{dirname}/*"].each do |f|
62
+ puts "==> #{File.basename(f)}".colorize(:green)
63
+ zip.add(File.basename(f), f)
64
+ end
65
+ end
66
+
67
+ FileUtils.rmdir("/tmp/#{dirname}")
68
+ puts "=> Done".colorize(:green)
69
+ end
70
+
71
+ def self.validate_site
72
+ if ! File.exist?("index.html")
73
+ puts "=> Error: Not a Weebly site".colorize(:red)
74
+ return
75
+ end
76
+
77
+ Dir.new('.').each do |f|
78
+ if File.directory?(f) || File.extname(f) != '.html'
79
+ next
80
+ end
81
+
82
+ ret = true
83
+
84
+ if ! File.readlines(f).grep(/{content}/).any?
85
+ puts "==> Error: `#{File.basename(f)}` does not have a content tag".colorize(:red)
86
+ ret = false
87
+ elsif ! File.readlines(f).grep(/{footer}/).any?
88
+ puts "==> Error: `#{File.basename(f)}` does not have a footer tag".colorize(:red)
89
+ ret = false
90
+ elsif ! File.readlines(f).grep(/{menu}/).any?
91
+ puts "==> Warning: `#{File.basename(f)}` does not have a menu tag".colorize(:red)
92
+ ret = false
93
+ end
94
+ end
95
+ end
96
+
97
+ def self.serve_site
98
+ if ! File.exist?("index.html")
99
+ puts "=> Error: Not a Weebly site".colorize(:red)
100
+ return
101
+ end
102
+
103
+ spath = "/tmp/#{File.split(Dir.getwd)[-1]}/"
104
+ server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => spath)
105
+
106
+ trap 'INT' do server.shutdown end
107
+ server.start
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,3 @@
1
+ module Weebly
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'weebly/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "weebly"
8
+ spec.version = Weebly::VERSION
9
+ spec.authors = ["Joshua Beitler"]
10
+ spec.email = ["joshbeitler@gmail.com"]
11
+ spec.summary = %q{Makes weebly development easier}
12
+ spec.description = %q{Makes weebly development easier}
13
+ spec.homepage = "https://github.com/joshbeitler/weebly"
14
+ spec.license = "Apache-2.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["weebly"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_runtime_dependency "commander"
25
+ spec.add_runtime_dependency "rubyzip"
26
+ spec.add_runtime_dependency "colorize"
27
+ spec.add_runtime_dependency "listen", "~> 2.0"
28
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: weebly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Beitler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: commander
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubyzip
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: listen
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ description: Makes weebly development easier
98
+ email:
99
+ - joshbeitler@gmail.com
100
+ executables:
101
+ - weebly
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/weebly
111
+ - lib/weebly.rb
112
+ - lib/weebly/version.rb
113
+ - weebly.gemspec
114
+ homepage: https://github.com/joshbeitler/weebly
115
+ licenses:
116
+ - Apache-2.0
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.1.11
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Makes weebly development easier
138
+ test_files: []