Chris's first commit at Fri Jan 28 2011 10:14:32 GMT+0800 (CST)

This commit is contained in:
ihower committed 2011-04-13 18:19:51 +08:00
1 parent 554aa0a95d
commit 19a7d51e60
145 files changed
+12742 -893

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
require 'mongo'
module PrototypeR4
module GridIO
def self.included(base)
base.class_eval do
def size
(file_length / chunk_size) + (file_length % chunk_size > 0 ? 1 : 0)
end
def each(&block)
size.times { block.call(read(chunk_size)) }
end
end
end
end
end
+10 -9
View File
@@ -12,17 +12,18 @@ class RerouteMiddleware
env['REQUEST_URI'] =~ /^\/([0-9a-zA-Z\-_\/]*)/
parsed_entry_name = $1
entry = Item.find_by_full_name( parsed_entry_name )
case entry.type.to_s
when 'Component' :
env['REQUEST_URI'] = env['REQUEST_URI'].sub!(parsed_entry_name, entry.engine_name)
env['QUERY_STRING'] = (env['QUERY_STRING'].blank?)? "entry_name=#{parsed_entry_name}" : "entry_name=#{parsed_entry_name}&#{env['QUERY_STRING']}"
when 'Link' :
return [301, {'Location' => entry.url }, ['See Ya!']]
entry = Item.first(:conditions => {:full_name => parsed_entry_name} )
if entry
case entry.type.to_s
when 'Component'
env['REQUEST_URI'] = env['REQUEST_URI'].sub!(parsed_entry_name, entry.engine_name)
env['QUERY_STRING'] = (env['QUERY_STRING'].blank?)? "entry_name=#{parsed_entry_name}" : "entry_name=#{parsed_entry_name}&#{env['QUERY_STRING']}"
when 'Link'
return [301, {'Location' => entry.url }, ['See Ya!']]
end
end
@app.call(env)
end
end
end
+8
View File
@@ -0,0 +1,8 @@
@site_in_use_locales.map{ |locale|
lang = I18nVariable.first(:conditions => {:key => locale})[locale]
if I18n.locale.to_s.eql?(locale)
lang
else
"<a href='?locale=#{locale}'>#{lang}</a>"
end
}.join(' | ')
View File
Whitespace-only changes.
+1 -29
View File
@@ -2,36 +2,8 @@ namespace :dev do
task :build => :environment do
User.delete_all
UserAttribute.delete_all
User.create!( :email => 'ihower@rulingcom.com', :password => 'password', :password_confirmation => 'password', :use_attributes => ["teacher"] )
UserAttribute.create!( :key => "teacher", :name => "Teacher", :attrs => [
{ :name => "Name", :key => "name", :type => "text_field", :locale => false },
{ :name => "Title", :key => "title", :type => 'select', :options => [ ["Professor","1"], ["Associate Professor","2"], ["Doctor","3"] ], :locale => false } ,
{ :name_en => "Discipline", :name_zh_tw => "授課領域", :key => "discipline", :type => "text_field", :locale => true },
{ :name_en => "Category", :name_zh_tw => "類別", :key => "category", :type => 'select', :options_en => [ ["Class1","1"], ["Class2","2"] ], :options_zh_tw => [ ["類別一","1"], ["類別二","2"] ], :locale => true}
])
[Announcement, Item, Snippet, Layout].each { |m| m.delete_all }
Layout.create!( :name => 'root', :description => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read,
:content_en => File.open("#{RAILS_ROOT}/lib/template/root.layout.en").read)
Page.create!( :name => "root", :title => I18n.t(:homepage), :layout_name => "root", :parent_name => nil,
:content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.page.zh_tw").read,
:content_en => File.open("#{RAILS_ROOT}/lib/template/root.page.en").read )
["about"].each do |page_name|
Page.create!( :name => page_name, :title => page_name, :layout_name => "root", :parent_name => "root",
:content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.page.zh_tw").read,
:content_en => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.page.en").read )
end
["nav", "footer", "locale"].each do |page_name|
Snippet.create!( :name => page_name, :parent_name => "root",
:content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.snippet.zh_tw").read,
:content_en => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.snippet.en").read )
end
User.create!( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :use_attributes => ["teacher"] )
end
end