rails-pages 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +33 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/rails-pages/application.js +15 -0
- data/app/assets/javascripts/rails_pages/pages.js +2 -0
- data/app/assets/stylesheets/rails-pages/application.css +13 -0
- data/app/assets/stylesheets/rails_pages/pages.css +4 -0
- data/app/controllers/rails_pages/application_controller.rb +4 -0
- data/app/controllers/rails_pages/pages_controller.rb +29 -0
- data/app/helpers/rails_pages/application_helper.rb +4 -0
- data/app/helpers/rails_pages/pages_helper.rb +4 -0
- data/app/views/rails_pages/pages/show.html.erb +1 -0
- data/config/routes.rb +3 -0
- data/lib/rails-pages.rb +4 -0
- data/lib/rails-pages/engine.rb +7 -0
- data/lib/rails-pages/version.rb +3 -0
- data/lib/tasks/rails-pages_tasks.rake +4 -0
- metadata +96 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
RailsPages
|
2
|
+
==========
|
3
|
+
|
4
|
+
A really simple rails engine, serving text files from app/pages as HTML (currently only supports Markdown)
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
* Gemfile
|
10
|
+
|
11
|
+
````ruby
|
12
|
+
gem 'rails-pages'
|
13
|
+
````
|
14
|
+
|
15
|
+
* config/routes.rb
|
16
|
+
|
17
|
+
````ruby
|
18
|
+
mount RailsPages::Engine => 'pages', as: 'static'
|
19
|
+
````
|
20
|
+
|
21
|
+
Now add the test page `app/pages/test.md`
|
22
|
+
|
23
|
+
````markdown
|
24
|
+
TEST
|
25
|
+
====
|
26
|
+
|
27
|
+
Lorem ipsum ...
|
28
|
+
````
|
29
|
+
|
30
|
+
License
|
31
|
+
-------
|
32
|
+
|
33
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RailsPages'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_dependency "rails_pages/application_controller"
|
2
|
+
|
3
|
+
module RailsPages
|
4
|
+
class PagesController < ApplicationController
|
5
|
+
def show
|
6
|
+
raise "No Rails.root set" if Rails.root.nil?
|
7
|
+
file_base = File.join(Rails.root, 'app', 'pages', params[:id])
|
8
|
+
|
9
|
+
data_types = {
|
10
|
+
md: proc { |text| Redcarpet::Markdown.new(Redcarpet::Render::XHTML.new).render(text) },
|
11
|
+
markdown: proc { |text| Redcarpet::Markdown.new(Redcarpet::Render::XHTML.new).render(text) }
|
12
|
+
}
|
13
|
+
|
14
|
+
files = []
|
15
|
+
files += Dir.glob(file_base+'.'+I18n.locale.to_s+'.{'+data_types.keys.join(',')+'}')
|
16
|
+
files += Dir.glob(file_base+'.{'+data_types.keys.join(',')+'}')
|
17
|
+
file = files.first
|
18
|
+
if file.nil?
|
19
|
+
Rails.logger.error file+' not found'
|
20
|
+
raise ActionController::RoutingError.new('Not Found')
|
21
|
+
end
|
22
|
+
type = File.extname(file)
|
23
|
+
type = type[1..-1]
|
24
|
+
|
25
|
+
@html = data_types[type.to_sym].call(File.read(file))
|
26
|
+
render layout: 'application'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @html.html_safe %>
|
data/config/routes.rb
ADDED
data/lib/rails-pages.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-pages
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Spieker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.9
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.9
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: redcarpet
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.2.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.2.2
|
46
|
+
description: ''
|
47
|
+
email:
|
48
|
+
- p.spieker@duenos.de
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- app/assets/javascripts/rails-pages/application.js
|
54
|
+
- app/assets/javascripts/rails_pages/pages.js
|
55
|
+
- app/assets/stylesheets/rails-pages/application.css
|
56
|
+
- app/assets/stylesheets/rails_pages/pages.css
|
57
|
+
- app/controllers/rails_pages/application_controller.rb
|
58
|
+
- app/controllers/rails_pages/pages_controller.rb
|
59
|
+
- app/helpers/rails_pages/application_helper.rb
|
60
|
+
- app/helpers/rails_pages/pages_helper.rb
|
61
|
+
- app/views/rails_pages/pages/show.html.erb
|
62
|
+
- config/routes.rb
|
63
|
+
- lib/rails-pages/engine.rb
|
64
|
+
- lib/rails-pages/version.rb
|
65
|
+
- lib/rails-pages.rb
|
66
|
+
- lib/tasks/rails-pages_tasks.rake
|
67
|
+
- MIT-LICENSE
|
68
|
+
- Rakefile
|
69
|
+
- README.markdown
|
70
|
+
homepage: https://github.com/spieker/rails-pages
|
71
|
+
licenses: []
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.24
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: A really simple rails engine, serving text files from app/pages as HTML (currently
|
94
|
+
only supports Markdown)
|
95
|
+
test_files: []
|
96
|
+
has_rdoc:
|