bard_static 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem "rails", "3.0.7"
4
+ gem "rake", "~> 0.9.2"
5
+ gem "capybara", ">= 0.4.0"
6
+
7
+ gem "autotest-standalone"
8
+ gem "rspec-rails"
@@ -0,0 +1,53 @@
1
+ BardStatic
2
+ =========
3
+
4
+ _____________________________________
5
+ / BardStatic – handcrafted prototypes \
6
+ \ with ease /
7
+ -------------------------------------
8
+ \ ^__^
9
+ \ (oo)\_______
10
+ (__)\ )\/\
11
+ ||----w |
12
+ || ||
13
+
14
+
15
+ Installation
16
+ ------------
17
+
18
+ Add BardStatic to Gemfile:
19
+
20
+ gem "bard_static"
21
+
22
+ Usage
23
+ -----
24
+
25
+ Put your views in app/views/mockups and view them in
26
+ browser at /mockups/path_to_file.
27
+
28
+ Examples:
29
+
30
+ | URI Path | File path |
31
+ |--------------|----------------------------------------------------|
32
+ | /p | app/views/mockups/index.html.erb |
33
+ | /p/home | app/views/mockups/home.html.haml |
34
+ | /p/posts/new | app/views/mockups/posts/new.html.slim |
35
+
36
+ All available Rails helpers work nicely. Pure prototyping bliss!
37
+
38
+
39
+ Hooks
40
+ -----
41
+
42
+ BardStatic let's you add a `#before_bard_static` method in
43
+ `ApplicationController`, that will be run before any prototype. You can
44
+ use it, for example, to provide authentication or prevent prototypes
45
+ from being rendered in production.
46
+
47
+
48
+ Gotchas
49
+ -------
50
+
51
+ When rendering a partial, you must specify the full path
52
+ (e.g. `mockups/posts/form`) unless the partial is in
53
+ `app/views/mockups/`.
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake/task'
11
+
12
+ require 'rspec/core'
13
+ require 'rspec/core/rake_task'
14
+
15
+ RSpec::Core::RakeTask.new(:spec)
16
+ Bundler::GemHelper.install_tasks
17
+
18
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ module BardStatic
2
+ class StaticController < ApplicationController
3
+ before_filter :before_bard_static,
4
+ :if => proc { respond_to?(:before_bard_static, true) }
5
+
6
+ def serve
7
+ env["bard_static.prototype"] = true
8
+ render "mockups/#{params[:file_path]}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ namespace "mockups", :module => :bard_static do
3
+ root :to => "static#serve", :file_path => "index"
4
+ match "/*file_path" => "static#serve"
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require "bard_static/no_robots_middleware"
2
+
3
+ module BardStatic
4
+ class Engine < ::Rails::Engine
5
+ config.app_middleware.use NoRobotsMiddleware
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module BardStatic
2
+ class NoRobotsMiddleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ status, headers, response = @app.call(env)
9
+
10
+ if env["bard_static.prototype"] && status == 200
11
+ no_robots_tag = %{<meta name="robots" content="noindex, nofollow"/>\n}
12
+ response.body = response.body.sub("</head>", "#{no_robots_tag}</head>")
13
+ end
14
+
15
+ [status, headers, response]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module BardStatic
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bard_static
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Micah Geisel
14
+ - Joao Carlos
15
+ - !binary |
16
+ VmVzYSBWw6Ruc2vDpA==
17
+
18
+ - Matias Korhonen
19
+ - Antti Salonen
20
+ autorequire:
21
+ bindir: bin
22
+ cert_chain: []
23
+
24
+ date: 2011-06-16 00:00:00 Z
25
+ dependencies: []
26
+
27
+ description: Handcrafted prototypes for Rails.
28
+ email:
29
+ - micah@botandrose.com
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files: []
35
+
36
+ files:
37
+ - app/controllers/bard_static/static_controler.rb
38
+ - lib/bard_static.rb
39
+ - lib/bard_static/version.rb
40
+ - lib/bard_static/no_robots_middleware.rb
41
+ - config/routes.rb
42
+ - Rakefile
43
+ - Gemfile
44
+ - README.md
45
+ homepage: https://github.com/botandrose/bard_static
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.5
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Protoyping engine for Rails.
78
+ test_files: []
79
+