maglove 2.0.4 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/{vendor → assets}/autoprefixer.js +0 -0
  3. data/{data/maglove → assets}/export.haml +0 -0
  4. data/{data/maglove → assets}/hpub/index.css +0 -0
  5. data/{data/maglove → assets}/hpub/index.haml +0 -0
  6. data/{data/maglove → assets}/hpub/page.haml +0 -0
  7. data/{data/maglove → assets}/index.haml +0 -0
  8. data/{data/maglove → assets}/maglove.css +0 -0
  9. data/{data/maglove → assets}/maglove.haml +0 -0
  10. data/{data/maglove → assets}/maglove.js +1 -1
  11. data/{data/maglove → assets}/scaffold/base/base.coffee +0 -0
  12. data/{data/maglove → assets}/scaffold/base/base.less +0 -0
  13. data/{data/maglove → assets}/scaffold/base/images/base/loading-bars.svg +0 -0
  14. data/{data/maglove → assets}/scaffold/base/less/base/animations.less +0 -0
  15. data/{data/maglove → assets}/scaffold/base/less/base/blockquotes.less +0 -0
  16. data/{data/maglove → assets}/scaffold/base/less/base/buttons.less +0 -0
  17. data/{data/maglove → assets}/scaffold/base/less/base/code.less +0 -0
  18. data/{data/maglove → assets}/scaffold/base/less/base/forms.less +0 -0
  19. data/{data/maglove → assets}/scaffold/base/less/base/global.less +0 -0
  20. data/{data/maglove → assets}/scaffold/base/less/base/grid-minimal.less +0 -0
  21. data/{data/maglove → assets}/scaffold/base/less/base/grid-non-responsive.less +0 -0
  22. data/{data/maglove → assets}/scaffold/base/less/base/grid.less +0 -0
  23. data/{data/maglove → assets}/scaffold/base/less/base/helpers.less +0 -0
  24. data/{data/maglove → assets}/scaffold/base/less/base/images.less +0 -0
  25. data/{data/maglove → assets}/scaffold/base/less/base/lists.less +0 -0
  26. data/{data/maglove → assets}/scaffold/base/less/base/mixins.less +0 -0
  27. data/{data/maglove → assets}/scaffold/base/less/base/print.less +0 -0
  28. data/{data/maglove → assets}/scaffold/base/less/base/resets.less +0 -0
  29. data/{data/maglove → assets}/scaffold/base/less/base/tables.less +0 -0
  30. data/{data/maglove → assets}/scaffold/base/less/core/alignments.less +0 -0
  31. data/{data/maglove → assets}/scaffold/base/less/core/cleanup.less +0 -0
  32. data/{data/maglove → assets}/scaffold/base/less/core/editor.less +0 -0
  33. data/{data/maglove → assets}/scaffold/base/less/core/typography.less +0 -0
  34. data/{data/maglove → assets}/scaffold/base/less/vendor/flex-video.less +0 -0
  35. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome.less +0 -0
  36. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/animated.less +0 -0
  37. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/bordered-pulled.less +0 -0
  38. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/core.less +0 -0
  39. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/fixed-width.less +0 -0
  40. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/font-awesome.less +0 -0
  41. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/icons.less +0 -0
  42. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/larger.less +0 -0
  43. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/list.less +0 -0
  44. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/mixins.less +0 -0
  45. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/rotated-flipped.less +0 -0
  46. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/stacked.less +0 -0
  47. data/{data/maglove → assets}/scaffold/base/less/vendor/font-awesome/variables.less +0 -0
  48. data/{data/maglove → assets}/scaffold/base/less/vendor/image-loader.less +0 -0
  49. data/{data/maglove → assets}/scaffold/base/less/vendor/magnific-popup.less +0 -0
  50. data/{data/maglove → assets}/scaffold/base/less/widgets/banner.less +0 -0
  51. data/{data/maglove → assets}/scaffold/base/less/widgets/button.less +0 -0
  52. data/{data/maglove → assets}/scaffold/base/less/widgets/callout.less +0 -0
  53. data/{data/maglove → assets}/scaffold/base/less/widgets/columns.less +0 -0
  54. data/{data/maglove → assets}/scaffold/base/less/widgets/container.less +0 -0
  55. data/{data/maglove → assets}/scaffold/base/less/widgets/feedback.less +0 -0
  56. data/{data/maglove → assets}/scaffold/base/less/widgets/heading.less +0 -0
  57. data/{data/maglove → assets}/scaffold/base/less/widgets/horizontal_rule.less +0 -0
  58. data/{data/maglove → assets}/scaffold/base/less/widgets/image.less +0 -0
  59. data/{data/maglove → assets}/scaffold/base/less/widgets/paragraph.less +0 -0
  60. data/{data/maglove → assets}/scaffold/base/variables.less +0 -0
  61. data/{data/maglove → assets}/scaffold/base/vendor/jquery.js +0 -0
  62. data/{data/maglove → assets}/scaffold/theme/images/logo.png +0 -0
  63. data/{data/maglove → assets}/scaffold/theme/images/pattern/symphony.png +0 -0
  64. data/{data/maglove → assets}/scaffold/theme/less/base/variables.less +0 -0
  65. data/{data/maglove → assets}/scaffold/theme/templates/article-01.haml +3 -3
  66. data/{data/maglove → assets}/scaffold/theme/templates/cover.haml +0 -0
  67. data/{data/maglove → assets}/scaffold/theme/templates/toc.haml +1 -1
  68. data/{data/maglove → assets}/scaffold/theme/templates/toc.yml +0 -0
  69. data/{data/maglove → assets}/scaffold/theme/theme.coffee +0 -0
  70. data/{data/maglove → assets}/scaffold/theme/theme.less +0 -0
  71. data/{data/maglove → assets}/thumbnail.haml +0 -0
  72. data/{data/maglove → assets}/thumbnail.js +0 -0
  73. data/bin/maglove +0 -6
  74. data/lib/magloft/api_caller.rb +12 -12
  75. data/lib/magloft/remote_resource.rb +17 -17
  76. data/lib/maglove.rb +19 -19
  77. data/lib/maglove/asset/theme.rb +7 -6
  78. data/lib/maglove/commands/assets.rb +61 -44
  79. data/lib/maglove/commands/base.rb +5 -1
  80. data/lib/maglove/commands/fonts.rb +9 -6
  81. data/lib/maglove/commands/main.rb +3 -1
  82. data/lib/maglove/commands/theme.rb +63 -58
  83. data/lib/maglove/middleware/live_reload.rb +19 -11
  84. data/lib/maglove/server.rb +18 -8
  85. data/lib/maglove/theme.rb +27 -0
  86. data/lib/maglove/tilt/coffee_template.rb +1 -1
  87. data/lib/maglove/tilt/haml_template.rb +2 -3
  88. data/lib/maglove/tilt/js_template.rb +1 -2
  89. data/lib/maglove/tilt/scss_template.rb +3 -9
  90. data/lib/maglove/tilt/yaml_template.rb +2 -3
  91. data/lib/maglove/version.rb +1 -1
  92. data/lib/powersnap.rb +1 -3
  93. metadata +164 -155
  94. data/.gitignore +0 -9
  95. data/.rubocop.yml +0 -157
  96. data/Gemfile +0 -3
  97. data/Gemfile.lock +0 -206
  98. data/README.md +0 -26
  99. data/lib/block_resolver.rb +0 -6
  100. data/lib/maglove/application.rb +0 -58
  101. data/lib/maglove/phantom_script.rb +0 -44
  102. data/lib/maglove/workspace.rb +0 -41
  103. data/lib/workspace.rb +0 -11
  104. data/lib/workspace/workspace_dir.rb +0 -98
  105. data/lib/workspace/workspace_dir/archive.rb +0 -18
  106. data/lib/workspace/workspace_file.rb +0 -127
  107. data/lib/workspace/workspace_file/archive.rb +0 -45
  108. data/lib/workspace/workspace_file/media.rb +0 -19
  109. data/lib/workspace/workspace_file/net.rb +0 -18
  110. data/lib/workspace/workspace_file/parse.rb +0 -21
  111. data/maglove.gemspec +0 -45
@@ -1,44 +0,0 @@
1
- require 'tempfile'
2
-
3
- module MagLove
4
- class PhantomScript
5
- attr_accessor :running, :script, :options, :path, :log_file
6
-
7
- def initialize(script, options = {})
8
- @running = false
9
- @script = script
10
- @options = options.merge({
11
- script_path: Gem.datadir("maglove")
12
- })
13
- @path = File.absolute_path(File.join(@options[:script_path], "#{@script}.js"))
14
- throw "Script #{script} not found at #{@path}" unless File.exist?(@path)
15
- @log_file = Tempfile.new('pslog')
16
- end
17
-
18
- def run(*args)
19
- start = Time.now
20
- @running = true
21
- cmd = "phantomjs #{@path} #{@log_file.path} #{args.join(' ')}"
22
-
23
- # log phantomjs info
24
- @log_thread = Thread.new do
25
- f = File.open(@log_file.path, "r")
26
- f.seek(0, IO::SEEK_END)
27
- puts "phantom@0ms ▸ (start)"
28
- while @running
29
- select([f])
30
- line = f.gets
31
- puts "phantom@#{((Time.now - start) * 1000.0).to_i}ms ▸ #{line}" if line
32
- end
33
- end
34
-
35
- # run command and return result
36
- result = `#{cmd}`
37
- @running = false
38
- result == "ERROR" ? false : result
39
- ensure
40
- @log_file.close
41
- @log_file.unlink
42
- end
43
- end
44
- end
@@ -1,41 +0,0 @@
1
- module Workspace
2
- def theme_dir(root: "src", theme: options[:theme])
3
- workspace_dir("#{root}/themes/#{theme}")
4
- end
5
-
6
- def theme_file(path, root: "src", theme: options[:theme])
7
- workspace_file("#{root}/themes/#{theme}", path)
8
- end
9
-
10
- def theme_base_file(path, theme: options[:theme])
11
- theme_base_dir(theme: theme).file(path)
12
- end
13
-
14
- def theme_base_dir(theme: options[:theme])
15
- base_version = theme_config(:base_version, theme: theme)
16
- workspace_dir("src/base/#{base_version}")
17
- end
18
-
19
- def gem_dir
20
- workspace_dir(Gem.datadir("maglove"))
21
- end
22
-
23
- def theme_config(key = nil, theme: options[:theme])
24
- Maglove.theme_config(key, theme)
25
- end
26
-
27
- class WorkspaceFile
28
- def asset(theme: workspace_theme, base: false, asset_uri: ".")
29
- MagLove::Asset::Theme.new(path, { theme: theme, base: base, asset_uri: asset_uri })
30
- end
31
-
32
- def workspace_theme
33
- match = self.workspace.match(%r{/themes/([^/]+)})
34
- match ? match[1] : nil
35
- end
36
-
37
- def read_hamloft(options = {})
38
- Hamloft.render(read, options)
39
- end
40
- end
41
- end
data/lib/workspace.rb DELETED
@@ -1,11 +0,0 @@
1
- require "workspace/workspace_dir"
2
- require "workspace/workspace_file"
3
- module Workspace
4
- def workspace_dir(workspace, path = "")
5
- Workspace::WorkspaceDir.new(workspace, path)
6
- end
7
-
8
- def workspace_file(workspace, path = "")
9
- Workspace::WorkspaceFile.new(workspace, path)
10
- end
11
- end
@@ -1,98 +0,0 @@
1
- require 'workspace/workspace_dir/archive'
2
- module Workspace
3
- class WorkspaceDir
4
- include Workspace::WorkspaceDir::Archive
5
-
6
- attr_accessor :workspace, :path
7
-
8
- def initialize(workspace, path = "")
9
- @workspace = workspace
10
- @path = path
11
- end
12
-
13
- def to_s
14
- File.join(@workspace, @path)
15
- end
16
-
17
- def name
18
- File.basename(to_s)
19
- end
20
-
21
- def create
22
- FileUtils.mkdir_p(to_s)
23
- self
24
- end
25
-
26
- def exists?
27
- File.directory?(to_s)
28
- end
29
-
30
- def copy(target_dir)
31
- target_dir.parent_dir.create unless target_dir.parent_dir.exists?
32
- FileUtils.cp_r(to_s, target_dir.to_s)
33
- end
34
-
35
- def delete!
36
- FileUtils.rm_rf(to_s)
37
- end
38
-
39
- def reset!
40
- delete!
41
- create
42
- end
43
-
44
- def file(file_path)
45
- WorkspaceFile.new(@workspace, File.join(@path, file_path))
46
- end
47
-
48
- def dir(dir_path)
49
- self.class.new(@workspace, File.join(@path, dir_path))
50
- end
51
-
52
- def root_dir
53
- self.class.new(@workspace, "")
54
- end
55
-
56
- def chdir(target_dir = nil)
57
- if target_dir.nil?
58
- self.class.new(to_s, "")
59
- else
60
- self.class.new(dir(target_dir).to_s, "")
61
- end
62
- end
63
-
64
- def parent_dir
65
- root_dir.dir(File.expand_path("..", @path))
66
- end
67
-
68
- def children
69
- entries = []
70
- Dir.chdir(to_s) do
71
- Dir["*"].each do |path|
72
- entries.push(dir(path))
73
- end
74
- end
75
- entries
76
- end
77
-
78
- def files(glob = "*")
79
- entries = []
80
- Dir.chdir(to_s) do
81
- Dir[glob].each do |path|
82
- entries.push(file(path))
83
- end
84
- end
85
- entries
86
- end
87
-
88
- def each_dir(&block)
89
- children.each do |subdir|
90
- yield(subdir)
91
- end
92
- end
93
-
94
- def absolute_path
95
- File.absolute_path(to_s)
96
- end
97
- end
98
- end
@@ -1,18 +0,0 @@
1
- module Workspace
2
- class WorkspaceDir
3
- module Archive
4
- extend ActiveSupport::Concern
5
-
6
- def compress_zip(target_file)
7
- target_file.delete!
8
- require "zip"
9
- Zip::File.open(target_file.to_s, 'w') do |zipfile|
10
- Dir["#{self}/**/**"].each do |file|
11
- zipfile.add(file.sub("#{self}/", ''), file)
12
- end
13
- end
14
- self
15
- end
16
- end
17
- end
18
- end
@@ -1,127 +0,0 @@
1
- require 'cssminify'
2
- require 'closure-compiler'
3
- require 'workspace/workspace_file/archive'
4
- require 'workspace/workspace_file/media'
5
- require 'workspace/workspace_file/net'
6
- require 'workspace/workspace_file/parse'
7
-
8
- module Workspace
9
- class WorkspaceFile
10
- include Workspace::WorkspaceFile::Archive
11
- include Workspace::WorkspaceFile::Media
12
- include Workspace::WorkspaceFile::Net
13
- include Workspace::WorkspaceFile::Parse
14
-
15
- attr_accessor :workspace, :path
16
-
17
- def initialize(workspace, path)
18
- @workspace = workspace
19
- @path = path
20
- end
21
-
22
- def set(data)
23
- @contents = data
24
- self
25
- end
26
-
27
- def contents
28
- @contents ||= read
29
- end
30
-
31
- def replace(key, value)
32
- contents.gsub!(key, value)
33
- self
34
- end
35
-
36
- def write(data = nil)
37
- data ||= @contents
38
- dir.create unless dir.exists?
39
- File.open(to_s, "wb") { |file| file << data }
40
- self
41
- end
42
-
43
- def copy(target_file)
44
- target_file.dir.create unless target_file.dir.exists?
45
- FileUtils.cp(to_s, target_file.to_s)
46
- end
47
-
48
- def move(target_file)
49
- target_file.dir.create unless target_file.dir.exists?
50
- FileUtils.mv(to_s, target_file.to_s)
51
- end
52
-
53
- def to_s
54
- File.join(@workspace, @path)
55
- end
56
-
57
- def relative_path
58
- @path.sub(%r{^/}, "")
59
- end
60
-
61
- def exists?
62
- File.exist?(to_s) and !File.directory?(to_s)
63
- end
64
-
65
- def read
66
- File.open(to_s).read
67
- end
68
-
69
- def dir
70
- Workspace::WorkspaceDir.new(@workspace, File.dirname(@path))
71
- end
72
-
73
- def md5
74
- Digest::MD5.hexdigest(read)
75
- end
76
-
77
- def url
78
- "file://#{absolute_path}"
79
- end
80
-
81
- def delete!
82
- FileUtils.rm_f(to_s)
83
- end
84
-
85
- def basename
86
- File.basename(path, ".*")
87
- end
88
-
89
- def slug
90
- relative_path.chomp(File.extname(self.relative_path))
91
- end
92
-
93
- def extension
94
- File.extname(to_s).gsub(/^\./, "")
95
- end
96
-
97
- def rename!(filename)
98
- FileUtils.mv(to_s, dir.file(filename).to_s) if exists?
99
- @path = dir.file(filename).path
100
- end
101
-
102
- def absolute_path
103
- File.absolute_path(to_s)
104
- end
105
-
106
- def size
107
- File.size(to_s)
108
- end
109
-
110
- def minify
111
- if extension == "js"
112
- set(Closure::Compiler.new.compile(contents))
113
- elsif extension == "css"
114
- runtime = ExecJS.compile(Pathname(File.dirname(__FILE__)).join("../../vendor/autoprefixer.js").read)
115
- results = runtime.call("(function(css) { return autoprefixer.process(css).css; })", [contents])
116
- set(CSSminify.compress(results))
117
- end
118
- self
119
- end
120
-
121
- def minify!
122
- minify.write
123
- self
124
- end
125
-
126
- end
127
- end
@@ -1,45 +0,0 @@
1
- module Workspace
2
- class WorkspaceFile
3
- module Archive
4
- extend ActiveSupport::Concern
5
-
6
- def extract(target_dir)
7
- target_dir.create
8
- if extension == "zip"
9
- extract_zip(target_dir)
10
- elsif extension == "gz"
11
- extract_gz(target_dir)
12
- end
13
- self
14
- end
15
-
16
- private
17
-
18
- def extract_zip(target_dir)
19
- require "zip"
20
- Zip::File.open(to_s) do |archive|
21
- archive.each do |entry|
22
- entry.extract(File.join(target_dir.to_s, entry.name))
23
- end
24
- end
25
- end
26
-
27
- def extract_gz(target_dir)
28
- require 'rubygems/package'
29
- workspace_dir = target_dir.root_dir
30
- archive = Gem::Package::TarReader.new(Zlib::GzipReader.open(to_s))
31
- archive.rewind
32
- archive.each do |entry|
33
- if entry.directory?
34
- archive_dir = workspace_dir.dir(entry.full_name)
35
- archive_dir.create
36
- elsif entry.file?
37
- archive_file = workspace_dir.file(entry.full_name)
38
- archive_file.write(entry.read)
39
- end
40
- end
41
- archive.close
42
- end
43
- end
44
- end
45
- end
@@ -1,19 +0,0 @@
1
- module Workspace
2
- class WorkspaceFile
3
- module Media
4
- extend ActiveSupport::Concern
5
-
6
- def image?
7
- ["jpg", "jpeg", "gif", "png"].include?(extension)
8
- end
9
-
10
- def video?
11
- ["mp4"].include?(extension)
12
- end
13
-
14
- def audio?
15
- ["mp3"].include?(extension)
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- require "open-uri"
2
- require "open_uri_redirections"
3
-
4
- module Workspace
5
- class WorkspaceFile
6
- module Net
7
- extend ActiveSupport::Concern
8
-
9
- def download(url)
10
- url = "http:#{url}" if url[0..1] == "//"
11
- contents = open(url, { ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, allow_redirections: :safe }).read
12
- dir.create unless dir.exists?
13
- write(contents)
14
- self
15
- end
16
- end
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- module Workspace
2
- class WorkspaceFile
3
- module Parse
4
- extend ActiveSupport::Concern
5
-
6
- def read_json
7
- JSON.parse(read)
8
- end
9
-
10
- def read_yaml
11
- Psych.load_file(to_s)
12
- end
13
-
14
- def read_haml(options)
15
- require "haml"
16
- engine = Haml::Engine.new(read)
17
- engine.render(Object.new, options)
18
- end
19
- end
20
- end
21
- end