middleman-dev-cms 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +19 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/middleman-dev-cms.rb +11 -0
- data/lib/middleman/dev/cms/api_server.rb +79 -0
- data/lib/middleman/dev/cms/extension.rb +52 -0
- data/lib/middleman/dev/cms/version.rb +7 -0
- data/lib/middleman/dev/cms/views/index.erb +30 -0
- data/lib/middleman/dev/cms/views/rebuild.erb +3 -0
- data/middleman-dev-cms.gemspec +35 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 843deb0536199d7b5e58687f07f0e874f59f2459
|
4
|
+
data.tar.gz: 23b165c7ace3cc8eb2d1e1f49eb786e5728766c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35a1469951f789c28da625000995c90543ecb5b54352f060a5382d83ce7b77af36dc19decd19dcd83358acd6331c89b4c3e926509a5183b82942d3116c8bbf66
|
7
|
+
data.tar.gz: ed6e955ca5becb4f9675cc3d087a5a147c9f9025336b357673e8a455521cd2e13ee07076cd4e0078f413f934147866479e2287097ebd22ebd59c34590ac6011d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Middleman Dev CMS
|
2
|
+
|
3
|
+
This gem is a sinatra app meant to work with an a local middleman server to provide CRUD actions as well as integrate with git (coming soon!)
|
4
|
+
|
5
|
+
based on the the `middleman-blog-ui` gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
1. Add `middleman-dev-cms` in your `Gemfile`.
|
10
|
+
2. Add `activate :dev_cms` in `config.rb`
|
11
|
+
3. Start `middleman server`
|
12
|
+
4. visit `/cms` + a page, such as [http://localhost:4567/cms/any/page/to/edit.html](http://localhost:4567/cms/any/page/to/edit.html) and you can create, update, move, rename and delete files from the middleman server
|
13
|
+
|
14
|
+
Still a work in progress! Better docs to come.
|
15
|
+
|
16
|
+
## Development
|
17
|
+
|
18
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
19
|
+
|
20
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it ( https://github.com/[my-github-username]/middleman-dev-cms/fork )
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "middleman/dev/cms"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'middleman-core'
|
4
|
+
|
5
|
+
::Middleman::Extensions.register(:dev_cms) do
|
6
|
+
module Middleman::Dev::Cms
|
7
|
+
SOURCE_DIR ||= File.expand_path(File.join('..', '..', 'source'), __FILE__)
|
8
|
+
end
|
9
|
+
require 'middleman/dev/cms/extension'
|
10
|
+
::Middleman::Dev::Cms::Extension
|
11
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module Dev
|
6
|
+
module Cms
|
7
|
+
class ApiServer < Sinatra::Base
|
8
|
+
|
9
|
+
get '/rebuild' do
|
10
|
+
`bundle exec middleman build`
|
11
|
+
erb :rebuild
|
12
|
+
end
|
13
|
+
|
14
|
+
# get filepath
|
15
|
+
get '/*' do
|
16
|
+
filepath = params['captures'].first
|
17
|
+
filepath +="index.html" if filepath.end_with?("/")
|
18
|
+
filepath += ".html" unless filepath.end_with?(".html")
|
19
|
+
if found_filepath = Dir.glob("#{SOURCE_DIR + "/" + filepath}*").first
|
20
|
+
filepath += found_filepath.partition(".html").last
|
21
|
+
content = File.open(found_filepath).read
|
22
|
+
else
|
23
|
+
filepath += ".erb"
|
24
|
+
content = %Q(
|
25
|
+
---
|
26
|
+
title: Clever Title
|
27
|
+
description: So I know what im looking at
|
28
|
+
---
|
29
|
+
|
30
|
+
)
|
31
|
+
end
|
32
|
+
erb :index, locals: {content: content, filepath: (filepath)}
|
33
|
+
end
|
34
|
+
# if filepath matches new and doesnt exist, create it recursivly
|
35
|
+
# if they dont match, user edited field
|
36
|
+
# if newfilepath does not match filepath, perform move
|
37
|
+
# if newfilepath is blank, delete
|
38
|
+
post "/" do
|
39
|
+
full_filepath = SOURCE_DIR + "/" + params[:filepath]
|
40
|
+
original_filepath = SOURCE_DIR + "/" + params[:originalfilepath]
|
41
|
+
existing = Dir.glob("#{full_filepath}*").first
|
42
|
+
if params[:filepath].empty? # they want to delete this file
|
43
|
+
`rm "#{original_filepath}"`
|
44
|
+
redirect to("http://" + request.host_with_port + "/") and return
|
45
|
+
elsif full_filepath != original_filepath && !existing # lets move or rename
|
46
|
+
found = Dir.glob("#{original_filepath}*").first # find the known original
|
47
|
+
dest_full_filepath = full_filepath
|
48
|
+
`mkdir -p "#{dest_full_filepath.rpartition("/").first}"`
|
49
|
+
`mv "#{found}" "#{dest_full_filepath}"`
|
50
|
+
|
51
|
+
existing = dest_full_filepath
|
52
|
+
end
|
53
|
+
File.open(existing || full_filepath, "w+") {|f| f.write(params[:content]) }
|
54
|
+
|
55
|
+
sleep(0.6)
|
56
|
+
redirection = "http://" + request.host_with_port + "/" + params[:filepath].gsub(/\s/, "%20").gsub(/.md|.erb/, '')
|
57
|
+
redirect to(redirection)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def load_app
|
63
|
+
opts = {}
|
64
|
+
|
65
|
+
app = ::Middleman::Application.server.inst do
|
66
|
+
set :environment, opts[:environment].to_sym if opts[:environment]
|
67
|
+
logger
|
68
|
+
end
|
69
|
+
|
70
|
+
app
|
71
|
+
end
|
72
|
+
|
73
|
+
def logger
|
74
|
+
::Middleman::Logger.singleton( 1 )
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'middleman/dev/cms/api_server'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module Dev
|
5
|
+
module Cms
|
6
|
+
# Middleman extension entry point
|
7
|
+
class Extension < Middleman::Extension
|
8
|
+
|
9
|
+
self.defined_helpers = []
|
10
|
+
|
11
|
+
def initialize(app, options_hash = {}, &block)
|
12
|
+
super
|
13
|
+
app.map "/cms" do
|
14
|
+
run ApiServer
|
15
|
+
end
|
16
|
+
|
17
|
+
#::Sprockets.register_preprocessor 'application/javascript', ::Sprockets::CoffeeReact
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_configuration
|
21
|
+
end
|
22
|
+
|
23
|
+
def manipulate_resource_list(resources)
|
24
|
+
# p "manipulate_resource_list"
|
25
|
+
Dir.glob( "#{SOURCE_DIR}/**/*" ).each do |path|
|
26
|
+
unless File.directory? path
|
27
|
+
resources << make_template( path, path.gsub( /#{SOURCE_DIR}\//, "" ) )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
# resources << make_template( "#{SOURCE_DIR}/stylesheets/admin.css.scss", "stylesheets/admin.css" )
|
31
|
+
resources
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def register_extension_templates
|
36
|
+
# We call reload_path to register the templates directory with Middleman.
|
37
|
+
# The path given to app.files must be relative to the Middleman site's root.
|
38
|
+
#templates_dir_relative_from_root = Pathname(SOURCE_DIR).relative_path_from(Pathname(app.root))
|
39
|
+
#app.files.reload_path(templates_dir_relative_from_root)
|
40
|
+
end
|
41
|
+
|
42
|
+
def make_template( file, name )
|
43
|
+
name = name.gsub( /.erb/, "" ).gsub( /.haml/, "" ).gsub( /.coffee/, "" ).gsub( /.scss/, "" )
|
44
|
+
# puts "Adding #{name}"
|
45
|
+
Middleman::Sitemap::Resource.new(app.sitemap, name, file).tap do |resource|
|
46
|
+
resource.add_metadata(options: { layout: false }, locals: {})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<style>
|
5
|
+
body{background-color: #def;}
|
6
|
+
#filepath{font-size: 1.4em;width:100%;}
|
7
|
+
textarea{font-size: 1.3em;padding:8px;}
|
8
|
+
input[type='submit']{
|
9
|
+
font-size: 1.2em;
|
10
|
+
margin-top:20px;
|
11
|
+
padding:8px 10px;
|
12
|
+
background-color: #2d0;
|
13
|
+
border:none;
|
14
|
+
border-bottom:5px solid #2b0;
|
15
|
+
color:white;
|
16
|
+
border-radius: 5px;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<h1>Middleman Dev CMS</h1>
|
22
|
+
<form method='post' action='/cms'>
|
23
|
+
<input id='filepath' type="text" name="filepath" value="<%= filepath %>"><br><br>
|
24
|
+
<textarea id='content' name='content' rows="40" cols = "150" ><%= content %></textarea>
|
25
|
+
<input id='submit' type="hidden" name="originalfilepath" value="<%= filepath %>">
|
26
|
+
<br>
|
27
|
+
<input type='submit' value ='Save'>
|
28
|
+
</form>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'middleman/dev/cms/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "middleman-dev-cms"
|
7
|
+
spec.version = Middleman::Dev::Cms::VERSION
|
8
|
+
spec.authors = ["Russell Jennings", "Will Schenk"]
|
9
|
+
spec.email = ["violentpurr@gmail.com", 'wschenk@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = %q{Developer focused CMS for middleman}
|
12
|
+
spec.description = %q{Provides CRUD abilities for pages as well as git operations when running server}
|
13
|
+
spec.homepage = "https://github.com/meesterdude/middleman-dev-cms"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.platform = Gem::Platform::RUBY
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
# spec.add_dependency "middleman-react"
|
30
|
+
|
31
|
+
spec.add_dependency "sinatra", "~> 1.4"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_runtime_dependency("middleman-core", [">= 3.3"])
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-dev-cms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Russell Jennings
|
8
|
+
- Will Schenk
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sinatra
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.4'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.4'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.9'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: middleman-core
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.3'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.3'
|
70
|
+
description: Provides CRUD abilities for pages as well as git operations when running
|
71
|
+
server
|
72
|
+
email:
|
73
|
+
- violentpurr@gmail.com
|
74
|
+
- wschenk@gmail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/middleman-dev-cms.rb
|
89
|
+
- lib/middleman/dev/cms/api_server.rb
|
90
|
+
- lib/middleman/dev/cms/extension.rb
|
91
|
+
- lib/middleman/dev/cms/version.rb
|
92
|
+
- lib/middleman/dev/cms/views/index.erb
|
93
|
+
- lib/middleman/dev/cms/views/rebuild.erb
|
94
|
+
- middleman-dev-cms.gemspec
|
95
|
+
homepage: https://github.com/meesterdude/middleman-dev-cms
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata:
|
99
|
+
allowed_push_host: https://rubygems.org
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.6.8
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Developer focused CMS for middleman
|
120
|
+
test_files: []
|