Compare commits

..

3 Commits

Author SHA1 Message Date
rulingcom cf8f0ab26b Update for THU 2014-07-09 15:13:28 +08:00
rulingcom 5d37bce969 fix orbit_bar backend by Ray 2014-07-09 15:11:42 +08:00
rulingcom a8ac54a4d6 THU 2014-07-08 09:46:25 +08:00
18 changed files with 154 additions and 99 deletions

View File

@ -1,7 +1,7 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', "~> 3.2.16" gem 'rails', "~> 3.2.16"
gem "brakeman" # gem "brakeman"
gem 'mime-types' gem 'mime-types'
gem 'bson_ext' gem 'bson_ext'
@ -109,7 +109,7 @@ group :test, :development do
gem "spork" gem "spork"
gem "capybara" gem "capybara"
#gem 'rack-mini-profiler' #gem 'rack-mini-profiler'
gem "better_errors", "1.1.0" gem "better_errors"
# gem 'yard' # gem 'yard'
# gem "bluecloth" # gem "bluecloth"
end end

View File

@ -19,8 +19,8 @@ $(function () {
'use strict'; 'use strict';
// Initialize the jQuery File Upload widget: // Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({ $('#fileupload').fileupload({
maxFileSize: 50000000000, maxFileSize: 5000000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|pdf|doc|docx|ppt|pptx|xls|xlsx|csv|txt|zip|rar|tar|gz|odt|tiff|key|page)$/i, acceptFileTypes: /(\.|\/)(gif|jpe?g|png|pdf|doc|docx|ppt|pptx|xls|xlsx)$/i,
dropZone: $('#dropzone'), dropZone: $('#dropzone'),
headers:{ headers:{
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content") 'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")

View File

@ -28,8 +28,6 @@ CKEDITOR.editorConfig = function( config ) {
{ name: 'about' } { name: 'about' }
]; ];
config.allowedContent = true;
config.skin = 'moono'; config.skin = 'moono';
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>"; config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>";
@ -37,10 +35,6 @@ CKEDITOR.editorConfig = function( config ) {
//Font Config //Font Config
config.font_names = 'Arial;Comic Sans MS;Courier New;Georgia;Helvetica;Lucida Sans Unicode;Tahoma;Times New Roman;Trebuchet MS;Verdana;微軟正黑體'; config.font_names = 'Arial;Comic Sans MS;Courier New;Georgia;Helvetica;Lucida Sans Unicode;Tahoma;Times New Roman;Trebuchet MS;Verdana;微軟正黑體';
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
config.pasteFromWordPromptCleanup = true;
}; };
CKEDITOR.on('instanceReady',function(){ CKEDITOR.on('instanceReady',function(){

View File

@ -32,6 +32,7 @@ function preview() {
var resize = 500/bannerW var resize = 500/bannerW
bannerW = Math.floor(bannerW*resize); bannerW = Math.floor(bannerW*resize);
bannerH = Math.floor(bannerH*resize); bannerH = Math.floor(bannerH*resize);
console.log(bannerW)
}; };
if(bannerH > 300) { if(bannerH > 300) {
var resize = 300/bannerH var resize = 300/bannerH

View File

@ -7,12 +7,7 @@ $(function() {
for ( instance in CKEDITOR.instances ) for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement(); CKEDITOR.instances[instance].updateElement();
var formData; var formData = new FormData( $('form.previewable')[0] );
if(typeof(FormData) == "function"){
formData = new FormData( $('form.previewable')[0] );
}else{
formData = $('form.previewable').serialize()
}
$.ajax({ $.ajax({
type: "post", type: "post",

View File

@ -7,11 +7,19 @@
position: fixed; position: fixed;
margin-bottom: 0; margin-bottom: 0;
} }
#orbit-bar *,
#orbit-bar *:before,
#orbit-bar *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#orbit-bar .orbitlogo { #orbit-bar .orbitlogo {
width: 20px; width: 50px;
height: 20px; height: 40px;
padding: 0!important;
background-size: 70%; background-size: 70%;
display: inline-block; display: block;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-image: url(<%= asset_path 'orbit-logo.svg' %>); background-image: url(<%= asset_path 'orbit-logo.svg' %>);
@ -19,8 +27,23 @@
/* For Suck IE */ /* For Suck IE */
background-image: url(<%= asset_path 'orbit-logo.png' %>)\9; background-image: url(<%= asset_path 'orbit-logo.png' %>)\9;
} }
#orbit-bar .dropdown-menu li > a {
padding: 0 20px;
display: block;
height: 30px;
line-height: 30px;
}
#orbit-bar .dropdown-menu li i {
float: left;
display: inline-block;
margin-right: 5px;
line-height: 30px;
height: 100%;
}
#orbit-bar.navbar .nav > li > a { #orbit-bar.navbar .nav > li > a {
color: #EEE; color: #EEE;
padding: 0 15px;
display: block;
text-shadow: 0 -1px 0 #000; text-shadow: 0 -1px 0 #000;
border-right: 1px solid #363636; border-right: 1px solid #363636;
box-shadow: 1px 0px 0px rgba(0, 0, 0, 0.3); box-shadow: 1px 0px 0px rgba(0, 0, 0, 0.3);
@ -34,6 +57,11 @@
background-color: #0095CF; background-color: #0095CF;
text-shadow: 0 -1px 0 #014380; text-shadow: 0 -1px 0 #014380;
} }
#orbit-bar.navbar .nav > li > a > [class^="icon"],
#orbit-bar.navbar .nav > li > a > [class*=" icon"] {
line-height: 40px;
display: block;
}
#orbit-bar.navbar .nav li.dropdown.open > .dropdown-toggle, #orbit-bar.navbar .nav li.dropdown.open > .dropdown-toggle,
#orbit-bar.navbar .nav li.dropdown.active > .dropdown-toggle, #orbit-bar.navbar .nav li.dropdown.active > .dropdown-toggle,
#orbit-bar.navbar .nav li.dropdown.open.active > .dropdown-toggle { #orbit-bar.navbar .nav li.dropdown.open.active > .dropdown-toggle {
@ -66,6 +94,10 @@
right: auto; right: auto;
bottom: auto; bottom: auto;
} }
#orbit-bar .nav > li {
display: block;
line-height: 40px;
}
#orbit-bar .nav [class^="icon"], #orbit-bar .nav [class^="icon"],
#orbit-bar .nav [class*=" icon"] { #orbit-bar .nav [class*=" icon"] {
font-size: 1.5em; font-size: 1.5em;
@ -92,24 +124,53 @@
#orbit-bar .modal .input-prepend { #orbit-bar .modal .input-prepend {
margin-bottom: 15px; margin-bottom: 15px;
} }
#orbit-bar .modal .other-sign-in {
position: relative;
text-align: center;
margin-top: 20px;
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 1px solid #EDEDED;
}
#orbit-bar .modal .other-sign-in .btn {
padding: 4px 0;
display: block;
margin-bottom: 5px;
width: 100%;
}
#orbit-bar .modal .other-sign-in p {
position: absolute;
width: 30px;
height: 30px;
background-color: #FFF;
padding: 0 10px;
margin-bottom: 0;
margin-left: -25px;
line-height: 30px;
left: 50%;
bottom: -15px;
font-size: 1.3em;
color: #B1B1B1;
}
/*Search*/ /*Search*/
#orbit-bar #search { #orbit-bar #search {
margin-bottom: 0; margin-bottom: 0;
position: relative; position: relative;
padding: 8px 10px 0; padding: 0 10px;
border-right: 1px solid #363636; border-right: 1px solid #363636;
box-shadow: 1px 0px 0px rgba(0, 0, 0, 0.3); box-shadow: 1px 0px 0px rgba(0, 0, 0, 0.3);
} }
#orbit-bar #search form { #orbit-bar #search form {
margin-bottom: 8px; margin: 8px 0;
} }
#orbit-bar #search input[type="text"] { #orbit-bar #search input[type="text"] {
height: 14px; height: 23px;
line-height: 15px; line-height: 15px;
font-size: 13px; font-size: 13px;
padding-left: 25px; padding-left: 25px;
padding-right: 25px; padding-right: 25px;
display: block;
-webkit-border-radius: 12px; -webkit-border-radius: 12px;
-moz-border-radius: 12px; -moz-border-radius: 12px;
-o-border-radius: 12px; -o-border-radius: 12px;
@ -122,15 +183,17 @@
#orbit-bar #search .search-clear { #orbit-bar #search .search-clear {
position: absolute; position: absolute;
color: #A3A3A3; color: #A3A3A3;
top: 14px; top: 16px;
} }
#orbit-bar #search .icon-search { #orbit-bar #search .icon-search {
left: 20px; left: 15px;
top: 12px; top: 12px;
font-size: 1.2em; font-size: 1.2em;
width: 1.25em;
margin-top: 0;
} }
#orbit-bar #search .search-clear { #orbit-bar #search .search-clear {
right: 14px; right: 13px;
font-size: 1.3em; font-size: 1.3em;
} }
#orbit-bar #search .search-clear:hover { #orbit-bar #search .search-clear:hover {
@ -245,7 +308,7 @@
#orbit-bar #orbit-user .user-pic { #orbit-bar #orbit-user .user-pic {
width: 40px; width: 40px;
height: 40px; height: 40px;
margin: -13px 10px -10px -15px; margin: -12px 10px -10px -15px;
} }
/*Language & flag*/ /*Language & flag*/

View File

@ -4,7 +4,7 @@ class Admin::AdBannersController < OrbitBackendController
open_for_sub_manager open_for_sub_manager
def index def index
@ad_banners = get_sorted_and_filtered("ad_banner") @ad_banners = AdBanner.all.page(params[:page]).per(10)
end end
def show def show

View File

@ -11,7 +11,7 @@ class Admin::AdImagesController < Admin::AdBannersController
end end
def index def index
@ad_images = get_sorted_and_filtered("ad_image") @ad_images = AdImage.all.page(params[:page]).per(10)
end end
def edit def edit

View File

@ -11,7 +11,7 @@ class Admin::DashboardsController < OrbitBackendController
check_backend_openness check_backend_openness
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link') @module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link')
@recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link') @recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link')
@most_visited = get_most_visited('bulletin', 'page_context') @most_visited = get_most_visited('bulletin', 'page_context','page')
end end
def reload_all_content def reload_all_content
@ -22,7 +22,7 @@ class Admin::DashboardsController < OrbitBackendController
end end
def reload_most_visited def reload_most_visited
@most_visited = get_most_visited('bulletin', 'page_context') @most_visited = get_most_visited('bulletin', 'page_context','page')
respond_to do |format| respond_to do |format|
format.js { render 'reload', locals: {div_id: 'most_visited'} } format.js { render 'reload', locals: {div_id: 'most_visited'} }
end end

View File

@ -321,8 +321,6 @@ class ApplicationController < ActionController::Base
sorted_objects.flatten! sorted_objects.flatten!
sorted_objects.uniq! sorted_objects.uniq!
objects = get_with_nil(objects, option, sorted_objects) objects = get_with_nil(objects, option, sorted_objects)
elsif option.eql?('size')
objects = objects.order_by([ [:width, params[:direction]], [:height, params[:direction]] ])
end end
end end
end end
@ -363,12 +361,7 @@ class ApplicationController < ActionController::Base
end end
if pagination if pagination
filtered_objects = filter_authorized_objects(objects) Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
if filtered_objects.is_a?(Array)
Kaminari.paginate_array(filtered_objects).page(params[:page]).per(10)
else
filter_authorized_objects(objects).page(params[:page]).per(10)
end
else else
filter_authorized_objects(objects) filter_authorized_objects(objects)
end end

View File

@ -248,24 +248,15 @@ module ApplicationHelper
end end
def get_month_traffic def get_month_traffic
site = Site.first result = []
if site.month_traffic_cache.blank? or (site.month_traffic_cache['updated_at'] < (Time.now-1.day) rescue true) (0..30).each do |i|
site.month_traffic_cache = {}
site.month_traffic_cache['result'] = []
(1..30).each do |i|
visits = Impression.where( created_at: { visits = Impression.where( created_at: {
'$gte' => Time.now.beginning_of_day-i.days, '$gte' => Time.now.beginning_of_day-i.days,
'$lte' => Time.now.end_of_day-i.days} '$lte' => Time.now.end_of_day-i.days}
).count ).count
site.month_traffic_cache['result'].push([ Time.now.beginning_of_day-i.days, visits]) result.push([ Time.now.beginning_of_day-i.days, visits])
end end
[:name=> t(:visitors_count),:data=>result]
site.month_traffic_cache['updated_at'] = Time.now
site.save
end
[:name=> t(:visitors_count),:data=>site.month_traffic_cache['result']]
end end
# def get_today_traffic # def get_today_traffic

View File

@ -63,6 +63,7 @@ class MailCronMailer < ActionMailer::Base
end end
end end
@mail_cron_log = { @mail_cron_log = {
:mail_subject => @data.mail_subject, :mail_subject => @data.mail_subject,
:mail_to => group_mail, :mail_to => group_mail,
@ -73,16 +74,10 @@ class MailCronMailer < ActionMailer::Base
@mail_cron_log = MailCronLog.new(@mail_cron_log) @mail_cron_log = MailCronLog.new(@mail_cron_log)
@mail_cron_log.save @mail_cron_log.save
@mail_to_count = @data.mail_to.split(',') - group_mail.split(',')
if @mail_to_count.count == 0
@data.destroy @data.destroy
else
@data.mail_to = @mail_to_count.join(',')
@data.save
end
end end

View File

@ -38,7 +38,7 @@ class MailCron
if !email_user_id.blank? if !email_user_id.blank?
@user = User.find(email_user_id) rescue nil @user = User.find(email_user_id)
@group_mail << @user.email if !@user.blank? @group_mail << @user.email if !@user.blank?

View File

@ -51,8 +51,6 @@ class Site
field :store_confirmation, :type => Boolean, :default => false field :store_confirmation, :type => Boolean, :default => false
field :meta_viewport, :type => Boolean, :default => false field :meta_viewport, :type => Boolean, :default => false
field :month_traffic_cache
belongs_to :design belongs_to :design
has_many :site_metas, :autosave => true, :dependent => :destroy has_many :site_metas, :autosave => true, :dependent => :destroy
validate :in_use_locales, :minimum_enabled_locales validate :in_use_locales, :minimum_enabled_locales

View File

@ -1,32 +1,58 @@
<div style='position:relative'> <div>
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class="orbit-cycle-slideshow" data-cycle-timeout="<%= @ad_banner.timeout_millisecond %>" data-cycle-fx="<%= @ad_banner.ad_fx %>" data-cycle-pager=".banner_nav_<%= @ad_banner.title.dehumanize %>" data-cycle-pager-template="<li class='needed'><a href='#'></a></li>" data-cycle-pager-active-class="activeSlide" data-cycle-random='true' style="z-index: 0"> <div
id='slideshow-<%= @ad_banner.title.dehumanize %>'
class="orbit-cycle-slideshow"
data-cycle-timeout="<%= @ad_banner.timeout_millisecond %>"
data-cycle-fx="<%= @ad_banner.ad_fx %>"
data-cycle-pager-active-class="activeSlide"
data-cycle-random='true'
data-cycle-slides=".slide-img"
data-overlay=".adBanner-overlay .caption"
data-pager=".<%= @ad_banner.title.dehumanize %> .navigation"
data-cycle-pager-template="<li class='dot'></li>"
style="z-index: 0">
<% @ad_banner.ad_images.can_display.each do |ad_image| %> <% @ad_banner.ad_images.can_display.each do |ad_image| %>
<div
class="slide-img"
data-cycle-title="<%= ad_image.title %>"
data-cycle-desc="<%= ad_image.context %>"
data-overlay-template="<h2><%= ad_image.title %></h2><%= ad_image.context %>">
<% link = ad_image_link(ad_image) %> <% link = ad_image_link(ad_image) %>
<%= image_tag ad_image.file, alt: ad_image.title, title: ad_image.title, width: @ad_banner.width, height: @ad_banner.height, link_open: ad_image.link_open, link_url: link, style: "display:none; #{'cursor:pointer;' if link.present?}" %> <%= image_tag ad_image.file, alt: ad_image.title, title: ad_image.title, width: @ad_banner.width, height: @ad_banner.height, link_open: ad_image.link_open, link_url: link, style: "#{'cursor:pointer;' if link.present?}" %>
<%= %>
</div>
<% end %> <% end %>
</div> </div>
<ul class='clear banner_nav banner_nav_<%= @ad_banner.title.dehumanize %>'></ul> <div class="<%= @ad_banner.title.dehumanize %> adBanner-overlay">
<div class="caption"></div>
<ul class="navigation"></ul>
</div>
<!-- <ul class='clear banner_nav banner_nav_<%#= @ad_banner.title.dehumanize %>'></ul> -->
</div> </div>
<script> <script>
$(function(){ $(function(){
if($("#slideshow-<%= @ad_banner.title.dehumanize %> img").length > 1){ // if($("#slideshow-<%= @ad_banner.title.dehumanize %> img").length > 1){
var a = []; // var a = [];
<% @ad_banner.ad_images.can_display.each do |image| %> // <% @ad_banner.ad_images.can_display.each do |image| %>
a.push("<%= image.file.url %>"); // a.push("<%= image.file.url %>");
<% end %> // <% end %>
$.preload(a, 2, function(){ // $.preload(a, 2, function(){
// $('.orbit-cycle-slideshow').cycle();
// var lis = $("ul.banner_nav_<%= @ad_banner.title.dehumanize %> li");
// if( lis.length > a.length ){
// for( i = lis.length - 1; i > a.length - 1; i-- ){
// lis[i].remove();
// }
// }
// });
// }
// else{
// $("#slideshow-<%= @ad_banner.title.dehumanize %> img").show()
// }
$('.orbit-cycle-slideshow').cycle(); $('.orbit-cycle-slideshow').cycle();
var lis = $("ul.banner_nav_<%= @ad_banner.title.dehumanize %> li");
if( lis.length > a.length ){
for( i = lis.length - 1; i > a.length - 1; i-- ){
lis[i].remove();
}
}
});
}
else{
$("#slideshow-<%= @ad_banner.title.dehumanize %> img").show()
}
}); });
</script> </script>

View File

@ -56,7 +56,6 @@ module Orbit
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'modules', '*.{rb,yml}').to_s] config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'modules', '*.{rb,yml}').to_s]
config.i18n.enforce_available_locales = false
config.i18n.default_locale = :zh_tw config.i18n.default_locale = :zh_tw
# JavaScript files you want as :defaults (application.js is always included). # JavaScript files you want as :defaults (application.js is always included).

View File

@ -1,5 +1,5 @@
defaults: &defaults defaults: &defaults
host: localhost host: 127.0.0.1
# slaves: # slaves:
# - host: slave1.local # - host: slave1.local
port: 27017 port: 27017
@ -8,13 +8,13 @@ defaults: &defaults
development: development:
<<: *defaults <<: *defaults
database: orbit_site_new database: thu_orbit
test: test:
<<: *defaults <<: *defaults
database: orbit_site_new database: thu_orbit
# set these environment variables on your prod server # set these environment variables on your prod server
production: production:
@ -24,4 +24,4 @@ production:
# password: <%= ENV['MONGOID_PASSWORD'] %> # password: <%= ENV['MONGOID_PASSWORD'] %>
# database: <%= ENV['MONGOID_DATABASE'] %> # database: <%= ENV['MONGOID_DATABASE'] %>
<<: *defaults <<: *defaults
database: orbit_site_new database: thu_orbit

View File

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
require 'fileutils' require 'fileutils'
require 'shell' # require 'shell'
require 'open-uri' require 'open-uri'
require 'net/http/post/multipart' require 'net/http/post/multipart'