brightly 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,18 +52,21 @@ config.ru:
52
52
  end
53
53
  run Brightly::Provider::Base
54
54
 
55
- == Client Usage
55
+ You can easily set up a brightly app for passenger with:
56
56
 
57
- The simplest way to use brighten in a rails application is to create a helper method that can make the requests. You could likely create an ActiveResource model for this, but the data is hardly representative of a model, so a simple method call makes more sense.
57
+ brightly -p brightly
58
58
 
59
- config/initializers/brightly.rb:
59
+ Then just add the outputted config to your apache config.
60
+
61
+ == Client Usage
60
62
 
61
- Brightly::Consumer.provider_url = "http://your-host.com"
62
- Brightly::Consumer.theme = "blackboard"
63
+ The simplest way to use brighten in a rails application is to create a helper method that can make the requests. You could likely create an ActiveResource model for this, but the data is hardly representative of a model, so a simple method call makes more sense.
63
64
 
64
- In your controller or model:
65
+ A simple method can be added to your model which makes the call to Brightly:
65
66
 
66
- brighten("# Some Markdown")
67
+ def brighten(markdown, theme = 'blackboard')
68
+ Net::HTTP.post_form(URI.parse("http://127.0.0.1:4567/brighten"), {:markdown => markdown, :theme => theme}).body
69
+ end
67
70
 
68
71
  Remember that you likely don't want to do this every hit to a page, markdown processing is done with RDiscount so it's fast, but code highlighting and markdown processing and the service call all adds up. Store the result, get better performance.
69
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{brightly}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adam Elliot"]
@@ -27,10 +27,9 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "bin/brightly",
29
29
  "brightly.gemspec",
30
- "config.ru",
31
30
  "lib/brightly.rb",
32
31
  "lib/brightly/provider/base.rb",
33
- "lib/brightly/provider/config.rb",
32
+ "lib/brightly/provider/config.ru",
34
33
  "lib/brightly/provider/exec.rb",
35
34
  "lib/brightly/provider/public/stylesheets/active4d.css",
36
35
  "lib/brightly/provider/public/stylesheets/all_hallows_eve.css",
@@ -1,8 +1,6 @@
1
1
  module Brightly
2
2
  module Provider
3
3
  autoload :Base, "brightly/provider/base"
4
-
5
- autoload :Config, "brightly/provider/config"
6
4
  autoload :Exec, "brightly/provider/exec"
7
5
  end
8
6
  end
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'optparse'
3
+ require 'fileutils'
3
4
 
4
5
  module Brightly
5
6
  module Provider
@@ -16,19 +17,45 @@ module Brightly
16
17
  opts.on('-p port') { |val| options[:port] = val.to_i }
17
18
 
18
19
  opts.on('-r', '--rack-file', 'Prints the path to the builtin rack file and the contents of the file.') do
19
- a = File.dirname(__FILE__).split(File::SEPARATOR)
20
- a.slice!(-5, 5)
21
- config = File.join(a.join('/'), 'config.ru')
20
+ config = rack_file
21
+
22
22
  puts "#{config}:"
23
23
  puts File.read(config)
24
24
  exit
25
25
  end
26
+
27
+ opts.on('-p path', '--passenger path', 'Generate an apache passenger config and directory structure.') do |val|
28
+ config = rack_file
29
+
30
+ FileUtils.mkdir_p(File.join(val))
31
+ FileUtils.mkdir_p(File.join(val, 'tmp'))
32
+ FileUtils.mkdir_p(File.join(val, 'public'))
33
+
34
+ FileUtils.cp(config, File.join(val))
35
+
36
+ puts "You apache conf should look something like:"
37
+ puts <<-CONF
38
+ <VirtualHost *:80>
39
+ ServerName brightly.local
40
+ DocumentRoot #{File.expand_path(File.join(val, 'public'))}
41
+ </VirtualHost>
42
+ CONF
43
+ exit
44
+ end
26
45
 
27
46
  opts.on_tail('-h', '--help', "Show this message") { puts opts ; exit }
28
47
  end.parse!
29
48
 
30
49
  Brightly::Provider::Base.run! options
31
50
  end
51
+
52
+ private
53
+ def rack_file
54
+ a = File.dirname(__FILE__).split(File::SEPARATOR)
55
+ a.slice!(-5, 5)
56
+ a += ['lib', 'brightly', 'provider']
57
+ config = File.join(a.join(File::SEPARATOR), 'config.ru')
58
+ end
32
59
  end
33
60
  end
34
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Elliot
@@ -80,10 +80,9 @@ files:
80
80
  - VERSION
81
81
  - bin/brightly
82
82
  - brightly.gemspec
83
- - config.ru
84
83
  - lib/brightly.rb
85
84
  - lib/brightly/provider/base.rb
86
- - lib/brightly/provider/config.rb
85
+ - lib/brightly/provider/config.ru
87
86
  - lib/brightly/provider/exec.rb
88
87
  - lib/brightly/provider/public/stylesheets/active4d.css
89
88
  - lib/brightly/provider/public/stylesheets/all_hallows_eve.css
File without changes