fir 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +4 -0
- data/example/public/dispatch.cgi +34 -0
- data/lib/fir/boot.rb +4 -0
- data/lib/fir/pages.rb +2 -2
- metadata +3 -2
data/README.markdown
CHANGED
@@ -96,6 +96,10 @@ Most of us will be perfectly happy managing content by editing the files in the
|
|
96
96
|
|
97
97
|
Fir isn't a CMS. Instead, it exposes a minimal, RESTful API for managing content. The idea is that content should be managed with specially-designed Fir clients, rather than through Fir itself. You can see how this works by downloading the [example app](http://github.com/jarrett/fir-example), booting it, and visiting `/manage-content.html` in your browser. The source of that page is available [on GitHub](http://github.com/jarrett/fir-example/blob/master/public/manage-content.html).
|
98
98
|
|
99
|
+
Fir's API uses HTTP basic authentication. The users list is stored in `users.yml`. To create a user or change an existing user's password, run:
|
100
|
+
|
101
|
+
rake users:add user=username pass=password
|
102
|
+
|
99
103
|
Webserver Support
|
100
104
|
=================
|
101
105
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# This script is called when running Fir as a CGI, which isn't recommended.
|
4
|
+
# Still, here it is, in case you want to try.
|
5
|
+
#
|
6
|
+
# This script will not be operational unless the webserver is configured properly.
|
7
|
+
# In Apache, you need to enable mod_rewrite in .htaccess files for this directory.
|
8
|
+
# That usually means setting AllowOverride to All. (http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride)
|
9
|
+
# Apache must also be told that CGI is allowed in this directory. This is done with the ExecCGI option
|
10
|
+
# (http://httpd.apache.org/docs/1.3/mod/core.html#options).
|
11
|
+
#
|
12
|
+
# Learn more about CGI under Apache: http://httpd.apache.org/docs/1.3/howto/cgi.html
|
13
|
+
#
|
14
|
+
# You must also set up rewrite rules so the requests get sent to this script.
|
15
|
+
# See how it's done in .htaccess in this directory.
|
16
|
+
#
|
17
|
+
# Besides the performance issues, CGI has another disadvantage. Apache (and perhaps others) unescapes
|
18
|
+
# URLs before sending them to your CGI script. Passenger does not. Fir, being designed for Passenger,
|
19
|
+
# unescapes URLs. So, when running Fir as a CGI, all URLs will be escaped twice. This breaks certain URLs.
|
20
|
+
# For example:
|
21
|
+
#
|
22
|
+
# http://example.com/the%2Bsign
|
23
|
+
#
|
24
|
+
# ...will break. Apache will unescape the path to "the+sign." Fir will then unescape it again to "the sign."
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'fir'
|
28
|
+
|
29
|
+
FIR_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
30
|
+
require File.expand_path(File.join(FIR_ROOT, 'config.rb'))
|
31
|
+
|
32
|
+
builder = Rack::Builder.new(&Fir.boot_proc)
|
33
|
+
|
34
|
+
Rack::Handler::CGI.run builder
|
data/lib/fir/boot.rb
CHANGED
@@ -2,6 +2,10 @@ module Fir
|
|
2
2
|
def self.boot_proc
|
3
3
|
# This get called in config.ru. Thus, Passenger can eval the contents of config.ru the way it wants to
|
4
4
|
lambda do
|
5
|
+
# Depending on the location of the script that invoked Fir, all the relative paths may be messed up.
|
6
|
+
# This happens, for example, when running dispatch.cgi from the public directory. Changing the working
|
7
|
+
# directory fixes that.
|
8
|
+
Dir.chdir(FIR_ROOT)
|
5
9
|
::Fir.validate_config
|
6
10
|
#use ::Rack::Reloader # Only when developing the Fir gem
|
7
11
|
use ::Rack::ContentLength
|
data/lib/fir/pages.rb
CHANGED
@@ -34,12 +34,12 @@ module Fir
|
|
34
34
|
include TemplateLoading
|
35
35
|
|
36
36
|
def initialize
|
37
|
-
@page_config = yaml_or_empty('pages.yml')
|
37
|
+
@page_config = yaml_or_empty(File.join(FIR_ROOT, 'pages.yml'))
|
38
38
|
@path_mappings = @page_config.inject({}) do |mappings, (page, configs)|
|
39
39
|
mappings[configs['path']] = page if configs['path']
|
40
40
|
mappings
|
41
41
|
end
|
42
|
-
@menus = yaml_or_empty('menus.yml')
|
42
|
+
@menus = yaml_or_empty(File.join(FIR_ROOT, 'menus.yml'))
|
43
43
|
end
|
44
44
|
|
45
45
|
def call(env)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- jarrett
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- example/pages/products/dynamite.html.erb
|
99
99
|
- example/pages/products/index.markdown
|
100
100
|
- example/pages/products/mouse-trap.html.erb
|
101
|
+
- example/public/dispatch.cgi
|
101
102
|
- example/public/manage-content.html
|
102
103
|
- example/public/static.txt
|
103
104
|
- example/public/stylesheets/style.css
|