manic 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -7,7 +7,7 @@ usage
7
7
  ======================================
8
8
  Manic.config do
9
9
  # set global variables
10
- site_title "Ink site yo"
10
+ site_title "Manic static site example
11
11
  author "Justin Baker"
12
12
 
13
13
  # extend with helper method
@@ -16,4 +16,18 @@ usage
16
16
 
17
17
  # add helper method for use in templates
18
18
  img_tag lambda{|src| "<img src=\"#{src}\" />"}
19
- end
19
+ end
20
+
21
+ plugins
22
+ =======================================
23
+ Plugins are as basic as they can be. The API consists of just a module with helper methods.
24
+ By default, all files in `plugins` will be autoloaded and available. This doesn't mean you can't load plugins other ways.
25
+ Calling `plugin ModuleName` or `plugin "filename"` in the Manic config file will load a plugin.
26
+
27
+ Helper methods can also be defined inside the Manic config by passing a lambda.
28
+
29
+ Manic.config do
30
+ img_tag lambda{|src| "<img src=\"#{src}\" />"}
31
+ end
32
+
33
+ Now you have an `img_tag` helper method available to you.
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rake/testtask'
1
2
 
2
3
  require "bundler"
3
4
  Bundler.setup
@@ -8,4 +9,16 @@ task :build => "#{gemspec.full_name}.gem"
8
9
  file "#{gemspec.full_name}.gem" => gemspec.files + ["manic.gemspec"] do
9
10
  system "gem build manic.gemspec"
10
11
  system "gem install manic-#{Manic::VERSION}.gem"
11
- end
12
+ end
13
+
14
+ task :push do
15
+ system "gem push manic-#{Manic::VERSION}.gem"
16
+ end
17
+
18
+ Rake::TestTask.new do |t|
19
+ t.libs << 'test'
20
+ t.test_files = FileList['test/**/*_test.rb']
21
+ end
22
+
23
+ desc "Run tests"
24
+ task :default => :test
data/bin/manic CHANGED
@@ -1,9 +1,11 @@
1
1
  #! /usr/bin/env ruby
2
2
  $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib/")
3
3
  require "manic"
4
+ require "manic/server"
4
5
  conf = File.join(Dir.pwd,"config.manic")
5
- if File.exists?(conf)
6
- load(conf)
7
- else
8
- puts "Manic config file not found. Check your mind."
9
- end
6
+ Manic.load_config(conf)
7
+
8
+ if ARGV[0] == "server"
9
+ Manic::Server.new(:Port => 3000).start
10
+ end
11
+
@@ -0,0 +1,9 @@
1
+ module GistTag
2
+ # This is just a basic example of a non-trivial plugin
3
+ # eventually we'll have a full plugin similar to http://brandontilley.com/2011/01/30/gist-tag-for-jekyll.html
4
+ def gist(gist_id, filename = "")
5
+ "<script src='https://gist.github.com/#{gist_id}.js?file=#{filename}'></script>"
6
+ end
7
+
8
+ end
9
+ Manic.plugin(GistTag)
data/lib/manic.rb CHANGED
@@ -1,20 +1,39 @@
1
1
  require "tilt"
2
2
  %w{base config}.each{|l| require "manic/#{l}"}
3
+
4
+
3
5
  class Manic
6
+ class ConfigurationNotFound < StandardError; end
7
+
8
+ def self.plugin(mod)
9
+ Base.extend(mod)
10
+ end
11
+
12
+ def self.load_config(conf)
13
+ if File.exists?(conf)
14
+ load(conf)
15
+ else
16
+ raise ConfigurationNotFound.new("Manic config file not found. Check your mind.")
17
+ end
18
+ end
4
19
 
5
20
  def self.config(&block)
6
- Config.new.instance_eval(&block)
7
- Dir.glob("#{Manic::Base.site_root}/**/*").each do |file|
8
- new_file = File.path(file).split("/")
9
- new_file = new_file.size > 1 ? new_file.pop : new_file
10
- new_file = new_file.split(".")[0] + ".html"
11
- result = Tilt.new(file).render(Manic::Base, :current_file => file)
12
- File.open("#{Manic::Base.output_root}/#{new_file}", 'w') {|f| f.write(result) }
13
- puts "Parsing #{File.path(file)} into #{Manic::Base.output_root}/#{File.path(new_file)}"
14
- end
21
+ load_plugins
22
+ Config.new.instance_eval(&block)
23
+ Dir.glob("#{Manic::Base.site_root}/**/*").each do |file|
24
+ new_file = File.path(file).split("/")
25
+ new_file = new_file.size > 1 ? new_file.pop : new_file
26
+ new_file = new_file.split(".")[0] + ".html"
27
+ result = Tilt.new(file).render(Manic::Base, :current_file => file)
28
+ File.open("#{Manic::Base.output_root}/#{new_file}", 'w') {|f| f.write(result) }
29
+ puts "Parsing #{File.path(file)} into #{Manic::Base.output_root}/#{File.path(new_file)}"
30
+ end
15
31
  end
16
32
 
33
+ def self.load_plugins
34
+ Dir.glob("#{Manic::Base.root}/plugins/**/*").each do |file|
35
+ require file
36
+ end
37
+ end
17
38
 
18
-
19
- end
20
-
39
+ end
data/lib/manic/config.rb CHANGED
@@ -1,22 +1,21 @@
1
1
  class Manic
2
2
  class Config
3
-
4
- def plugin(file)
5
- if file.is_a?(String)
6
- require(file)
7
- else
8
- Base.extend(file)
9
- end
10
- end
11
-
3
+ def plugin(file)
4
+ if file.is_a?(String)
5
+ require(file)
6
+ else
7
+ Base.extend(file)
8
+ end
9
+ end
10
+
12
11
  def method_missing(meth, *args)
13
- isproc = args[0].is_a?(Proc)
12
+ isproc = args[0].is_a?(Proc)
14
13
  if isproc
15
- Config.send(:define_method, meth, args[0])
14
+ Base.send(:define_method, meth, args[0])
16
15
  else
17
- Config.class_eval "def Base.#{meth}; @#{meth}; end; def Base.#{meth}=(var); @#{meth} = var; end; Base.#{meth} = \"#{args[0]}\""
18
- end
19
-
20
- end
16
+ Config.class_eval "def Base.#{meth}; @#{meth}; end; def Base.#{meth}=(var); @#{meth} = var; end; Base.#{meth} = \"#{args[0]}\""
17
+ end
18
+ end
19
+
21
20
  end
22
21
  end
@@ -0,0 +1,8 @@
1
+ require "rack"
2
+ class Manic
3
+ class Server < ::Rack::Server
4
+ def app
5
+ Rack::Directory.new(Manic::Base.output_root)
6
+ end
7
+ end
8
+ end
data/lib/manic/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  class Manic
2
2
  # Version number
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-02-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: a manic static site generator, with config in ruby, plugin support
15
15
  email:
@@ -21,9 +21,10 @@ extra_rdoc_files: []
21
21
  files:
22
22
  - lib/manic/base.rb
23
23
  - lib/manic/config.rb
24
+ - lib/manic/server.rb
24
25
  - lib/manic/version.rb
25
26
  - lib/manic.rb
26
- - example/tag_helper.rb
27
+ - example/plugins/gist_tag.rb
27
28
  - bin/manic
28
29
  - LICENSE
29
30
  - Rakefile
@@ -43,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
44
  version: '0'
44
45
  segments:
45
46
  - 0
46
- hash: 556736847
47
+ hash: -155714125
47
48
  required_rubygems_version: !ruby/object:Gem::Requirement
48
49
  none: false
49
50
  requirements:
@@ -1,5 +0,0 @@
1
- module TagHelper
2
- def tag(el)
3
- "<tag>"
4
- end
5
- end