mr_hyde 0.1.0 → 0.2.0

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +3 -3
  4. data/Rakefile +1 -0
  5. data/bin/mrhyde +56 -10
  6. data/lib/mr_hyde/commands/build.rb +3 -2
  7. data/lib/mr_hyde/commands/list.rb +41 -0
  8. data/lib/mr_hyde/commands/new.rb +3 -9
  9. data/lib/mr_hyde/commands/remove.rb +2 -2
  10. data/lib/mr_hyde/commands/serve.rb +26 -0
  11. data/lib/mr_hyde/configuration.rb +17 -5
  12. data/lib/mr_hyde/extensions/new.rb +54 -2
  13. data/lib/mr_hyde/jekyll_ext/converters/scss.rb +18 -0
  14. data/lib/mr_hyde/jekyll_ext/jekyll.rb +16 -0
  15. data/lib/mr_hyde/jekyll_ext/site.rb +47 -0
  16. data/lib/mr_hyde/jekyll_ext/tags/include.rb +23 -0
  17. data/lib/mr_hyde/site.rb +234 -0
  18. data/lib/mr_hyde/version.rb +1 -1
  19. data/lib/mr_hyde.rb +125 -24
  20. data/lib/site_template/_config.yml +14 -0
  21. data/lib/site_template/_mrhyde.yml +2 -11
  22. data/lib/site_template/sources/_assets/_sass/_base.scss +204 -0
  23. data/lib/site_template/sources/_assets/_sass/_functions.scss +11 -0
  24. data/lib/site_template/sources/_assets/_sass/_grid.scss +544 -0
  25. data/lib/site_template/sources/_assets/_sass/_layout.scss +241 -0
  26. data/lib/site_template/sources/_assets/_sass/_newbase.scss +488 -0
  27. data/lib/site_template/sources/_assets/_sass/_normalize.scss +424 -0
  28. data/lib/site_template/sources/_assets/_sass/_syntax-highlighting.scss +67 -0
  29. data/lib/site_template/sources/_includes/footer.html +58 -0
  30. data/lib/site_template/sources/_includes/head.html +12 -0
  31. data/lib/site_template/sources/_includes/header.html +31 -0
  32. data/lib/site_template/sources/_layouts/default.html +25 -0
  33. data/lib/site_template/sources/_layouts/page.html +14 -0
  34. data/lib/site_template/sources/_layouts/post.html +15 -0
  35. data/lib/site_template/sources/main_site/about.md +9 -0
  36. data/lib/site_template/sources/main_site/css/main.scss +55 -0
  37. data/lib/site_template/sources/main_site/css/normalize.css +427 -0
  38. data/lib/site_template/sources/main_site/index.md +17 -0
  39. data/lib/site_template/sources/main_site/js/main.coffee +27 -0
  40. data/lib/subsite_template/_config.yml +2 -0
  41. data/lib/subsite_template/_posts/0000-00-00-welcome-to-mr-hyde.markdown.erb +27 -0
  42. data/lib/subsite_template/about.md +9 -0
  43. data/lib/subsite_template/assets/dr_jekyll_and_mr_hyde_poster.png +0 -0
  44. data/lib/subsite_template/feed.xml +30 -0
  45. data/lib/subsite_template/index.html +26 -0
  46. data/resources/mrhyde-logo-red.png +0 -0
  47. data/resources/mrhyde-logo.png +0 -0
  48. data/spec/build_spec.rb +26 -27
  49. data/spec/list_spec.rb +37 -0
  50. data/spec/new_spec.rb +53 -25
  51. data/spec/rm_spec.rb +30 -31
  52. metadata +38 -8
  53. data/lib/mr_hyde/blog.rb +0 -146
  54. data/lib/mr_hyde/extensions/.new.rb.swp +0 -0
  55. data/lib/site_template/site/css/main.css +0 -0
  56. data/lib/site_template/site/index.html +0 -0
  57. data/test/blog_test.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec62071e2cf42fc9b179c84964c68874b92babab
4
- data.tar.gz: 6c6470ac9a73127c09b80618ec54c5b45ca0e25f
3
+ metadata.gz: 608e05d085560eb38898a27c5ffcef2dc1220c96
4
+ data.tar.gz: 98c227e6bec0118e0c7fa15bb5cbb474ba752262
5
5
  SHA512:
6
- metadata.gz: 6ed4ab1d0e48757ec3640cbb0b099ac58b0ce2541eec6b38eb79847e3d917faee12e2291dd997fa64ed7eb2bf10779665a706edddf63f3b9f8c56284ceeb6920
7
- data.tar.gz: b18c81a9d1d4923dbd8d0afe491909d711ba35587a094d472ea68fcbd8b0cee27050fcce25d559e1cdcb0fb356bd1156b5d52cf1d848f32d35dd7e29fe4bddb1
6
+ metadata.gz: 8e8b2dc18dd88fd38cc98a20bbc75d4a769c970e3b14038e1739d814a03b14c11d1427b592a7a8efc10deab4cd740f27ab2a5962b36b238255dee02751effd4c
7
+ data.tar.gz: 9df017b5e3c7c9dc2b0c83c3bc964c0d62d67d76f5ba368d24615f224893662c4bc813594948c550a6f93dbfd06864563e74c291a80067c62bbb2c7037051761
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  .sass-cache/
16
+ .DS_Store
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
+ <img src="https://raw.githubusercontent.com/emoriarty/mr_hyde/master/resources/mrhyde-logo.png" alt="Mr.Hyde logo" height="100"/>
1
2
  # MrHyde
3
+ Mr. Hyde lets you generate and manage as many static sites as you like, all nested from a parent site, for example, you can have several nested sites sharing the same assets than the parent site and other nested sites with its own assets.
2
4
 
3
- Mr. Hyde lets you generate and manage as many sites as you want.
4
-
5
- It's based on [Jekyll](https://github.com/jekyll/jekyll), in fact Mr. Hyde wraps Jekyll to give you the possibilty of managing many sites.
5
+ All this work thanks to [Jekyll](http://jekyllrb.com) in fact Mr. Hyde wraps Jekyll so if you know Jekyll there is no much to learn about Mr. Hyde.
6
6
 
7
7
  The current version is based on [Jekyll 2.5.3](https://github.com/jekyll/jekyll/tree/v2.5.3).
8
8
 
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
4
  ENV["JEKYLL_LOG_LEVEL"] = "error"
5
+ ENV["MRHYDE_LOG_LEVEL"] = "error"
5
6
 
6
7
  Rake::TestTask.new do |t|
7
8
  t.libs.push "lib"
data/bin/mrhyde CHANGED
@@ -8,6 +8,9 @@ require 'io/console'
8
8
  require 'mercenary'
9
9
  require 'mr_hyde'
10
10
  require 'mr_hyde/commands/remove'
11
+ require 'mr_hyde/commands/serve'
12
+ require 'mr_hyde/commands/list'
13
+
11
14
 
12
15
  Mercenary.program(:mrhyde) do |p|
13
16
  p.version MrHyde::VERSION
@@ -15,9 +18,10 @@ Mercenary.program(:mrhyde) do |p|
15
18
  p.syntax "mrhyde <subcommand>"
16
19
 
17
20
  p.command(:new) do |c|
18
- c.syntax "new <subcommand>"
19
- c.description "Creates a new Mr. Hyde site scaffold in path"
20
- c.option "force", "--force", "Force creation even if PATH already exists"
21
+ c.syntax "new [PATH]"
22
+ c.description "Creates a new Mr. Hyde site scaffold in path or current path."
23
+ c.option "force", "--force", "Force creation even if PATH already exists."
24
+ c.option "blank", "--blank", "Creates scaffolding but with empty files."
21
25
 
22
26
  c.action do |args, options|
23
27
  MrHyde::Commands::New.process(args, options)
@@ -33,7 +37,7 @@ Mercenary.program(:mrhyde) do |p|
33
37
  snew.description "Creates a new Jekyll site or sites"
34
38
 
35
39
  snew.option "force", "--force", "Force creation even if PATH already exists"
36
- snew.option "blank", "--blank", "Creates scaffolding but with empty files"
40
+ snew.option "blank", "--blank", "Creates scaffolding with empty files and no nested site"
37
41
 
38
42
  snew.action do |args, options|
39
43
  MrHyde::Commands::New.process({ :type => :site, :args => args }, options)
@@ -46,9 +50,9 @@ Mercenary.program(:mrhyde) do |p|
46
50
 
47
51
  srm.alias(:rm)
48
52
 
49
- srm.option "force", "--force", "Don't ask for remove blog"
50
- srm.option "all", "--all", "Remove all built sites. This option works alone."
51
- srm.option "full", "--full", "Remove all built and draft site or sites. This option can be used with the rest of options."
53
+ #srm.option "force", "--force", "Don't ask for remove blog"
54
+ srm.option "all", "--all", "Remove all built sites."
55
+ srm.option "full", "--full", "Remove all built and source site/s. This option can be used with the rest of options."
52
56
 
53
57
  srm.action do |args, options|
54
58
  MrHyde::Commands::Remove.process(args, options)
@@ -57,17 +61,59 @@ Mercenary.program(:mrhyde) do |p|
57
61
 
58
62
  site.command(:build) do |sbuild|
59
63
  sbuild.syntax "build name[ name ... n] "
60
- sbuild.description "Build the named blog or blogs, by default if no name is indicated then all blog will be built"
64
+ sbuild.description "Build the named site or sites. By default if no name is indicated then all sites will be build."
61
65
 
62
- sbuild.option "all", "--all", "Build all blogs"
66
+ sbuild.option "all", "--all", "Build all nested sites"
63
67
 
64
68
  sbuild.action do |args, options|
65
69
  MrHyde::Commands::Build.process args, options
66
70
  end
67
71
  end
68
-
69
72
  end
73
+
74
+ p.command(:serve) do |serve|
75
+ serve.syntax "serve [options]"
76
+ serve.description "Serve your site locally"
77
+ serve.alias :server
78
+
79
+ serve.option 'detach', '-B', '--detach', 'Run the server in the background (detach)'
80
+ serve.option 'port', '-P', '--port [PORT]', 'Port to listen on'
81
+ serve.option 'host', '-H', '--host [HOST]', 'Host to bind to'
82
+ serve.option 'baseurl', '-b', '--baseurl [URL]', 'Base URL'
83
+ serve.option 'skip_initial_build', '--skip-initial-build', 'Skips the initial site build which occurs before the server is started.'
84
+
85
+ serve.action do |args, options|
86
+ options["serving"] = true
87
+ options["watch"] = true unless options.key?("watch")
88
+ MrHyde::Commands::Build.process(options['all'] = 'all') if options['build']
89
+ MrHyde::Commands::Serve.process(options)
90
+ end
91
+ end
92
+
93
+
94
+ p.command(:build) do |build|
95
+ build.syntax "build"
96
+ build.description "Build the main site"
97
+
98
+ build.option "full", "--full", "Builds main site and nested sites."
99
+
100
+ build.action do |args, options|
101
+ options['main'] = true
102
+ MrHyde::Commands::Build.process args, options
103
+ end
104
+ end
70
105
 
106
+ p.command(:list) do |list|
107
+ list.syntax "list"
108
+ list.description "Shows a list of all sites within sources."
109
+
110
+ list.option "built", "--built", "Shows a list of built sites."
111
+
112
+ list.action do |args, options|
113
+ MrHyde::Commands::List.process options
114
+ end
115
+ end
116
+
71
117
  p.action do |args, options|
72
118
  if args.empty?
73
119
  puts p
@@ -4,7 +4,7 @@ require "mr_hyde"
4
4
  require "mr_hyde/configuration"
5
5
  require "mr_hyde/extensions/new"
6
6
  require "mr_hyde/command"
7
- require "mr_hyde/blog"
7
+ require "mr_hyde/site"
8
8
 
9
9
  module MrHyde
10
10
  module Commands
@@ -12,7 +12,8 @@ module MrHyde
12
12
  class << self
13
13
  # Options
14
14
  def process(args, opts = {})
15
- MrHyde::Blog.build args, opts
15
+ MrHyde::Site.build args, opts
16
+ MrHyde.logger.info "Built process is fisished, you can look the result in '#{MrHyde.destination}' folder"
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,41 @@
1
+ require "mr_hyde/command"
2
+ require "mr_hyde/site"
3
+
4
+ module MrHyde
5
+ module Commands
6
+ class List < MrHyde::Command
7
+ class << self
8
+
9
+ def process(opts)
10
+ MrHyde.configuration
11
+
12
+ if opts['built']
13
+ show_built_sites
14
+ else
15
+ show_sources_sites
16
+ end
17
+ end
18
+
19
+ def show_built_sites
20
+ if File.exist? MrHyde.destination
21
+ show_list "Built sites (#{MrHyde.destination})", Site.built_list
22
+ else
23
+ MrHyde.logger.warn "Still there is not a built site"
24
+ end
25
+ end
26
+
27
+ def show_sources_sites
28
+ show_list "Source Sites (#{MrHyde.sources_sites})", Site.sources_list
29
+ end
30
+
31
+ def show_list(title, list)
32
+ MrHyde.logger.info "#{title}\n#{'-' * title.length}"
33
+ list.each do |site|
34
+ MrHyde.logger.info site
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -6,18 +6,13 @@ require "mr_hyde"
6
6
  require "mr_hyde/configuration"
7
7
  require "mr_hyde/extensions/new"
8
8
  require "mr_hyde/command"
9
- require "mr_hyde/blog"
9
+ require "mr_hyde/site"
10
10
 
11
11
  module MrHyde
12
12
  module Commands
13
13
  class New < MrHyde::Command
14
14
  class << self
15
- # Options
16
- # :type => what type of element we want to create [:blog|:site]
17
- # by default it creates a new MrHyde site
18
- # if :type is :blog then
19
- # :name => blog's name
20
- #
15
+
21
16
  def process(args, opts = {})
22
17
  case args.delete(:type)
23
18
  when :site then new_site(args[:args], opts)
@@ -29,13 +24,12 @@ module MrHyde
29
24
 
30
25
  def scaffold(args, opts)
31
26
  new_site_path = MrHyde.create args, opts
32
- MrHyde.logger.info "New Mr. Hyde Site installed in #{new_site_path}"
33
27
  rescue SystemExit => se
34
28
  MrHyde.logger.abort_with "Conflict:", se.message
35
29
  end
36
30
 
37
31
  def new_site(args, opts)
38
- Blog.create(args, opts)
32
+ Site.create(args, opts)
39
33
  end
40
34
  end
41
35
  end
@@ -1,12 +1,12 @@
1
1
  require "mr_hyde/command"
2
- require "mr_hyde/blog"
2
+ require "mr_hyde/site"
3
3
 
4
4
  module MrHyde
5
5
  module Commands
6
6
  class Remove < MrHyde::Command
7
7
  class << self
8
8
  def process(args, opts = {})
9
- Blog.remove args, opts
9
+ Site.remove args, opts
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,26 @@
1
+ require "fileutils"
2
+
3
+ require "jekyll"
4
+ require "jekyll/stevenson"
5
+ require "jekyll/commands/serve"
6
+
7
+ require "mr_hyde"
8
+ require "mr_hyde/configuration"
9
+
10
+ module MrHyde
11
+ module Commands
12
+ class Serve < MrHyde::Command
13
+ class << self
14
+ def process(opts = {})
15
+ opts = MrHyde.configuration(opts)
16
+ unless File.exist? MrHyde.destination
17
+ MrHyde.logger.abort_with "Cannot start server: There is no built content"
18
+ end
19
+ ENV['JEKYLL_LOG_LEVEL'] = 'info'
20
+ Jekyll.logger = Stevenson.new
21
+ Jekyll::Commands::Serve.process opts
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -5,12 +5,24 @@ module MrHyde
5
5
  class Configuration < Jekyll::Configuration
6
6
 
7
7
  DEFAULTS = {
8
- 'sources' => 'sources',
9
- 'destination' => 'site',
10
- 'config' => '_mrhyde.yml',
11
- 'jekyll_config' => '_jekyll.yml'
8
+ # Places
9
+ 'source' => Dir.pwd,
10
+ 'sources' => 'sources',
11
+ 'sources_sites' => '_sites',
12
+ 'destination' => 'site',
13
+ 'layouts' => '_layouts',
14
+ 'includes' => '_includes',
15
+ 'config' => '_mrhyde.yml',
16
+ 'jekyll_config' => '_config.yml',
17
+ 'assets' => '_assets',
18
+ 'mainsite' => 'main_site',
19
+ # Serving
20
+ 'detach' => false, # default to not detaching the server
21
+ 'port' => '4000',
22
+ 'host' => '127.0.0.1',
23
+ 'baseurl' => ''
12
24
  }
13
-
25
+
14
26
  def read_config_files(files)
15
27
  configuration = clone
16
28
 
@@ -5,6 +5,10 @@ module MrHyde
5
5
  module Extensions
6
6
  class New < Jekyll::Commands::New
7
7
  class << self
8
+ def subsite_template
9
+ File.expand_path "../../subsite_template", File.dirname(__FILE__)
10
+ end
11
+
8
12
  def template
9
13
  site_template
10
14
  end
@@ -13,10 +17,58 @@ module MrHyde
13
17
  File.join template, '_config.yml'
14
18
  end
15
19
 
16
- def create_sample_site
17
- create_sample_files
20
+ def process(args, options = {})
21
+ raise ArgumentError.new('You must specify a path.') if args.empty?
22
+
23
+ new_site_path = File.expand_path(args.join(" "), Dir.pwd)
24
+ FileUtils.mkdir_p new_site_path
25
+ if preserve_source_location?(new_site_path, options)
26
+ Jekyll.logger.abort_with "Conflict:", "#{new_site_path} exists and is not empty."
27
+ end
28
+
29
+ if options["blank"]
30
+ create_blank_site new_site_path, options
31
+ elsif options["full"]
32
+ create_independant_sample_files args, options
33
+ else
34
+ create_sample_files new_site_path, options
35
+
36
+ File.open(File.expand_path(initialized_post_name, new_site_path), "w") do |f|
37
+ f.write(scaffold_post_content)
38
+ end
39
+ end
40
+
41
+ Jekyll.logger.info "New jekyll site installed in #{new_site_path}."
42
+ end
43
+
44
+ def create_blank_site(path, opts)
45
+ Dir.chdir(path) do
46
+ FileUtils.mkdir(%w(_posts _drafts))
47
+ FileUtils.touch("index.html")
48
+ end
18
49
  end
19
50
 
51
+ def create_sample_files(path, opts)
52
+ FileUtils.cp_r subsite_template + '/.', path
53
+ FileUtils.cp_r subsite_template + '/_posts', path
54
+ FileUtils.rm File.expand_path(scaffold_path, path)
55
+ end
56
+
57
+ def create_independant_sample_files(args, opts)
58
+ Jekyll::Commands::New.process args, opts
59
+ end
60
+
61
+ def scaffold_post_content
62
+ ERB.new(File.read(File.expand_path(scaffold_path, subsite_template))).result
63
+ end
64
+
65
+ def initialized_post_name
66
+ "_posts/#{Time.now.strftime('%Y-%m-%d')}-welcome-to-mr-hyde.markdown"
67
+ end
68
+
69
+ def scaffold_path
70
+ "_posts/0000-00-00-welcome-to-mr-hyde.markdown.erb"
71
+ end
20
72
  end
21
73
  end
22
74
  end
@@ -0,0 +1,18 @@
1
+ require 'jekyll/converters/scss'
2
+ require 'mr_hyde'
3
+
4
+ include Jekyll
5
+
6
+ module Converters
7
+ class Scss
8
+ alias_method :pristine_sass_load_paths, :sass_load_paths
9
+
10
+ def sass_load_paths
11
+ paths = pristine_sass_load_paths
12
+ common_assets = Jekyll.sanitized_path(File.join(MrHyde.sources, MrHyde.config['assets']), sass_dir)
13
+ paths << common_assets if File.directory? common_assets
14
+
15
+ paths
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'jekyll'
2
+ require 'mr_hyde'
3
+
4
+ module Jekyll
5
+ class << self
6
+
7
+ def logger
8
+ @logger ||= LogAdapter.new(Stevenson.new, (ENV['JEKYLL_LOG_LEVEL'] || :error).to_sym)
9
+ end
10
+
11
+ def logger=(writer)
12
+ @logger = LogAdapter.new(writer, (ENV['JEKYLL_LOG_LEVEL'] || :error).to_sym)
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,47 @@
1
+ require 'jekyll/site'
2
+ require 'mr_hyde'
3
+
4
+ include Jekyll
5
+
6
+ class Site
7
+ alias_method :pristine_site_payload, :site_payload
8
+
9
+ # First try to find the file referenced in the jekyll folder (by default _config.yml),
10
+ # in case is not there, then try to find it in the mrhyde folder (by default _config.yml)
11
+ def in_source_dir(*paths)
12
+ file_path = paths.reduce(source) do |base, path|
13
+ Jekyll.sanitized_path(base, path)
14
+ end
15
+ unless File.exist? file_path
16
+ file_path = paths.reduce(MrHyde.source) do |base, path|
17
+ Jekyll.sanitized_path(base, path)
18
+ end
19
+ end
20
+ file_path
21
+ end
22
+
23
+
24
+ # This patching ensures that if the site is the main, then adds to the payload
25
+ # the sites value containing the sites payloads info within sources sites.
26
+ def site_payload
27
+ payload = pristine_site_payload
28
+
29
+ if source == MrHyde.main_site
30
+ site_names = MrHyde.built_list
31
+
32
+ unless site_names.empty?
33
+ sites_payload = site_names.map do |site_name|
34
+ opts = MrHyde.site_configuration(site_name)
35
+ opts = Jekyll.configuration(opts)
36
+ site = Site.new opts
37
+
38
+ Utils.deep_merge_hashes site.site_payload['site'], { 'name' => site_name }
39
+ end
40
+ payload['site'] = Utils.deep_merge_hashes(payload['site'], { 'sites' => sites_payload })
41
+ end
42
+ end
43
+
44
+ payload
45
+ end
46
+
47
+ end
@@ -0,0 +1,23 @@
1
+ require 'jekyll/tags/include'
2
+ require 'mr_hyde'
3
+
4
+ include Jekyll
5
+
6
+ module Tags
7
+ class IncludeTag
8
+ =begin
9
+ def tag_includes_dir
10
+ File.join MrHyde.sources, MrHyde.config['includes']
11
+ =end
12
+
13
+ def resolved_includes_dir(context)
14
+ path = File.join(File.realpath(context.registers[:site].source), @includes_dir)
15
+
16
+ unless File.directory? path
17
+ path = File.join(File.realpath(MrHyde.source), MrHyde.sources, @includes_dir)
18
+ end
19
+
20
+ path
21
+ end
22
+ end
23
+ end