joke 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 78a2f6542fa17c3b7d7b10e612af34adb896340b
4
+ data.tar.gz: 4d78a7f2724770b6c010b7e9f9bd303f212db0c3
5
+ SHA512:
6
+ metadata.gz: 08e441de3bc79409df449c770a08a5ddd29174110ebf9c319b402b6cfc7f7e361a6ce7ae95b6d078454fa1a7e2297e5248489902361758487dc0bf9f53e71a84
7
+ data.tar.gz: cfd1a24b597b4891bc3d78eed752d1c67cf22d41d105a12155521a270e1b24f18cb7862b64381dce315f6c14fabd16fb1aa3174d6a9039a98307fe96a6613db8
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Coby Chapple
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # Joke
2
+
3
+ Joke lets you manage [Jekyll](http://jekyllrb.com) sites locally like a CMS.
4
+
5
+ ### Installation
6
+
7
+ gem install joke
8
+
9
+ ### Usage
10
+
11
+ cd your/jekyll/site
12
+ joke
13
+
14
+ Point your browser at <http://localhost:4000/>.
15
+
16
+ ## License
17
+
18
+ [MIT](./LICENSE).
@@ -0,0 +1,152 @@
1
+ # Gemspec/Rakefile from https://github.com/mojombo/rakegem
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'date'
6
+
7
+ #############################################################################
8
+ #
9
+ # Helper functions
10
+ #
11
+ #############################################################################
12
+
13
+ def name
14
+ @name ||= Dir['*.gemspec'].first.split('.').first
15
+ end
16
+
17
+ def version
18
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
19
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
20
+ end
21
+
22
+ def date
23
+ Date.today.to_s
24
+ end
25
+
26
+ def rubyforge_project
27
+ name
28
+ end
29
+
30
+ def gemspec_file
31
+ "#{name}.gemspec"
32
+ end
33
+
34
+ def gem_file
35
+ "#{name}-#{version}.gem"
36
+ end
37
+
38
+ def replace_header(head, header_name)
39
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
40
+ end
41
+
42
+ #############################################################################
43
+ #
44
+ # Standard tasks
45
+ #
46
+ #############################################################################
47
+
48
+ task :default => :test
49
+
50
+ require 'rake/testtask'
51
+ Rake::TestTask.new(:test) do |test|
52
+ test.libs << 'lib' << 'test'
53
+ test.pattern = 'test/**/test_*.rb'
54
+ test.verbose = true
55
+ end
56
+
57
+ desc "Generate RCov test coverage and open in your browser"
58
+ task :coverage do
59
+ require 'rcov'
60
+ sh "rm -fr coverage"
61
+ sh "rcov test/test_*.rb"
62
+ sh "open coverage/index.html"
63
+ end
64
+
65
+ require 'rdoc/task'
66
+ Rake::RDocTask.new do |rdoc|
67
+ rdoc.rdoc_dir = 'rdoc'
68
+ rdoc.title = "#{name} #{version}"
69
+ rdoc.rdoc_files.include('README*')
70
+ rdoc.rdoc_files.include('lib/**/*.rb')
71
+ end
72
+
73
+ desc "Open an irb session preloaded with this library"
74
+ task :console do
75
+ sh "irb -rubygems -r ./lib/#{name}.rb"
76
+ end
77
+
78
+ #############################################################################
79
+ #
80
+ # Custom tasks (add your own tasks here)
81
+ #
82
+ #############################################################################
83
+
84
+
85
+
86
+ #############################################################################
87
+ #
88
+ # Packaging tasks
89
+ #
90
+ #############################################################################
91
+
92
+ desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
93
+ task :release => :build do
94
+ unless `git branch` =~ /^\* master$/
95
+ puts "You must be on the master branch to release!"
96
+ exit!
97
+ end
98
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
99
+ sh "git tag v#{version}"
100
+ sh "git push origin master"
101
+ sh "git push origin v#{version}"
102
+ sh "gem push pkg/#{name}-#{version}.gem"
103
+ end
104
+
105
+ desc "Build #{gem_file} into the pkg directory"
106
+ task :build => :gemspec do
107
+ sh "mkdir -p pkg"
108
+ sh "gem build #{gemspec_file}"
109
+ sh "mv #{gem_file} pkg"
110
+ end
111
+
112
+ desc "Generate #{gemspec_file}"
113
+ task :gemspec => :validate do
114
+ # read spec file and split out manifest section
115
+ spec = File.read(gemspec_file)
116
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
117
+
118
+ # replace name version and date
119
+ replace_header(head, :name)
120
+ replace_header(head, :version)
121
+ replace_header(head, :date)
122
+ #comment this out if your rubyforge_project has a different name
123
+ replace_header(head, :rubyforge_project)
124
+
125
+ # determine file list from git ls-files
126
+ files = `git ls-files`.
127
+ split("\n").
128
+ sort.
129
+ reject { |file| file =~ /^\./ }.
130
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
131
+ map { |file| " #{file}" }.
132
+ join("\n")
133
+
134
+ # piece file back together and write
135
+ manifest = " s.files = %w[\n#{files}\n ]\n"
136
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
137
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
138
+ puts "Updated #{gemspec_file}"
139
+ end
140
+
141
+ desc "Validate #{gemspec_file}"
142
+ task :validate do
143
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
144
+ unless libfiles.empty?
145
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
146
+ exit!
147
+ end
148
+ unless Dir['VERSION*'].empty?
149
+ puts "A `VERSION` file at root level violates Gem best practices."
150
+ exit!
151
+ end
152
+ end
@@ -0,0 +1 @@
1
+ source: test/source
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'joke'
4
+
5
+ puts "Firing up the Joke server…"
6
+ Joke::App.run!
@@ -0,0 +1,91 @@
1
+ # Gemspec/Rakefile from https://github.com/mojombo/rakegem
2
+
3
+ # -*- encoding: utf-8 -*-
4
+ $:.push File.expand_path("../lib", __FILE__)
5
+ require "joke/app"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'joke'
16
+ s.version = '0.0.1'
17
+ s.date = '2013-10-08'
18
+ s.rubyforge_project = 'joke'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "A local CMS for Jekyll sites."
23
+ s.description = "Joke lets you manage Jekyll sites locally like a CMS."
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Coby Chapple"]
29
+ s.email = 'coby@github.com'
30
+ s.homepage = 'https://github.com/cobyism/joke'
31
+ s.license = 'MIT'
32
+
33
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
34
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
35
+ s.require_paths = %w[lib]
36
+
37
+ ## This sections is only necessary if you have C extensions.
38
+ # s.require_paths << 'ext'
39
+ # s.extensions = %w[ext/extconf.rb]
40
+
41
+ ## If your gem includes any executables, list them here.
42
+ s.executables = ["joke"]
43
+
44
+ ## Specify any RDoc options here. You'll want to add your README and
45
+ ## LICENSE files to the extra_rdoc_files list.
46
+ s.rdoc_options = ["--charset=UTF-8"]
47
+ s.extra_rdoc_files = %w[README.md LICENSE]
48
+
49
+ ## List your runtime dependencies here. Runtime dependencies are those
50
+ ## that are needed for an end user to actually USE your code.
51
+ s.add_dependency('sinatra')
52
+ s.add_dependency('jekyll')
53
+
54
+ ## List your development dependencies here. Development dependencies are
55
+ ## those that are only needed during development
56
+ s.add_development_dependency('rack-test')
57
+
58
+ ## Leave this section as-is. It will be automatically generated from the
59
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
60
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
61
+ # = MANIFEST =
62
+ s.files = %w[
63
+ LICENSE
64
+ README.md
65
+ Rakefile
66
+ _config.yml
67
+ bin/joke
68
+ joke.gemspec
69
+ lib/joke.rb
70
+ lib/joke/app.rb
71
+ lib/joke/helpers.rb
72
+ lib/joke/public/stylesheets/main.css
73
+ lib/joke/views/config.erb
74
+ lib/joke/views/index.erb
75
+ lib/joke/views/layout.erb
76
+ lib/joke/views/page.erb
77
+ lib/joke/views/pages.erb
78
+ lib/joke/views/posts.erb
79
+ test/source/_layouts/default.html
80
+ test/source/_posts/2013-01-01-test-post.md
81
+ test/source/_posts/2013-01-02-example-post.md
82
+ test/source/css/style.css
83
+ test/source/index.html
84
+ test/test_joke.rb
85
+ ]
86
+ # = MANIFEST =
87
+
88
+ ## Test files will be grabbed from the file list. Make sure the path glob
89
+ ## matches what you actually use.
90
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
91
+ end
@@ -0,0 +1,5 @@
1
+ require 'joke/app'
2
+
3
+ module Joke
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,60 @@
1
+ require 'jekyll'
2
+ require 'sinatra'
3
+ require 'joke/helpers'
4
+
5
+ module Joke
6
+ class App < Sinatra::Base
7
+
8
+ helpers Joke::Helpers
9
+
10
+ configure do
11
+ set :port, 4000
12
+ end
13
+
14
+ set :public_folder, File.dirname(__FILE__) + '/public'
15
+
16
+ before do
17
+ options = {
18
+ :url => "http://localhost:4000/preview",
19
+ :baseurl => "/preview"
20
+ }
21
+ @site = Jekyll::Site.new(Jekyll.configuration(options))
22
+ @rendered_site = @site.clone
23
+
24
+ # Properly build one instance of the site
25
+ @rendered_site.process
26
+
27
+ # Leave one version of the site unprocessed
28
+ @site.read
29
+ end
30
+
31
+ get '/' do
32
+ erb :index
33
+ end
34
+
35
+ get '/pages' do
36
+ @pages = @site.pages
37
+ erb :pages
38
+ end
39
+
40
+ get '/pages/:name' do
41
+ @page = find_page(@site, params[:name])
42
+ erb :page
43
+ end
44
+
45
+ get '/posts' do
46
+ @posts = @site.posts
47
+ erb :posts
48
+ end
49
+
50
+ get '/config' do
51
+ @config = @site.config
52
+ erb :config
53
+ end
54
+
55
+ get "/preview/?*" do
56
+ jekyll_preview(request.path) {404}
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,27 @@
1
+ module Joke
2
+ module Helpers
3
+
4
+ def jekyll_preview(path, &missing_file_block)
5
+ file_path = File.join('_site', path.gsub('/preview',''))
6
+ file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
7
+
8
+ if File.exist?(file_path)
9
+ file = File.open(file_path, "rb")
10
+ contents = file.read
11
+ file.close
12
+ erb contents, :layout => false
13
+ else
14
+ erb :not_found
15
+ end
16
+ end
17
+
18
+ def find_page(site, name)
19
+ result = nil
20
+ site.pages.each do |page|
21
+ result = page if page.name == name
22
+ end
23
+ result
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ * {
2
+ -moz-box-sizing: border-box;
3
+ box-sizing: border-box;
4
+ }
5
+
6
+ html, body {
7
+ font-family: "Helvetica Neue", Helvetica, arial, freesans, clean, sans-serif;
8
+ margin: 0;
9
+ padding: 0;
10
+ }
@@ -0,0 +1,3 @@
1
+ <h2>Configuration</h2>
2
+
3
+ <%= @config.inspect %>
@@ -0,0 +1,3 @@
1
+ <h2>Welcome!</h2>
2
+
3
+ <%= @site.inspect %>
@@ -0,0 +1,21 @@
1
+ <html>
2
+ <head>
3
+ <title>Joke</title>
4
+ <link href="/stylesheets/main.css" rel="stylesheet" type="text/css">
5
+ </head>
6
+ <body>
7
+ <header>
8
+ <h1>Joke</h1>
9
+ <nav>
10
+ <ul>
11
+ <li><a href="/pages">Pages</a></li>
12
+ <li><a href="/posts">Posts</a></li>
13
+ <li><a href="/config">Configuration</a></li>
14
+ </ul>
15
+ </nav>
16
+ </header>
17
+ <section class="main">
18
+ <%= yield %>
19
+ </section>
20
+ </body>
21
+ </html>
@@ -0,0 +1,20 @@
1
+ <h2>Editing Page</h2>
2
+
3
+ <a href="/preview<%= @page.url %>">Preview Page</a>
4
+
5
+ Site: <%= @page.site %>
6
+ Pager: <%= @page.pager %>
7
+ Name: <%= @page.name %>
8
+ Ext: <%= @page.ext %>
9
+ Basename: <%= @page.basename %>
10
+ Data: <%= @page.data %>
11
+
12
+ Content
13
+ <textarea>
14
+ <%= @page.content %>
15
+ </textarea>
16
+
17
+ Output
18
+ <textarea>
19
+ <%= @page.output %>
20
+ </textarea>
@@ -0,0 +1,7 @@
1
+ <h2>Pages</h2>
2
+
3
+ <ul>
4
+ <% @pages.each do |page| %>
5
+ <li><a href="/pages/<%= page.name %>"><%= page.name %></a> | <a href="/preview<%= page.url %>">Preview</a></li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,7 @@
1
+ <h2>Posts</h2>
2
+
3
+ <ul>
4
+ <% @posts.each do |post| %>
5
+ <li><%= post.title %> | <a href="/preview<%= post.url %>">Preview</a></li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>Jekyll Site</title>
4
+ <link href="{{ site.baseurl }}/css/style.css" rel="stylesheet" type="text/css">
5
+ </head>
6
+ <body>
7
+ {{ content }}
8
+ </body>
9
+ </html>
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Test Post
3
+ layout: default
4
+ ---
5
+
6
+ Test post contents.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Example Post
3
+ layout: default
4
+ ---
5
+
6
+ Example post contents.
@@ -0,0 +1,4 @@
1
+ html, body {
2
+ background: #c00;
3
+ color: #fff;
4
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <h1>Test Page</h1>
6
+ {% for post in site.posts %}
7
+ <a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
8
+ {% endfor %}
@@ -0,0 +1,42 @@
1
+ require 'joke'
2
+ require 'test/unit'
3
+ require 'rack/test'
4
+
5
+ class JokeTest < Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ Joke::App
10
+ end
11
+
12
+ def test_index
13
+ get '/'
14
+ assert last_response.ok?
15
+ assert last_response.body.include?("Joke")
16
+ end
17
+
18
+ def test_pages
19
+ get '/pages'
20
+ assert last_response.ok?
21
+ assert last_response.body.include?("Pages")
22
+ end
23
+
24
+ def test_page
25
+ get '/pages/index.html'
26
+ assert last_response.ok?
27
+ assert last_response.body.include? "Name: index.html"
28
+ end
29
+
30
+ def test_posts
31
+ get '/posts'
32
+ assert last_response.ok?
33
+ assert last_response.body.include?("Posts")
34
+ end
35
+
36
+ def test_config
37
+ get '/config'
38
+ assert last_response.ok?
39
+ assert last_response.body.include?("Configuration")
40
+ end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: joke
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Coby Chapple
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Joke lets you manage Jekyll sites locally like a CMS.
56
+ email: coby@github.com
57
+ executables:
58
+ - joke
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - README.md
62
+ - LICENSE
63
+ files:
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - _config.yml
68
+ - bin/joke
69
+ - joke.gemspec
70
+ - lib/joke.rb
71
+ - lib/joke/app.rb
72
+ - lib/joke/helpers.rb
73
+ - lib/joke/public/stylesheets/main.css
74
+ - lib/joke/views/config.erb
75
+ - lib/joke/views/index.erb
76
+ - lib/joke/views/layout.erb
77
+ - lib/joke/views/page.erb
78
+ - lib/joke/views/pages.erb
79
+ - lib/joke/views/posts.erb
80
+ - test/source/_layouts/default.html
81
+ - test/source/_posts/2013-01-01-test-post.md
82
+ - test/source/_posts/2013-01-02-example-post.md
83
+ - test/source/css/style.css
84
+ - test/source/index.html
85
+ - test/test_joke.rb
86
+ homepage: https://github.com/cobyism/joke
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project: joke
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 2
110
+ summary: A local CMS for Jekyll sites.
111
+ test_files:
112
+ - test/test_joke.rb