Skip to content

Commit

Permalink
'Runo' -> 'Bike', 'runo' -> 'bike'.
Browse files Browse the repository at this point in the history
  • Loading branch information
afunai committed Sep 20, 2010
1 parent a19d58e commit ab5d0f8
Show file tree
Hide file tree
Showing 87 changed files with 1,489 additions and 1,489 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rdoc
pkg

## PROJECT::SPECIFIC
runo.gemspec
*.gemspec
tmp/*
data*
*~
Expand Down
34 changes: 17 additions & 17 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
= Runo
= Bike

Runo is the easiest web application framework ever.
Bike is the easiest web application framework ever.
You can make various apps such like blog, forum, contact form by putting single (or several) HTML file with a bit of special markups. The view rules. There is no model definition, no server restart, and no coding at all.

== Wiki

http://wiki.github.com/afunai/runo/
http://wiki.github.com/afunai/bike/

== Features

Expand All @@ -16,48 +16,48 @@ http://wiki.github.com/afunai/runo/
* You can make nested apps inside an app (e.g. blog comments inside a blog entry).
* Authentication / Authorization / User admin are built in by default.
* Storage can be plain YAML files (default), or any RDB via Sequel.
* Runo itself is a Rack application.
* Bike itself is a Rack application.

== Quick Start

This is a quick tutorial for making a simple web application using Runo.
This is a quick tutorial for making a simple web application using Bike.

=== Step 1 - Install Runo
=== Step 1 - Install Bike

Open a command line terminal. Type:

gem install runo
gem install bike

If you want to make thumbnails for submitted images, you have to install QuickMagick as well.
http://rubyforge.org/projects/quickmagick/

=== Step 2 - Initialize a Runo Directory
=== Step 2 - Initialize a Bike Directory

In a command line terminal, go to an empty directory where you want to build Runo projects.
In a command line terminal, go to an empty directory where you want to build Bike projects.
Then type:

runo init
bike init

This will create a "runo" directory, which includes:
This will create a "bike" directory, which includes:

runo/
bike/
config.ru
skin/

=== Step 3 - Start a Test Server

In the terminal, change to the newly created "runo" directory.
In the terminal, change to the newly created "bike" directory.
Type:

runo run
bike run

=== Step 4 - Try some examples

Now open this URL with your browser.

http://localhost:9292/

You will see the default homepage of Runo.
You will see the default homepage of Bike.
There is some links to examples such like Blog, Contact Form, Forum, etc. Just see what can be done by plain HTML files.

=== Step 5 - Create Your Own App
Expand All @@ -66,7 +66,7 @@ Let's call our app "fab".
It is a web-based forum where logged in users can submit their own articles, and everybody can read them.
We put links to signup / login at bottom of the app.

Create a new directory under runo/skin/:
Create a new directory under bike/skin/:

mkdir skin/fab/

Expand Down Expand Up @@ -107,7 +107,7 @@ See the URL:
http://localhost:9292/fab/

You have just created your first app. Open a bottle of your favorite drink and make yourself comfortable.
When you need more complicated tricks, HTMLs under skin/examples/ will be your help. Also, you should check out the wiki: http://wiki.github.com/afunai/runo/
When you need more complicated tricks, HTMLs under skin/examples/ will be your help. Also, you should check out the wiki: http://wiki.github.com/afunai/bike/

== Note on Patches/Pull Requests

Expand Down
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = 'runo'
gem.rubyforge_project = 'runo'
gem.name = 'bike'
gem.rubyforge_project = 'bike'
gem.summary = 'The laziest web application framework'
gem.description = <<'_eos'
Runo is a web application framework that can make feature-rich apps by HTML files only.
Bike is a web application framework that can make feature-rich apps by HTML files only.
You need no database setup (by default), no scheme definition, no command-line voodoo.
Just put a good old HTML file under skin/, and your new app is already running.
_eos

gem.authors = ['Akira FUNAI']
gem.email = 'akira@funai.com'
gem.homepage = 'http://github.com/afunai/runo'
gem.homepage = 'http://github.com/afunai/bike'

gem.files = FileList[
'bin/*',
Expand All @@ -28,7 +28,7 @@ _eos
't/skin/**/*',
].to_a
gem.test_files = FileList['t/test_*.rb']
gem.executables = ['runo']
gem.executables = ['bike']

gem.add_dependency('rack', '>= 0.9')
gem.add_dependency('sequel', '>= 3.0')
Expand Down Expand Up @@ -74,7 +74,7 @@ Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "runo #{version}"
rdoc.title = "bike #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
20 changes: 10 additions & 10 deletions bin/bike
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
require 'rubygems'

$LOAD_PATH.unshift(::File.expand_path('../lib',::File.dirname(__FILE__)))
require 'runo'
require 'bike'

case ARGV.shift
when 'init'
runo_dir = ::File.expand_path './runo'
bike_dir = ::File.expand_path './bike'

if ::File.exists? runo_dir
$stderr.puts "#{runo_dir} already exists."
if ::File.exists? bike_dir
$stderr.puts "#{bike_dir} already exists."
exit 1
else
$stderr.puts "Setting up Runo files in #{runo_dir}..."
$stderr.puts "Setting up Bike files in #{bike_dir}..."
::FileUtils.cp_r(
::File.expand_path('../skel',Runo.libdir),
'./runo',
::File.expand_path('../skel',Bike.libdir),
'./bike',
:verbose => :true
)
end
when 'run'
::Dir.chdir(File.exists?('./config.ru') ? '.' : './runo') {
$stderr.puts "Starting a server with Runo files in #{::File.expand_path '.'}..."
::Dir.chdir(File.exists?('./config.ru') ? '.' : './bike') {
$stderr.puts "Starting a server with Bike files in #{::File.expand_path '.'}..."
system('rackup',*ARGV)
}
else
$stderr.puts 'Usage: runo {init|run [Rack options]}'
$stderr.puts 'Usage: bike {init|run [Rack options]}'
exit 1
end
2 changes: 1 addition & 1 deletion lib/_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Author:: Akira FUNAI
# Copyright:: Copyright (c) 2009 Akira FUNAI

module Runo::Error
module Bike::Error

class Forbidden < StandardError
end
Expand Down
36 changes: 18 additions & 18 deletions lib/_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

$KCODE = 'UTF8' if RUBY_VERSION < '1.9.0'

class Runo::Field
class Bike::Field

include Runo::I18n
include Bike::I18n

DEFAULT_META = {}

def self.instance(meta = {})
k = meta[:klass].to_s.split(/-/).inject(Runo) {|c, name|
k = meta[:klass].to_s.split(/-/).inject(Bike) {|c, name|
name = name.capitalize
c.const_get(name)
}
Expand Down Expand Up @@ -60,7 +60,7 @@ def find_ancestor(&block)
end

def meta_name
my[:parent] && !my[:parent].is_a?(Runo::Set::Static::Folder) ?
my[:parent] && !my[:parent].is_a?(Bike::Set::Static::Folder) ?
"#{my[:parent][:name]}-#{my[:id]}" : my[:id]
end

Expand All @@ -69,21 +69,21 @@ def meta_full_name
end

def meta_short_name
return '' if Runo.base && my[:full_name] == Runo.base[:full_name]
my[:parent] && Runo.base && my[:parent][:full_name] != Runo.base[:full_name] ?
return '' if Bike.base && my[:full_name] == Bike.base[:full_name]
my[:parent] && Bike.base && my[:parent][:full_name] != Bike.base[:full_name] ?
"#{my[:parent][:short_name]}-#{my[:id]}" : my[:id]
end

def meta_folder
find_ancestor {|f| f.is_a? Runo::Set::Static::Folder }
find_ancestor {|f| f.is_a? Bike::Set::Static::Folder }
end

def meta_sd
find_ancestor {|f| f.is_a? Runo::Set::Dynamic }
find_ancestor {|f| f.is_a? Bike::Set::Dynamic }
end

def meta_client
Runo.client
Bike.client
end

def meta_owner
Expand All @@ -104,18 +104,18 @@ def meta_group

def meta_roles
roles = 0
roles |= Runo::Workflow::ROLE_ADMIN if my[:admins].include? my[:client]
roles |= Runo::Workflow::ROLE_GROUP if my[:group].include? my[:client]
roles |= Runo::Workflow::ROLE_OWNER if my[:owner] == my[:client]
roles |= (Runo.client == 'nobody') ? Runo::Workflow::ROLE_NONE : Runo::Workflow::ROLE_USER
roles |= Bike::Workflow::ROLE_ADMIN if my[:admins].include? my[:client]
roles |= Bike::Workflow::ROLE_GROUP if my[:group].include? my[:client]
roles |= Bike::Workflow::ROLE_OWNER if my[:owner] == my[:client]
roles |= (Bike.client == 'nobody') ? Bike::Workflow::ROLE_NONE : Bike::Workflow::ROLE_USER
roles
end

def permit?(action)
return false if action == :create && @result == :load
return true unless my[:sd]
return true if my[:sd].workflow.permit?(my[:roles], action)
return true if find_ancestor {|f| f[:id] =~ Runo::REX::ID_NEW } # descendant of a new item
return true if find_ancestor {|f| f[:id] =~ Bike::REX::ID_NEW } # descendant of a new item
end

def default_action
Expand All @@ -129,7 +129,7 @@ def get(arg = {})
_get(arg)
else
if arg[:action]
raise Runo::Error::Forbidden
raise Bike::Error::Forbidden
else
arg[:action] = default_action
end
Expand Down Expand Up @@ -158,7 +158,7 @@ def delete
end

def post(action, v = nil)
raise Runo::Error::Forbidden unless permit_post?(action, v)
raise Bike::Error::Forbidden unless permit_post?(action, v)

if _post action, val_cast(v)
@result = (action == :load || action == :load_default) ? action : nil
Expand Down Expand Up @@ -216,7 +216,7 @@ def _g_empty(arg)
alias :_g_message :_g_empty

def _g_default(arg)
Runo::Field.h val
Bike::Field.h val
end

def _g_errors(arg)
Expand All @@ -226,7 +226,7 @@ def _g_errors(arg)
end

def _g_class(arg)
c = self.class.to_s.sub('Runo::', '').gsub('::', '-').downcase
c = self.class.to_s.sub('Bike::', '').gsub('::', '-').downcase
_g_valid?(arg) ? c : "#{c} error"
end

Expand Down
14 changes: 7 additions & 7 deletions lib/_i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Author:: Akira FUNAI
# Copyright:: Copyright (c) 2009 Akira FUNAI

module Runo::I18n
module Bike::I18n

class Msgstr < String
def %(*args)
Expand Down Expand Up @@ -126,18 +126,18 @@ def self.merge_msg!(m)
module_function

def _(msgid)
Runo::I18n::Msgstr.new(Array(Runo::I18n.msg[msgid]).first || msgid)
Bike::I18n::Msgstr.new(Array(Bike::I18n.msg[msgid]).first || msgid)
end

def n_(msgid, msgid_plural, n)
msgstrs = Runo::I18n.msg[msgid].is_a?(::Array) ? Runo::I18n.msg[msgid] : [msgid, msgid_plural]
case v = Runo::I18n.msg[:plural] ? Runo::I18n.msg[:plural].call(n) : (n != 1)
msgstrs = Bike::I18n.msg[msgid].is_a?(::Array) ? Bike::I18n.msg[msgid] : [msgid, msgid_plural]
case v = Bike::I18n.msg[:plural] ? Bike::I18n.msg[:plural].call(n) : (n != 1)
when true
Runo::I18n::Msgstr.new msgstrs[1]
Bike::I18n::Msgstr.new msgstrs[1]
when false
Runo::I18n::Msgstr.new msgstrs[0]
Bike::I18n::Msgstr.new msgstrs[0]
else
Runo::I18n::Msgstr.new msgstrs[v.to_i]
Bike::I18n::Msgstr.new msgstrs[v.to_i]
end
end

Expand Down
12 changes: 6 additions & 6 deletions lib/_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Author:: Akira FUNAI
# Copyright:: Copyright (c) 2009 Akira FUNAI

module Runo::Parser
module Bike::Parser

module_function

def parse_html(html, action = :index, xml = false)
item = {}

html = gsub_block(html, '(?:app|runo)-\w+') {|open, inner, close| # "runo" is obsolete at 0.1.1
html = gsub_block(html, '(?:app|bike)-\w+') {|open, inner, close| # "bike" is obsolete at 0.1.1
id = open[/id="(.+?)"/i, 1] || 'main'
item[id] = parse_block(open, inner, close, action, xml)
"$(#{id})"
Expand Down Expand Up @@ -106,7 +106,7 @@ def skip_comment(s)

def scrape_meta(html)
meta = {}
html.gsub!(/(?:^\s+)?<meta[^>]*name="runo-([^"]+)[^>]*content="([^"]+).*?>\n?/i) {
html.gsub!(/(?:^\s+)?<meta[^>]*name="bike-([^"]+)[^>]*content="([^"]+).*?>\n?/i) {
meta[$1.intern] = $2.include?(',') ? $2.split(/\s*,\s*/) : $2
''
}
Expand All @@ -118,7 +118,7 @@ def scrape_label(html)
label_plural = $2.to_s.split(/,/).collect {|s| s.strip }
label_plural *= 4 if label_plural.size == 1
label = label_plural.first
Runo::I18n.msg[label] ||= label_plural
Bike::I18n.msg[label] ||= label_plural
label
end
end
Expand Down Expand Up @@ -153,7 +153,7 @@ def supplement_ss(tmpl, action)

def parse_block(open_tag, inner_html, close_tag, action = :index, xml = false)
open_tag.sub!(/id=".*?"/i, 'id="@(name)"')
workflow = open_tag[/class=(?:"|".*?\s)(?:app|runo)-(\w+)/, 1] # "runo" is obsolete at 0.1.1
workflow = open_tag[/class=(?:"|".*?\s)(?:app|bike)-(\w+)/, 1] # "bike" is obsolete at 0.1.1

if inner_html =~ /<(?:\w+).+?class=(?:"|"[^"]*?\s)(model|body)(?:"|\s)/i # "body" is obsolete at 0.1.1
item_html = ''
Expand All @@ -179,7 +179,7 @@ def parse_block(open_tag, inner_html, close_tag, action = :index, xml = false)
tmpl[action] = "#{open_tag}#{sd_tmpl}#{close_tag}"
tmpl[action].gsub!(/\s*class=".*?"/,'') if xml

item_meta = Runo::Parser.parse_html(item_html, action, xml)
item_meta = Bike::Parser.parse_html(item_html, action, xml)
supplement_ss(item_meta[:tmpl][action], action) unless xml || workflow == 'attachment'

sd = {
Expand Down
Loading

0 comments on commit ab5d0f8

Please sign in to comment.