octopress 3.0.0.alpha2 → 3.0.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +15 -18
  3. data/Gemfile +3 -1
  4. data/LICENSE +20 -0
  5. data/README.md +66 -0
  6. data/Rakefile +1 -76
  7. data/bin/octopress +14 -58
  8. data/lib/octopress.rb +40 -79
  9. data/lib/octopress/command.rb +10 -4
  10. data/lib/octopress/commands/new.rb +50 -12
  11. data/lib/octopress/commands/publish.rb +18 -0
  12. data/lib/octopress/core_ext.rb +1 -0
  13. data/lib/octopress/draft.rb +43 -0
  14. data/lib/octopress/page.rb +109 -0
  15. data/lib/octopress/post.rb +30 -0
  16. data/lib/octopress/version.rb +1 -1
  17. data/octopress.gemspec +7 -32
  18. metadata +31 -437
  19. data/.editorconfig +0 -22
  20. data/.gitattributes +0 -1
  21. data/.powrc +0 -4
  22. data/.rspec +0 -5
  23. data/.rubocop.yml +0 -119
  24. data/.slugignore +0 -3
  25. data/.travis.yml +0 -6
  26. data/CHANGELOG.markdown +0 -46
  27. data/CONTRIBUTING.markdown +0 -17
  28. data/README.markdown +0 -37
  29. data/lib/console +0 -17
  30. data/lib/guard/jekyll.rb +0 -33
  31. data/lib/octopress/commands.rb +0 -14
  32. data/lib/octopress/commands/build.rb +0 -17
  33. data/lib/octopress/commands/build_javascripts.rb +0 -11
  34. data/lib/octopress/commands/build_jekyll.rb +0 -42
  35. data/lib/octopress/commands/build_stylesheets.rb +0 -13
  36. data/lib/octopress/commands/install.rb +0 -44
  37. data/lib/octopress/commands/scaffold.rb +0 -102
  38. data/lib/octopress/commands/serve.rb +0 -25
  39. data/lib/octopress/configuration.rb +0 -237
  40. data/lib/octopress/dependency_installer.rb +0 -287
  41. data/lib/octopress/errors.rb +0 -3
  42. data/lib/octopress/filters/content.rb +0 -66
  43. data/lib/octopress/filters/date.rb +0 -46
  44. data/lib/octopress/filters/post.rb +0 -175
  45. data/lib/octopress/filters/url.rb +0 -34
  46. data/lib/octopress/formatters.rb +0 -9
  47. data/lib/octopress/formatters/base_formatter.rb +0 -17
  48. data/lib/octopress/formatters/simple_formatter.rb +0 -9
  49. data/lib/octopress/formatters/verbose_formatter.rb +0 -9
  50. data/lib/octopress/generators/category_generator.rb +0 -196
  51. data/lib/octopress/generators/sitemap_generator.rb +0 -308
  52. data/lib/octopress/guardfile +0 -43
  53. data/lib/octopress/helpers/titlecase.rb +0 -37
  54. data/lib/octopress/ink.rb +0 -12
  55. data/lib/octopress/inquirable_string.rb +0 -12
  56. data/lib/octopress/installer.rb +0 -96
  57. data/lib/octopress/js_assets_manager.rb +0 -97
  58. data/lib/octopress/liquid_helpers/conditional.rb +0 -36
  59. data/lib/octopress/liquid_helpers/config.rb +0 -58
  60. data/lib/octopress/liquid_helpers/include.rb +0 -33
  61. data/lib/octopress/liquid_helpers/url.rb +0 -29
  62. data/lib/octopress/liquid_helpers/vars.rb +0 -30
  63. data/lib/octopress/plugin.rb +0 -33
  64. data/lib/octopress/rake.rb +0 -16
  65. data/lib/octopress/scaffold/.gitignore +0 -18
  66. data/lib/octopress/scaffold/site/Gemfile +0 -3
  67. data/lib/octopress/scaffold/site/config.ru +0 -25
  68. data/lib/octopress/scaffold/site/config/compass.rb +0 -27
  69. data/lib/octopress/scaffold/site/config/rack.rb +0 -25
  70. data/lib/octopress/scaffold/site/config/site.yml +0 -0
  71. data/lib/octopress/scaffold/site/javascripts/lib/ios-rotate-scaling-fix.js +0 -19
  72. data/lib/octopress/scaffold/site/javascripts/lib/jquery-1.9.1.js +0 -9598
  73. data/lib/octopress/scaffold/site/javascripts/lib/jquery.cookie.js +0 -93
  74. data/lib/octopress/scaffold/site/stylesheets/_config.scss +0 -1
  75. data/lib/octopress/scaffold/site/stylesheets/_style.scss +0 -1
  76. data/lib/octopress/scaffold/site/stylesheets/site.scss +0 -16
  77. data/lib/octopress/tags/assign.rb +0 -34
  78. data/lib/octopress/tags/capture.rb +0 -31
  79. data/lib/octopress/tags/config-tag.rb +0 -23
  80. data/lib/octopress/tags/include.rb +0 -63
  81. data/lib/octopress/tags/js-assets.rb +0 -23
  82. data/lib/octopress/tags/puts.rb +0 -39
  83. data/lib/octopress/tags/render-partial.rb +0 -89
  84. data/lib/octopress/tags/return.rb +0 -21
  85. data/lib/rake/clean.rake +0 -8
  86. data/lib/rake/clobber.rake +0 -5
  87. data/lib/rake/console.rake +0 -5
  88. data/lib/rake/deploy.rake +0 -4
  89. data/lib/rake/gen_deploy.rake +0 -2
  90. data/lib/rake/generate.rake +0 -4
  91. data/lib/rake/generate_only.rake +0 -14
  92. data/lib/rake/hygiene.rake +0 -29
  93. data/lib/rake/install.rake +0 -8
  94. data/lib/rake/integrate.rake +0 -4
  95. data/lib/rake/isolate.rake +0 -13
  96. data/lib/rake/list_drafts.rake +0 -7
  97. data/lib/rake/new.rake +0 -7
  98. data/lib/rake/new_page.rake +0 -49
  99. data/lib/rake/new_post.rake +0 -32
  100. data/lib/rake/nuke.rake +0 -4
  101. data/lib/rake/preview.rake +0 -4
  102. data/lib/rake/push.rake +0 -37
  103. data/lib/rake/rsync.rake +0 -20
  104. data/lib/rake/set_root_dir.rake +0 -35
  105. data/lib/rake/setup_github_pages.rake +0 -115
  106. data/lib/rake/watch.rake +0 -11
  107. data/lib/scaffold/Rakefile +0 -142
  108. data/lib/scaffold/plugin-name.gemspec +0 -43
  109. data/lib/spec/fixtures/env/defaults/classic.yml +0 -2
  110. data/lib/spec/fixtures/no_override/defaults/classic.yml +0 -11
  111. data/lib/spec/fixtures/override/defaults/classic.yml +0 -11
  112. data/lib/spec/fixtures/override/site.yml +0 -11
  113. data/lib/spec/octopress/configuration_spec.rb +0 -67
  114. data/lib/spec/octopress/dependency_installer_spec.rb +0 -66
  115. data/lib/spec/octopress/ink_spec.rb +0 -10
  116. data/lib/spec/octopress/octopress_spec.rb +0 -97
  117. data/lib/spec/spec_helper.rb +0 -22
  118. data/lib/spec/support/env.rb +0 -36
  119. data/lib/spec/support/simplecov.rb +0 -52
@@ -1,97 +0,0 @@
1
- require 'digest/md5'
2
- require 'stitch-rb'
3
- require 'uglifier'
4
- require 'coffee-script'
5
-
6
- module Octopress
7
- class JSAssetsManager
8
-
9
- attr_reader :config
10
-
11
- def initialize
12
- @js_assets_path = File.join(Octopress.root, "javascripts")
13
-
14
- if Dir.exists? @js_assets_path
15
- unless Octopress.configuration.has_key? :require_js
16
- abort "No :require_js key in configuration. Cannot proceed.".red
17
- end
18
- unless Octopress.configuration[:require_js].has_key? :lib
19
- abort "No :lib key in :require_js configuration. Cannot proceed.".red
20
- end
21
- unless Octopress.configuration[:require_js].has_key? :modules
22
- abort "No :modules key in :require_js configuration. Cannot proceed.".red
23
- end
24
-
25
- @lib_config = Octopress.configuration[:require_js][:lib]
26
- @lib_config = [@lib_config] unless @lib_config.kind_of?(Array)
27
- modules_config = Octopress.configuration[:require_js][:modules]
28
-
29
- # Read js dependencies from require_js.yml configuration
30
- @lib = @lib_config.collect {|item| Dir.glob("#{@js_assets_path}/lib/#{item}") }
31
- @lib.concat(Dir.glob("#{@js_assets_path}/lib/**/*")).flatten.uniq
32
-
33
- @modules = modules_config.collect {|item| "#{@js_assets_path}/#{item}" }.flatten.uniq
34
- @module_files = @modules.collect {|item| Dir[item+'/**/*'] }.flatten.uniq
35
-
36
- else
37
- @js_assets_path = false
38
- end
39
- end
40
-
41
-
42
- def get_fingerprint
43
- Digest::MD5.hexdigest(@module_files.concat(@lib).flatten.uniq.map! { |path| "#{File.mtime(path).to_i}" }.join + @lib_config.join)
44
- end
45
-
46
- def url
47
- @js_assets_path ? "/javascripts/build/" + filename : false
48
- end
49
-
50
- def filename
51
- if @js_assets_path
52
- Octopress.env == 'production' ? "all-#{@fingerprint || get_fingerprint}.js" : "all.js"
53
- else
54
- false
55
- end
56
- end
57
-
58
- def identical(file)
59
- File.size?(file) && File.open(file) {|f| f.readline} =~ /#{@fingerprint}/
60
- end
61
-
62
- def compile
63
- if @js_assets_path
64
- @fingerprint = get_fingerprint
65
-
66
- relative_dir = File.join(Octopress.configuration[:source], "javascripts/build")
67
- dir = File.join(Octopress.root, relative_dir)
68
-
69
- relative_file = File.join(relative_dir, filename)
70
- file = File.join(dir, filename)
71
-
72
- if identical(file)
73
- "identical ".green + relative_file
74
- else
75
- write_msg = (File.exists?(file) ? "overwrite " : " create ").green + relative_file
76
- puts "compiling javascripts..."
77
-
78
- js = Stitch::Package.new(:dependencies => @lib.flatten, :paths => @modules.flatten).compile
79
- js = Uglifier.new.compile js if Octopress.env == 'production'
80
- js = "/* Octopress fingerprint: #{@fingerprint} */\n" + js
81
-
82
- FileUtils.rm_rf dir
83
- FileUtils.mkdir_p dir
84
- File.open(file, 'w') { |f| f.write js }
85
-
86
- write_msg
87
- end
88
- else
89
- '' # return no message no javascripts to compile
90
- end
91
- rescue Exception => e
92
- Octopress.logger.fatal "failed to compile javascripts".red
93
- raise e
94
- end
95
- end
96
- end
97
-
@@ -1,36 +0,0 @@
1
- module Octopress
2
- module Conditional
3
- EXPRESSION = /(.+?)\s+(unless|if)\s+(.+)/i
4
- TERNARY = /(.*?)\(\s*(.+?)\s+\?\s+(.+?)\s+:\s+(.+?)\s*\)(.+?)?/
5
-
6
- def strip_expression(markup, context = false)
7
- if markup =~ TERNARY
8
- result = evaluate_ternary($2, $3, $4, context)
9
- markup = "#{$1} #{result} #{$5}"
10
- end
11
- markup =~ EXPRESSION ? $1 : markup
12
- end
13
-
14
- def evaluate_ternary(expression, if_true, if_false, context)
15
- evaluate('if', expression, context) ? if_true : if_false
16
- end
17
-
18
- def evaluate_expression(markup, context)
19
- if markup =~ EXPRESSION
20
- evaluate($2, $3, context)
21
- else
22
- true
23
- end
24
- end
25
-
26
- def evaluate(type, expression, context)
27
- tag = if type == 'if'
28
- Liquid::If.new('if', expression, ["true","{% endif %}"])
29
- elsif type == 'unless'
30
- Liquid::Unless.new('unless', expression, ["true","{% endunless %}"])
31
- end
32
- result = tag.render(context) != ''
33
- end
34
- end
35
- end
36
-
@@ -1,58 +0,0 @@
1
- module Octopress
2
- module ConfigHelper
3
-
4
- # Static: Reads a configuration.
5
- #
6
- # context - The current site configuration passed from a Liquid tag's context.
7
- # key - The configuration key, eg, url, or twitter.username
8
- #
9
- # Returns a the value for the key, eg: site.key
10
-
11
- def config(context, key)
12
- config = context.registers[:site].config
13
- key.split('.').map { |k| config = config[k] }.last
14
- end
15
-
16
- # Static: Reads a configuration.
17
- #
18
- # context - The current site configuration passed from a Liquid tag's context.
19
- # key - The configuration key, eg, url, or twitter.username
20
- # tag - The name of tag to generate, defaults to 'div'.
21
- # classname - String for classname(s), default to dasherized key, eg foo.bar is foo-bar.
22
- #
23
- # Returns a tag with config values stored as data attributes.
24
-
25
- def config_tag(context, key, tag='div', classname=nil)
26
- value = config(context, key)
27
- key = key.split('.').last
28
- classname ||= key.sub(/_/, '-').sub(/\./, '-')
29
-
30
- "<#{tag} class='#{classname}' #{config_data(key, value)} ></#{tag}>"
31
- end
32
-
33
- # Static: Maps values to data attributes
34
- #
35
- # key - A string used to create "data-#{key}" if values is not an object.
36
- # value - A string or object used to populate values for data attributes.
37
- #
38
- # Returns a string of data attributes.
39
-
40
- def config_data(key, value)
41
- if value.respond_to? 'keys'
42
- data = ''
43
- value.each do |k,v|
44
- data << unless v.nil?
45
- v = v.join ',' if v.respond_to? 'join'
46
- v = v.to_json if v.respond_to? 'keys'
47
- " data-#{k.sub'_','-'}='#{v}'"
48
- end
49
- end
50
- data
51
- elsif value.respond_to? 'join'
52
- " data-#{key}='#{value.join(',')}'"
53
- else
54
- " data-#{key}='#{value}'"
55
- end
56
- end
57
- end
58
- end
@@ -1,33 +0,0 @@
1
- module Octopress
2
- module IncludeHelper
3
- include Conditional
4
-
5
- def render_include(file, context)
6
- tag = Jekyll::Tags::IncludeTag.new('', file, [])
7
- tag.render(context)
8
- end
9
-
10
- def exists(file, context)
11
- base = Pathname.new(context.registers[:site].source || 'source').expand_path
12
- File.exists? File.join(base, "_includes", file)
13
- end
14
-
15
- def get_files(files, context)
16
- files = files.split("||").map do |file|
17
- file = file.strip
18
- context[file].nil? ? file : context[file]
19
- end
20
- end
21
-
22
- def get_include(files, context)
23
- files = get_files(files, context)
24
- files.each_with_index do |f, i|
25
- if exists(f, context)
26
- return f
27
- elsif i == files.size - 1
28
- return f == 'none' ? false : f
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,29 +0,0 @@
1
- require "erb"
2
-
3
- module Octopress
4
- module UrlHelpers
5
- include ERB::Util
6
-
7
- def page_url(context)
8
- url = (context['post'] || context['page'])['url']
9
- prepend_url(url, context['site']['url'])
10
- end
11
-
12
- def encode_url(input)
13
- url_encode input
14
- end
15
-
16
- # Prepend a local url with a file path
17
- # remote urls and urls beginning with ! will be ignored
18
-
19
- def prepend_url(input, path='')
20
- path += '/' unless path.match /\/$/
21
- if input.match /^!/
22
- input.gsub(/^(!)(.+)/, '\2')
23
- else
24
- input.gsub(/^(\/)?([^:]+?)$/, "#{path}"+'\2')
25
- end
26
- end
27
-
28
- end
29
- end
@@ -1,30 +0,0 @@
1
- module Octopress
2
- module VarHelpers
3
- VAR_SYNTAX = /(#{Liquid::VariableSignature}+)\s*(=|\+=)\s*(.*)\s*/o
4
-
5
- def determine_value(vars, context)
6
- vars.each do |var|
7
- rendered = var.render(context)
8
- return rendered unless rendered.nil?
9
- end
10
- nil
11
- end
12
-
13
- def get_value(vars, context)
14
- vars = vars.strip.split("||").map do |v|
15
- Liquid::Variable.new(v.strip)
16
- end
17
- value = determine_value(vars, context)
18
- if value.nil?
19
- var = vars.last.name
20
- if var == 'nil'
21
- nil
22
- else
23
- vars.last.name.gsub /^['"]?((?:.)+?)["']?$/, '\1'
24
- end
25
- else
26
- value
27
- end
28
- end
29
- end
30
- end
@@ -1,33 +0,0 @@
1
- module Octopress
2
- class Plugin
3
- def self.included(subclass)
4
- @plugins ||= []
5
- @plugins << subclass
6
- Octopress.logger.debug "Registering Plugin: #{subclass}"
7
- end
8
-
9
- def self.init!(context)
10
- @plugins.each do |plugin|
11
- if plugin.tasks.size > 0
12
- plugin.tasks.each do |task_file|
13
- context.instance_eval do
14
- load task_file
15
- end
16
- end
17
- end
18
- end
19
- end
20
-
21
- def self.root
22
- self.const_get(:ROOT)
23
- end
24
-
25
- def self.name
26
- self.to_s.underscore
27
- end
28
-
29
- def self.tasks
30
- Dir[File.join(self.root, 'lib', self.name, 'rake', '*.rake')]
31
- end
32
- end
33
- end
@@ -1,16 +0,0 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
- require 'helpers/titlecase'
4
-
5
- module Octopress
6
- class Rake
7
- def self.init!(ctx)
8
- ctx.instance_eval do
9
- tasks_path = File.join(Octopress.lib_root, "rake", "*.rake")
10
- Dir[tasks_path].each do |f|
11
- load f
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,18 +0,0 @@
1
- .bundle
2
- .DS_Store
3
- *.sw[mnop]
4
- *~
5
- /.sass-cache
6
- /.gist-cache
7
- /.pygments-cache
8
- /_deploy
9
- /public
10
- /source/_stash
11
- /source/stylesheets/site.css
12
- /source/javascripts/build
13
- /source/images/icon-*.png
14
- /vendor
15
- /lib/vendor
16
- node_modules
17
- /_config.yml
18
- /config/deploy.yml
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "octopress", "3.0.0.alpha1"
@@ -1,25 +0,0 @@
1
- require 'bundler/setup'
2
- require 'sinatra/base'
3
-
4
- # The project root directory
5
- $root = ::File.dirname(__FILE__)
6
-
7
- class SinatraStaticServer < Sinatra::Base
8
-
9
- get(/.+/) do
10
- send_sinatra_file(request.path) {404}
11
- end
12
-
13
- not_found do
14
- send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404})
15
- end
16
-
17
- def send_sinatra_file(path, &missing_file_block)
18
- file_path = File.join(File.dirname(__FILE__), 'public', path)
19
- file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
20
- File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
21
- end
22
-
23
- end
24
-
25
- run SinatraStaticServer
@@ -1,27 +0,0 @@
1
- $:.unshift File.expand_path("../lib", File.dirname(__FILE__)) # For use/testing when no gem is installed
2
- require "octopress"
3
- require 'sass-globbing'
4
-
5
- config = Octopress.configuration
6
-
7
- project_path = Octopress.root
8
- project_type = :stand_alone
9
-
10
- # Publishing paths
11
- compass_http_path = config[:destination].gsub('public', '')
12
- http_path = compass_http_path
13
- http_images_path = "#{http_path}/images"
14
- http_generated_images_path = "#{http_path}/images"
15
- http_fonts_path = "#{http_path}/fonts"
16
- css_dir = "#{Octopress.root}/#{config[:destination]}/stylesheets"
17
-
18
- # Local development paths
19
- sass_dir = "stylesheets"
20
- images_dir = "#{config[:source]}/images"
21
- fonts_dir = "#{config[:source]}/fonts"
22
- generated_images_dir = "#{config[:source]}/images"
23
-
24
- unless Octopress.env == 'development'
25
- line_comments = false
26
- output_style = :compressed
27
- end
@@ -1,25 +0,0 @@
1
- require 'bundler/setup'
2
- require 'sinatra/base'
3
-
4
- # The project root directory
5
- $root = ::File.dirname(__FILE__)
6
-
7
- class SinatraStaticServer < Sinatra::Base
8
-
9
- get(/.+/) do
10
- send_sinatra_file(request.path) {404}
11
- end
12
-
13
- not_found do
14
- send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404})
15
- end
16
-
17
- def send_sinatra_file(path, &missing_file_block)
18
- file_path = File.join(File.dirname(__FILE__), 'public', path)
19
- file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
20
- File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
21
- end
22
-
23
- end
24
-
25
- run SinatraStaticServer