Fix bugs and changes for nccu

This commit is contained in:
Christophe Vilayphiou 2012-02-24 19:11:51 +08:00 committed by Christophe Vilayphiou
parent f4d663c67d
commit f13ebc6c46
20 changed files with 98 additions and 61 deletions

View File

@ -20,6 +20,7 @@ gem 'rubyzip'
gem 'sinatra' gem 'sinatra'
gem 'sprockets' gem 'sprockets'
gem 'tinymce-rails' gem 'tinymce-rails'
gem 'therubyracer'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.

View File

@ -179,6 +179,8 @@ GEM
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
subexec (0.2.1) subexec (0.2.1)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
thor (0.14.6) thor (0.14.6)
tilt (1.3.3) tilt (1.3.3)
tinymce-rails (3.4.8) tinymce-rails (3.4.8)
@ -234,6 +236,7 @@ DEPENDENCIES
sinatra sinatra
spork spork
sprockets sprockets
therubyracer
tinymce-rails tinymce-rails
uglifier uglifier
watchr watchr

View File

@ -7,5 +7,4 @@
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require page_edit //= require page_edit
//= require side_bar_history //= require side_bar_history
//= require rc

View File

@ -60,10 +60,10 @@ class Admin::PagesController < ApplicationController
def update def update
@item = Page.find(params[:id]) @item = Page.find(params[:id])
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank? if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
end end
if @item.update_attributes(params[:page]) if @item.update_attributes(params[:page])
flash[:notice] = t('admin.update_success_page') flash[:notice] = t('admin.update_success_page')

View File

@ -11,7 +11,7 @@ module Admin::ItemHelper
end end
ret << "<ul class='list'>" ret << "<ul class='list'>"
ret << "<li>" ret << "<li>"
ret << (link_to node.name, dest) ret << (link_to node.i18n_variable[I18n.locale], dest)
ret << ' | ' << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page') ret << ' | ' << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page')
ret << ' | ' << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page') ret << ' | ' << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page')
ret << ' | ' << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page') ret << ' | ' << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page')

View File

@ -20,7 +20,7 @@ class Design
validates_presence_of :title validates_presence_of :title
validates_presence_of :author validates_presence_of :author
# after_save :parse_css_for_images after_save :parse_css_for_images
def new_files=(*attrs) def new_files=(*attrs)
attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs

View File

@ -18,7 +18,7 @@
<td> <td>
<%= design.title %> <%= design.title %>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills">
<li><%= link_to t(:edit), edit_admin_design_path(design), :class => 'edit' %></li> <li><%= link_to t(:edit), edit_admin_design_path(design), :class => 'edit' %></li>
<li class="dropdown"><%= link_to t(:delete), admin_design_path(design), :confirm => t('sure?'), :method => :delete, :class => 'delete' %></li> <li class="dropdown"><%= link_to t(:delete), admin_design_path(design), :confirm => t('sure?'), :method => :delete, :class => 'delete' %></li>
</ul> </ul>

View File

@ -9,7 +9,7 @@
<li><%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %></li> <li><%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-asset') + t('admin.asset'), admin_assets_path %></li> <li><%= link_to content_tag(:i, nil, :class => 'icons-asset') + t('admin.asset'), admin_assets_path %></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="#"><i class="icons-structure"></i>Structure</a></li> <li><%= link_to content_tag(:i, nil, :class => 'icons-structure') + t('admin.structure'), admin_items_path %></li>
<li><a href="#"><i class="icons-plus-cube"></i>Add Item</a></li> <li><a href="#"><i class="icons-plus-cube"></i>Add Item</a></li>
</ul> </ul>
</div> </div>

View File

@ -4,28 +4,24 @@
<%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys') do -%> <%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys')) do -%>
<%= content_tag :li, link_to(t('admin.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> <%= content_tag :li, link_to(t('admin.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
<%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
<%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
<%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %>
<% end -%> <% end -%>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers('users') do -%> <%= content_tag :li, :class => active_for_controllers('users') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %> <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%> <%= content_tag :li, :class => active_for_controllers(nil) do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), admin_pages_path %> <%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), panel_page_content_back_end_page_contexts_path %>
<%#= content_tag :ul, :class => "nav nav-list" do -%>
<%#= content_tag :li, link_to(t('admin.all_pages'), panel_page_content_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
<%#= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
<%# end -%>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers('designs') do -%> <%= content_tag :li, :class => active_for_controllers('designs') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%> <%= content_tag :li, :class => active_for_controllers(nil) do -%>

View File

@ -6,7 +6,7 @@ module ParserCommon
if current != 0 if current != 0
res << "<div class='rc_dm'>" res << "<div class='rc_dm'>"
item = rand(100000) item = rand(100000)
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.name}<span class='down'></span></a>" res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl' rel='#{item}'>#{page.i18n_variable[I18n.locale]}<span class='down'></span></a>"
if page.children.size > 0 if page.children.size > 0
res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>" res << "<div id='#{item}' class='dm_list #{menu.values['class_#{current}']}'>"
res << "<ul class='ini_list'>" res << "<ul class='ini_list'>"
@ -22,7 +22,7 @@ module ParserCommon
res << "</div>" res << "</div>"
else else
res << '<ul>' res << '<ul>'
res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.name}</a>" + "</li>" res << "<li>" + "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>" + "</li>"
page.children.each do |child| page.children.each do |child|
res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>" res << "<li>" + menu_level(child, current + 1, menu, edit) + "</li>"
end end
@ -39,7 +39,7 @@ module ParserCommon
if page.children.size > 0 if page.children.size > 0
res << menu_level(page, current + 1, menu, edit) res << menu_level(page, current + 1, menu, edit)
else else
res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.name}</a>" res << "<a href='#{edit ? admin_page_path(page.id) : page.full_name}' class='nav dm_ctrl'>#{page.i18n_variable[I18n.locale]}</a>"
end end
res << "</li>" res << "</li>"
end end

View File

@ -0,0 +1,11 @@
# encoding: utf-8
namespace :add_content do
task :build => :environment do
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/page_content/page_content.json").read).save
end
end

View File

@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
date_now = Time.now date_now = Time.now
if params[:bulletin_category_id] if params[:bulletin_category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
else else
@bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(1) @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
end end
get_categorys get_categorys

View File

@ -2,6 +2,7 @@
<%= f.error_messages %> <%= f.error_messages %>
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
<div class="field"> <div class="field">
<%= f.label :image, t('announcement.image') %><br /> <%= f.label :image, t('announcement.image') %><br />
<%= f.file_field :image %> <%= f.file_field :image %>
@ -140,6 +141,7 @@
}); });
</script> </script>
<% end %> <% end %>
<<<<<<< HEAD
<!--Widget start--> <!--Widget start-->
<!-- <div id="sub-wiget"> <!-- <div id="sub-wiget">
@ -527,4 +529,6 @@
<button class="btn btn-success" type="submit">Preview/預覽</button> <button class="btn btn-success" type="submit">Preview/預覽</button>
<button class="btn btn-primary" type="submit">Submit/送出</button> <button class="btn btn-primary" type="submit">Submit/送出</button>
<button class="btn" type="reset">Cancel/取消</button> <button class="btn" type="reset">Cancel/取消</button>
<!-- </div> --> <!-- </div> -->
=======
>>>>>>> Fix bugs and changes for nccu

View File

@ -2,30 +2,28 @@
<%= flash_messages %> <%= flash_messages %>
<%= paginate @bulletins %>
<h1 class="h1"><%= t('bulletin.list_announcement') %></h1> <h1 class="h1"><%= t('bulletin.list_announcement') %></h1>
<table class="table table-bordered"> <table class="table table-bordered">
<tr> <tr>
<th><%= t('bulletin.postdate') %></th> <th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.category') %></th> <th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.title') %></th> <th><%= t('bulletin.postdate') %></th>
</tr> </tr>
<% @bulletins.each do |post| %> <% @bulletins.each do |post| %>
<tr> <tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td> <td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %> <td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td> </td>
<td><%= post.postdate %></td> <td><%= post.postdate %></td>
</tr> </tr>
<% end %> <% end %>
</table>
</table> <%= paginate @bulletins %>
<br />

View File

@ -1,9 +1,23 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<h1 class="h1"><%= @bulletin.title[I18n.locale] %></h1>
<br /> <div class="info">
<br /> <div class="info1">
<br /> <span class="date"><%= @bulletin.postdate %></span>
&nbsp;|&nbsp;
<a href="" class="unit"><%= User.find(@bulletin.create_user_id).name %></a>
</div>
</div>
<div class="news_image">
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
</div>
<div class="news_paragraph">
<%= @bulletin.text[I18n.locale].html_safe %>
</div>
<div class="fb">
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.nccu.edu.tw&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35&amp;appId=263319013700607" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>
</div>
<!--
<p id="notice"><%= flash_messages %></p> <p id="notice"><%= flash_messages %></p>
<ul> <ul>
@ -25,11 +39,11 @@
</li> </li>
<li> <li>
<b><%= t('announcement.subtitle') %></b> <b><%= t('announcement.subtitle') %></b>
<%= @bulletin.subtitle[I18n.locale] %> <%= @bulletin.subtitle[I18n.locale].html_safe %>
</li> </li>
<li> <li>
<b><%= t('announcement.text') %></b> <b><%= t('announcement.text') %></b>
<%= @bulletin.text[I18n.locale] %> <%= @bulletin.text[I18n.locale].html_safe %>
</li> </li>
<li> <li>
<li> <li>
@ -52,6 +66,6 @@
<b><%= t('announcement.最後修改時間') %></b> <b><%= t('announcement.最後修改時間') %></b>
<%= @bulletin.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> <%= @bulletin.updated_at.strftime("%Y-%m-%d %H:%I:%S") %>
</li> </li>
-->
<%#= link_back %> <%#= link_back %>

View File

@ -2,7 +2,7 @@
<% if @bulletins and !@bulletins.nil? %> <% if @bulletins and !@bulletins.nil? %>
<h2 class="topic_title"><%= t('焦點新聞')%></h2> <h2 class="topic_title"><%= t('校園新聞')%></h2>
<%= link_to "more+",panel_announcement_front_end_bulletins_path(), :class => "topic_note" %> <%= link_to "more+",panel_announcement_front_end_bulletins_path(), :class => "topic_note" %>
<div class="topic_prev">previous page</div> <div class="topic_prev">previous page</div>
<div class="topic_next">next page</div> <div class="topic_next">next page</div>

View File

@ -3,6 +3,6 @@
<p id="notice"><%= flash_messages %></p> <p id="notice"><%= flash_messages %></p>
<h2><%= @page_context.page.i18n_variable[I18n.locale] %></h2> <h1 class="h1"><%= @page_context.page.i18n_variable[I18n.locale] rescue nil %></h1>
<div class="page_content"><%= @page_context.context[I18n.locale].html_safe %></div> <div class="page_content"><%= @page_context.context[I18n.locale].html_safe rescue nil %></div>

View File

@ -14,7 +14,7 @@ class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
# @web_link = WebLink.where( :is_hidden => false ).desc(:is_top, :name).first # @web_link = WebLink.where( :is_hidden => false ).desc(:is_top, :name).first
@web_links = WebLink.widget_datas.page(params[:page]).per(5) @web_links = WebLink.widget_datas.page(params[:page]).per(9)
# get_categorys # get_categorys
@ -24,7 +24,7 @@ class Panel::WebResource::Widget::WebLinksController < ObitWidgetController
end end
def reload_web_links def reload_web_links
@web_links = WebLink.widget_datas.page(params[:page]).per(5) @web_links = WebLink.widget_datas.page(params[:page]).per(9)
end end

View File

@ -0,0 +1,10 @@
<ul>
<% @web_links.each do |widget| -%>
<li><%= link_to widget.name[I18n.locale], widget.url, {:target => '_blank', :title => widget.name[I18n.locale]} %></li>
<% end -%>
</ul>
<div class='pagination'>
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/web_links', :action => 'reload_web_links'}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/web_links', :action => 'reload_web_links'}, :remote => true, :class => 'next' %>
</div>

View File

@ -0,0 +1 @@
$('#web_links_links').html("<%= j render 'web_links' if @web_links %>")