Merge branch 'nccu_ie' of https://github.com/Rulingcom/NCCU into nccu_ie

This commit is contained in:
Harry Bomrah committed 2012-08-13 18:46:45 +08:00
commit 31f1f8092b
58 files changed
+2848 -421

No files matched your search

+2 -1
View File
@@ -6,4 +6,5 @@
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require_tree .
//= social-share-button
@@ -0,0 +1,33 @@
window.SocialShareButton =
openUrl : (url) ->
window.open(url)
false
share : (el) ->
site = $(el).data('site')
title = encodeURIComponent($(el).parent().data('title'))
img = encodeURIComponent($(el).parent().data("img"))
fb_url = encodeURIComponent($(el).parent().data("fb_url"))
url = encodeURIComponent(location.href)
switch site
when "weibo"
SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8")
when "twitter"
SocialShareButton.openUrl("https://twitter.com/home?status=#{title}: #{url}")
when "douban"
SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}")
when "facebook"
SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}")
when "qq"
SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}")
when "tqq"
SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}")
when "baidu"
SocialShareButton.openUrl("http://apps.hi.baidu.com/share/?url=#{url}&title=#{title}&content=")
when "kaixin001"
SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}")
when "renren"
SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&title=#{title}&description=")
when "google_plus"
SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}&t=#{title}")
false
@@ -47,7 +47,6 @@ function myFileBrowser(field_name, url, type, win) {
var cmsURL = window.location.toString();
cmsURL = cmsURL.split("/");
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
// console.log(cmsURL);
// script URL - use an absolute path!
if (cmsURL.indexOf("?") < 0) {
//add the type as the only query parameter
+1 -1
View File
@@ -3,5 +3,5 @@
*and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
*the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require social-share-button
*/
File diff suppressed because it is too large. Load diff
+61 -35
View File
@@ -31,8 +31,7 @@
padding-bottom: 1px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset;
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset;
background-image: -moz-linear-gradient(top, #5282A6, #133757);
background-image: -ms-linear-gradient(top, #5282A6, #133757);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5282A6), to(#133757));
@@ -40,15 +39,6 @@
background-image: -o-linear-gradient(top, #5282A6, #133757);
background-image: linear-gradient(top, #5282A6, #133757);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5282A6', endColorstr='#133757', GradientType=0);
/*
background-image: -moz-linear-gradient(top, #545b60, #191a1c);
background-image: -ms-linear-gradient(top, #545b60, #191a1c);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#545b60), to(#191a1c));
background-image: -webkit-linear-gradient(top, #545b60, #191a1c);
background-image: -o-linear-gradient(top, #545b60, #191a1c);
background-image: linear-gradient(top, #545b60, #191a1c);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#545b60', endColorstr='#191a1c', GradientType=0);
*/
}
#orbit-bar .navbar-search {
left: 28px;
@@ -62,25 +52,20 @@
}
#orbit-bar .search-query {
padding: 7px 9px 5px;
height: 10px;
height: 11px;
margin-top: 3px;
border: 1px solid #333333;
font-size: 11px;
/*background-color: rgba(255, 255, 255, 0.8);
color: #333;
text-shadow: 0px 1px 0px #FFF;*/
line-height: 21px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) inset, 0 1px 0 rgba(255, 255, 255, 0.15);
}
#orbit-bar .search-query:focus {
/*background-color: rgba(255, 255, 255, 0.9);
text-shadow: 0px 1px 0px #FFF;*/
background-position: 5px 2px;
}
#orbit-bar .container {
width:100%;
}
#orbit-bar .orbit-logo .brand {
/* background: url(<%= asset_path 'orbit-bar.png' %>) no-repeat -162px -5px; */
background: url(<%= asset_path 'nccu_logo.png' %>) no-repeat 6px 0px;
text-indent:-9999px;
padding: 5px 20px 4px;
@@ -118,8 +103,7 @@
background-position: -10px -10px;
}
#orbit-bar .nav > li > a.orbit-bar-desktop {
background-position: -73px -42px;
width: 48px;
background-position: -73px -42px;width: 48px;
}
#orbit-bar .nav > li > a.orbit-bar-member {
background-position: -4px -37px;
@@ -190,7 +174,7 @@
margin: 0;
}
#orbit-bar .bar-login .dropdown-menu .log .span2 {
width: 183px;
width: 182px;
}
#orbit-bar .bar-login .dropdown-menu .log .forgot {
margin-bottom: 20px;
@@ -286,18 +270,9 @@
background-color: #FFF;
margin-left:160px;
padding-top: 32px;
/*padding-bottom: 18px;*/
position: relative;
padding-bottom: 45px;
/*min-height: 100%;*/
position: relative;
}
/*#main-wrap > .form-actions {
background-color: #FFF;
text-align: center;
padding: 17px 20px 0;
margin: 0;
border-top: none;
}*/
#main-wrap .subnav {
height: auto;
min-height: 36px;
@@ -378,11 +353,10 @@
#post-body .editor {
}
#post-body-content {
/*margin-right: 320px;*/
padding: 8px 0 8px 6px;
}
.filter .accordion-heading > a:hover {
text-decoration: none;
text-decoration: none;
}
.filter .accordion-group {
border-bottom: none;
@@ -581,6 +555,22 @@
/*background-color: #AF0045;
border-left: 2px solid #AF0045;*/
}
.gender {
position: absolute;
border-radius: 0 0 5px 0;
border-width: 10px;
margin: 0;
border-style: solid;
z-index: 10;
bottom: 0;
right: 0;
}
.gender.male {
border-color: transparent #41B1D5 #41B1D5 transparent;
}
.gender.female {
border-color: transparent #DB186E #DB186E transparent;
}
.user-info .roles-nav {
margin: 0;
position: relative;
@@ -642,6 +632,20 @@
min-width: 220px;
display: inline-block;
float: left;
position: relative;
}
.user-info-basic .gender {
border-radius: 0;
top: 0;
left: 0;
right: auto;
bottom: auto;
}
.user-info-basic .gender.male {
border-color: #41B1D5 transparent transparent #41B1D5;
}
.user-info-basic .gender.female {
border-color: #DB186E transparent transparent #DB186E;
}
.user-info-roles {
padding: 20px;
@@ -655,7 +659,7 @@
margin-right: 10px;
}
.user-avatar .reflective {
background-image: url(img/reflective.png);
background-image: url(<%= asset_path 'reflective.png' %>);
background-repeat: no-repeat;
background-position: 0;
height: 80px;
@@ -663,7 +667,7 @@
position: absolute;
}
.user .user-avatar .reflective {
background-image: url(img/reflective.png);
background-image: url(<%= asset_path 'reflective.png' %>);
background-repeat: no-repeat;
background-position: 0 -20px;
height: 80px;
@@ -855,6 +859,7 @@
.site-map .map-block ul {
margin: 0px;
list-style: none;
width: 220px \9;
}
.site-map .map-block li {
font-size: 12px;
@@ -929,6 +934,27 @@
margin-top: 2px;
}
.modal.alert-error {
color: #B94A48;
background-color: #F2DEDE;
border-color: #EED3D7;
}
.news_paragraph p {
line-height: 20px;
}
.nav-tabs>li>.edit, .nav-tabs>li>.edit:hover {
background-color: #333;
color: #FFF;
padding-right: 12px;
}
.nav-tabs li .icons-pencil {
float: right;
margin-top: 8px;
}
.nav-tabs li a {
padding-right: 32px;
}
/*icons*/
.the-icons i:after {
@@ -106,6 +106,15 @@ class ApplicationController < ActionController::Base
render :text => '404 Not Found'
end
end
def render_share
object_class = params[:model].classify.constantize
@object = object_class.find(params[:id])
module_app = ModuleApp.first(:conditions => {:key => params[:key]})
@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first
@orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}"
render 'shared/render_share', :layout => false
end
protected
+23 -13
View File
@@ -1,9 +1,6 @@
class PagesController < ApplicationController
include ApplicationHelper
before_filter :get_item, :only => [:index_from_link, :show_from_link]
# caches_page :index
def index
@@ -11,7 +8,7 @@ class PagesController < ApplicationController
if @item
impressionist(@item)
render_page
render_page
else
render :text => 'You need a home page'
end
@@ -19,14 +16,15 @@ class PagesController < ApplicationController
def show
#begin
@item = Item.first(:conditions => {:path => params[:page_name]})
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
if @item && @item.is_published #&& (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
impressionist(@item)
case @item.class.to_s
when 'Page'
render_page
when 'Page'
render_page unless save_from_no_lang_for_page
when 'Link'
redirect_to @item[:url]
redirect_to(@item[:url]) unless save_from_no_lang_for_page
end
else
render :file => "#{Rails.root}/public/404.html", :status => :not_found
@@ -43,15 +41,17 @@ class PagesController < ApplicationController
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
uri = URI::escape(url + options)
redirect_to uri
#uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&'))
redirect_to(uri)unless save_from_no_lang_for_page
end
def show_from_link
url = "/#{@item.path}?id=#{params[:id]}"
options = ''
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
redirect_to url + options
redirect_to(url + options) unless save_from_no_lang_for_page
end
def load_orbit_bar
@@ -66,12 +66,22 @@ class PagesController < ApplicationController
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
elsif !params[:category_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''})
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first
elsif !params[:tag_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => params[:tag_id]})
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
end
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => ''}) unless @item
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
end
protected
def save_from_no_lang_for_page
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
flash[:notice] = t('sys.module_page_lang_not_support')
redirect_to '/'
return true
else
return false
end
end
end
+14
View File
@@ -140,6 +140,7 @@ module ApplicationHelper
stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
end
stylesheets << "<link href='/assets/social-share-button.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css
stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
@@ -161,6 +162,8 @@ module ApplicationHelper
end
javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/event.js'></script>\n"
page.design.javascripts.each do |js|
# javascripts << "<script type='text/javascript' src='#{js.file.url}'></script>"
@@ -212,4 +215,15 @@ module ApplicationHelper
object.strftime("%Y-%m-%d")
end
def share_links(object, key)
js = ''
js << "<meta property='og:title' content='#{object.title}' />\n" rescue ''
js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue ''
js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue ''
content_tag :div, :class => 'fb' do
concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}")
# concat javascript_tag "$('head').append('#{j js}');"
end
end
end
+5 -2
View File
@@ -21,9 +21,12 @@ class Item
validates_associated :parent, :children
before_destroy :destroy_children
after_rearrange :rebuild_path, :if => "parent_id_changed?"
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
def enabled_for_lang(lang)
enabled_for.include?(lang)
end
def self.find_by_name(item_name)
Item.first(:conditions => { :name => item_name, :is_published => true })
end
+2 -2
View File
@@ -6,8 +6,8 @@ class Page < Item
field :content
field :app_frontend_url
field :theme_id, :type => BSON::ObjectId, :default => nil
field :category
field :tag
field :category, :default => ''
field :tag, :default => ''
field :view_count, :type => Integer, :default => 0
field :page_title, localize: true
-5
View File
@@ -31,12 +31,7 @@ class User
VALID_LOCALES.each do |loc|
locale = loc.to_sym
# debugger
# if(self.cache_dept.nil?)
# self.build_cache_dept key: "dept_cache_user_#{self.id}"
# end
dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',')
# self.cache_dept[locale] = sub_roles.collect{|sr| sr.title}.join(',')
end
self.cache_dept = dept_hash
self.save!
+1 -1
View File
@@ -59,4 +59,4 @@
</div>
<% end %>
</body>
</body>
@@ -16,7 +16,7 @@
$(document).ready(function(){
$('.site-map').masonry({
itemSelector: '.map-block',
columnWidth: 260,
columnWidth: 220,
isAnimated: true
});
});
+13 -2
View File
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html>
<html class="<%= I18n.locale.to_s %>">
<head>
<meta charset="utf-8">
<%= page_title(@item).html_safe %>
@@ -12,6 +12,17 @@
<%= page_javascripts(@item).html_safe %>
</head>
<body>
<%= yield %>
<%= yield %>
<% if !flash.empty? %>
<div class="modal alert alert-error hide" id="myModal">
<p type="button" class="close" data-dismiss="modal">×</p>
<% flash.each do |key, msg| %>
<%= "<strong>#{msg}</strong><br/>".html_safe%>
<% end%>
</div>
<script>
$('#myModal').modal('show')
</script>
<% end -%>
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html>
<head>
<meta property="og:title" content="<%= @object.title %>" />
<meta property="og:description" content="<%= strip_tags @object.subtitle %>" />
<meta property="og:image" content="<%= ('http://' + request.env['HTTP_HOST'] + @object.image.url) unless @object.image.blank? %>" />
<script type="text/javascript">
<!--
window.location = "<%= @orig_url %>"
//-->
</script>
</head>
<body>
</body>
</html>