Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit for nocms

  • Loading branch information...
commit 30bd67b53749b7d36105f55b4a30dc73f6e03b4a 1 parent b96b7f3
@drush drush authored
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Darren Rush
+Copyright (c) 2010 PowCloud, Inc, Darren Rush
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
9 README.rdoc
@@ -1,6 +1,11 @@
= nocms
-Description goes here.
+NOCMS is a web service that allows you to add basic Content Management to any website. It provides wiki-style editing with a
+few lines of Javascript, and server-sdie rendering and user authentication support with just some simple server-side integration.
+
+If you've ever been involved in hand-to-hand combat with a big, ugly, hard to customize Content Management System (CMS), then NOCMS might be right for your.
+
+http://www.nocms.org/
== Note on Patches/Pull Requests
@@ -14,4 +19,4 @@ Description goes here.
== Copyright
-Copyright (c) 2010 Darren Rush. See LICENSE for details.
+Copyright (c) 2010 PowCloud Inc. See LICENSE for details.
View
8 Rakefile
@@ -5,10 +5,10 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "nocms"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
- gem.email = "dlrush@gmail.com"
- gem.homepage = "http://github.com/drush/nocms"
+ gem.summary = %Q{A Ruby client for the NOCMS.org web service API. Provides server-side helpers for Rails/Sinatra/Rack applications.}
+ gem.description = %Q{A Ruby client for the NOCMS.org web service API. Provides server-side helpers for Rails/Sinatra/Rack applications.}
+ gem.email = "nocms@powcloud.com"
+ gem.homepage = "http://github.com/powcloud/nocms"
gem.authors = ["Darren Rush"]
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
View
40 lib/nocms.rb
@@ -0,0 +1,40 @@
+require 'active_support'
+require 'net/http'
+require 'uri'
+require 'cgi'
+
+@@nocms_pages = nil
+
+# This is a default, that might be override by the app
+@@nocms_lang_default = 'en'
+
+def nocms_can_edit?()
+ settings.environment != :production
+end
+
+def nocms_block(id, options = {})
+ raise 'Must specify an element id as the first parameter. :tag and :content are optional params' if id.nil?
+
+ tag = options[:tag] ||= 'div'
+ site = options[:site] ||= settings.nocms_site ||= request.host_with_port
+ path = options[:path] ||= request.path_info
+ lang = options[:lang] ||= request.env['HTTP_ACCEPT_LANGUAGE'].nil? ? nil : request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first ||= 'en'
+
+ if @@nocms_pages.nil? || @@nocms_pages_updated_at < Time.now - 3*60
+ @@nocms_pages_updated_at = Time.now
+ rq = "http://api.nocms.org/nocms/1.0/export?site=#{site}"
+ json = Net::HTTP.get(URI.parse(rq))
+ results = ActiveSupport::JSON.decode(json)
+ @@nocms_pages = Hash.new
+ results.each do |block|
+ p = block['block']
+ @@nocms_pages["#{p['path']}:#{p['xpath']}"] = p['content']
+ end
+ puts "Loaded #{results.length} blocks"
+ end
+
+ content = @@nocms_pages["/#{lang}#{path}:#{id}"] ||= @@nocms_pages["/#{@@nocms_lang_default}:#{path}:#{id}"] ||= options[:default] ||= 'Lorem ipsum'
+
+ # "%#{tag}\##{id}.edit #{content}"
+ "<#{tag} id='#{id}' class='nocms_edit'>#{content}</#{tag}>"
+end
View
BIN  nocms-0.1.0.gem
Binary file not shown
View
53 nocms.gemspec
@@ -0,0 +1,53 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{nocms}
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Darren Rush"]
+ s.date = %q{2010-08-18}
+ s.description = %q{A Ruby client for the NOCMS.org web service API. Provides server-side helpers for Rails/Sinatra/Rack applications.}
+ s.email = %q{nocms@powcloud.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "lib/nocms.rb",
+ "test/helper.rb",
+ "test/test_nocms.rb"
+ ]
+ s.homepage = %q{http://github.com/powcloud/nocms}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{A Ruby client for the NOCMS.org web service API. Provides server-side helpers for Rails/Sinatra/Rack applications.}
+ s.test_files = [
+ "test/helper.rb",
+ "test/test_nocms.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ else
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
+ end
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.