Commit 24405209 authored by 神楽坂玲奈's avatar 神楽坂玲奈

4-1

git-svn-id: http://glupx.googlecode.com/svn/trunk/Reliz@59 189f022a-1064-8ae2-3e6f-c4a67275c50b
parent 87965f10
class ApplicationController < ActionController::Base
Themes_Dir = 'app/views/themes'
protect_from_forgery
before_filter :load_settings
......@@ -19,36 +21,46 @@ class ApplicationController < ActionController::Base
end
end
def load_locale
p request.env['HTTP_ACCEPT_LANGUAGE']
#locale = @correct_user.locale || (
# request_language =
#request_language && request_language['HTTP_ACCEPT_LANGUAGE'][/[^,;]+/]
#)
#I18n.locale = locale if File.exist?("#{RAILS_ROOT}/config/locales/#{request_language}.yml")
locale = @correct_user.locale || (
request_language =
request_language && request_language['HTTP_ACCEPT_LANGUAGE'][/[^,;]+/]
)
I18n.locale = locale if File.exist?("#{RAILS_ROOT}/config/locales/#{request_language}.yml")
User::Guest.name = t 'user.guest'
#IE && FF are BANNED
end
def load_theme
if !@correct_user.theme.blank?
theme_path = "app/themes/#{@correct_user.theme}"
prepend_view_path theme_path if File.directory? theme_path
elsif !@site.theme.blank?
theme_path = "app/themes/#{@site.theme}"
prepend_view_path theme_path if File.directory? theme_path
end
case #TODO: DRY
when @site[:themes].has_key?(cookies[:theme])
prepend_view_path File.join Themes_Dir, cookies[:theme]
when @site[:themes].has_key?(@correct_user.theme)
prepend_view_path File.join Themes_Dir, @correct_user.theme
when @site[:themes].has_key?(@site.theme)
prepend_view_path File.join Themes_Dir, @site.theme
end
end
def load_settings
@site = {
:name => "Reliz",
:theme => nil
:theme => nil,
}
def @site.method_missing(method, *args)
self[method]# || super
end
def @site.to_s
"<a href=\"/\">#{name}</a>".html_safe
end
self[method]# || super
end
def @site.to_s
"<a href=\"/\">#{name}</a>".html_safe
end
#cache
@site[:themes] = {}
Dir.foreach(Themes_Dir) do |file|
theme_config_file = File.join Themes_Dir, file, "theme.yml"
if File.file? theme_config_file
@site[:themes][file] = YAML.load_file(theme_config_file)
end
end
p @site[:themes]
end
def redirect_to_thc
redirect_to("http://www.touhou.cc/bbs/"+params[:anything]+"?"+env['QUERY_STRING'])
redirect_to("http://www.touhou.cc/bbs/"+params[:anything]+"?"+env['QUERY_STRING'])
end
end
\ No newline at end of file
......@@ -116,4 +116,17 @@ class UsersController < ApplicationController
format.xml { head :ok }
end
end
def theme
if params[:theme].blank?
cookies[:theme] = nil
@correct_user.update_attribute(:theme, nil)
elsif @site[:themes].has_key? params[:theme]
cookies[:theme] = params[:theme]
@correct_user.update_attribute(:theme, params[:theme])
end
respond_to do |format|
format.html { redirect_to :back }
format.xml { head :ok }
end
end
end
......@@ -66,7 +66,7 @@
Drop
</option>
</select>
囧 囧 囧 囧
<% render 'layouts/themebar' %>
</td>
</tr>
</table>
......
<!--<script type="text/javascript">
function setstyle(styleid) {
str = unescape('styleid%3D57');
str = str.replace(/(^|&)styleid=\d+/ig, '');
str = (str != '' ? str + '&' : '') + 'styleid=' + styleid;
location.href = 'index.php?' + str;
}
</script>
<ul id="style_switch"><li><a href="###" onclick="setstyle(50)" title="緋紅" style="background: ;">緋紅</a></li><li><a href="###" onclick="setstyle(48)" title="金黃" style="background: ;">金黃</a></li><li><a href="###" onclick="setstyle(39)" title="翠绿" style="background: ;">翠绿</a></li><li><a href="###" onclick="setstyle(40)" title="炫紫" style="background: ;">炫紫</a></li><li><a href="###" onclick="setstyle(54)" title="酷黑" style="background: ;">酷黑</a></li><li><a href="###" onclick="setstyle(51)" title="銀白" style="background: ;">銀白</a></li><li><a href="###" onclick="setstyle(52)" title="深藍" style="background: ;">深藍</a></li><li><a href="###" onclick="setstyle(55)" title="亮橙" style="background: ;">亮橙</a></li><li><a href="###" onclick="setstyle(56)" title="清蓝" style="background: ;">清蓝</a></li><li class="current"><a href="###" onclick="setstyle(57)" title="夜露" style="background: ;">夜露</a></li><li><a href="###" onclick="setstyle(61)" title="圣诞" style="background: ;">圣诞</a></li><li><a href="###" onclick="setstyle(74)" title="黑色回忆" style="background: #373A3C;">黑色回忆</a></li></ul>
-->
<% unless @site.themes.empty? %>
<div id ="themebar">
<ul>
<li><%= link_to 'default', theme_path %></li>
<% @site.themes.each_pair do |name, theme| %>
<li><%= link_to name, theme_path, :theme => name %></li>
<% end %>
</ul>
</div>
<% end %>
\ No newline at end of file
......@@ -31,15 +31,7 @@
<div id="menu">
<%= render "layouts/navibar" %>
</div>
<script type="text/javascript">
function setstyle(styleid) {
str = unescape('fromuid%3D8507%26styleid%3D57');
str = str.replace(/(^|&)styleid=\d+/ig, '');
str = (str != '' ? str + '&' : '') + 'styleid=' + styleid;
location.href = 'index.php?' + str;
}
</script>
<%= render 'layouts/themebar' %>
</div>
</div>
......
Reliz::Application.routes.draw do
resources :settings
resources :settings
resources :moderations
resources :boards
......@@ -8,6 +8,7 @@ Reliz::Application.routes.draw do
root :to => 'boards#index'
resources :users
match 'theme' => 'users#theme'
get 'login' => 'users#login'
post 'login' => 'users#login_do'
get 'logout' => 'users#logout'
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment