Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fixes on forms (errors), better yaml implementation, some config …

…changes
  • Loading branch information...
commit 2a607d68650370d2512662c0af77dbb0e8870739 1 parent 2434c4c
Zach Karpinski authored
View
42 README
@@ -1,22 +1,7 @@
---
Jekyll Admin: By Zach Karpinski <zkarpinski [at] gmail [dot] com>
-LICENSE:
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
----
-
-Jekyll Admin assumes several conditions are met:
+This software assumes several conditions are met:
1. You have a functioning Jekyll blog already configured
2. You are placing Jekyll Admin into the RAILS_ROOT of a functioning Rails application.
3. You want to save your posts in HTML format.
@@ -39,37 +24,14 @@ these variables when creating any templates for your posts.
Jekyll Admin currently assumes all files are going to be stored with html markdown.
-jHtmlArea is included with this software. You can read more about it here:
-http://jhtmlarea.codeplex.com/
-
-If you want to remove the Wysiwyg interface simple edit app/views/jekyll_admin/_form.html.erb and
-delete the first and last three lines from the file.
-
You can find Jekyll Admin updates on Git Hub:
http://github.com/zkarpinski/Jekyll-Admin
-SCREENSHOTS:
-Example of a listing of blog posts:
-http://github.com/downloads/zkarpinski/Jekyll-Admin/Screen%20shot%202010-03-16%20at%203.18.10%20PM.png
-
-Example of editing a post:
-http://github.com/downloads/zkarpinski/Jekyll-Admin/Screen%20shot%202010-03-16%20at%203.19.23%20PM.png
-
INSTALLATION:
I recommend copying these files into your existing rails app by hand.
-Download from git
+Download from git:
git clone http://github.com/zkarpinski/Jekyll-Admin.git
-OR
-wget http://github.com/downloads/zkarpinski/Jekyll-Admin/Jekyll-Admin.zip; unzip -a Jekyll-Admin.zip
-
rm -rf Jekyll-Admin/.git
rm Jekyll-Admin/.gitignore
cp -R Jekyll-Admin/* /my/web/site.com/
-
-Credits:
-I originally created Jekyll Admin for the backend of http://changethis.com/. Change This is operated and
-hosted by my employer 800-CEO-READ (http://800ceoread.com). Change This is a great place to get out
-your ideas and challenge the status quo, no matter what your opinion is. 800-CEO-READ is a great place
-to order bulk business books. When you need 20 or more copies of a book somewhere on a certain date,
-they can do it. Even if that "somewhere" is more than one place.
View
8 app/controllers/jekyll_admin_controller.rb
@@ -1,6 +1,6 @@
-class JekyllAdminController < ApplicationController
+class JekyllAdminController < PublicController
before_filter :load_configs
-
+ layout "wide"
def index
@posts = JekyllAdmin.all
end
@@ -27,6 +27,7 @@ def edit
else
params[:id] = "#{params[:id]}.#{params[:format]}"
end
+
@post = JekyllAdmin.load(params[:id])
if request.post?
errors = form_errors
@@ -70,6 +71,7 @@ def form_errors
end
def load_configs
+ @post_template = false
@admin_config = JekyllAdmin.admin_config
logger.info @admin_config["ip_address_restriction"].split(",").each { |ip| ip.strip! }.inspect
@admin_config["ip_address_restriction"].split(",").each do |ip|
@@ -84,4 +86,4 @@ def load_configs
redirect_to "/"
end
end
-end
+end
View
26 app/models/jekyll_admin.rb
@@ -1,7 +1,6 @@
class JekyllAdmin
- #LOG = Logger.new(RAILS_ROOT + "/log/jekyll.log")
- #LOG.level = Logger::WARN
-
+ LOG = Logger.new(RAILS_ROOT + "/log/jekyll.log")
+
def initialize(values = {})
@data = Hash.new
values.each do |key,value|
@@ -29,7 +28,7 @@ def self.load(filename)
end
if content and content.size > 0
YAML::load(ERB.new(content).result(binding)).symbolize_keys.each do |key,value|
- obj.send("#{key}=",value)
+ obj.send("#{key}=",value.gsub(/\"/,""))
end
end
obj.body = body || ""
@@ -50,24 +49,13 @@ def save
file.puts("---")
JekyllAdmin.post_template.each do |key,value|
if not @excluded_keys.include?(key.to_s)
- # Strip newlines from yaml value
- @data[key].gsub!(/\n/m," ")
-
- # Colons that appear in text (ie, not with numbers in front of them) make yaml sad. Lets convert these
- @data[key].gsub!(/:\/\//,"&#58;//") # http://urls.com
- @data[key].gsub!(/: /,"&#58; ") # Normal text: like this
- @data[key].gsub!(/ : /," &#58; ") # Floating : colon
file.puts("#{key}: \"#{@data[key]}\"")
end
end
file.puts("---")
- if JekyllAdmin.admin_config["content_top"].strip.size > 0
- file.puts("{% " + JekyllAdmin.admin_config["content_top"] + " %}")
- end
+ file.puts("{% " + JekyllAdmin.admin_config["content_top"] + " %}")
file.puts(body)
- if JekyllAdmin.admin_config["content_bottom"].strip.size > 0
- file.puts("{% " + JekyllAdmin.admin_config["content_bottom"] + " %}")
- end
+ file.puts("{% " + JekyllAdmin.admin_config["content_bottom"] + " %}")
file.close
end
@@ -106,14 +94,14 @@ def self.config
end
def self.post_template
- YAML.load_file(File.join(Rails.root, "config","jekyll_admin_post_template.yml"))
+ YAML.load_file(File.join(Rails.root,"config","jekyll_admin_post_template.yml"))
end
def self.publish
admin_config = JekyllAdmin.admin_config
Dir.chdir(File.join(Rails.root,admin_config["relative_blog_path"]))
system("#{admin_config["jekyll_bin_path"]}")
- if admin_config["post_publish_commands"] and admin_config["post_publish_commands"].size > 0
+ if admin_config["post_publish_commands"].size > 0
Dir.chdir(Rails.root)
system("#{admin_config["post_publish_commands"]}")
sleep 1
View
4 app/views/jekyll_admin/_form.html.erb
@@ -17,6 +17,4 @@
<%= f.submit "Save" %> <%= link_to "Cancel", :back %>
-<script>
-$("textarea").htmlarea();
-</script>
+<script>$("textarea").htmlarea();</script>
View
3  config/jekyll_admin.yml
@@ -23,6 +23,9 @@ field_format_time: ^(\d|\d\d):(\d|\d\d) (am|pm|a.m.|p.m.)$,Must be in format HH&
# *** Omit comma for single entry.
ip_address_restriction: 10.15.30.
+# If you use layouts, change "default" to whatever your post layout is.
+default_post_layout: default
+
# If you want Jekyll Admin to automatically maintain includes above and below your body text
# edit the appropriate field. The system will automatically place the values below between {% and %}.
# Leave blank if you do not have includes in your posts.
Please sign in to comment.
Something went wrong with that request. Please try again.