Merge branch 'development' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into development

This commit is contained in:
Harry Bomrah 2014-04-11 19:48:43 +08:00
commit 3c8f4bcb53
22 changed files with 455 additions and 13 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@
/Gemfile.lock
app/views/frontend
/public/uploads/*

View File

@ -26,6 +26,12 @@ gem 'nokogiri'
#database
gem 'mongoid', github: "mongoid/mongoid"
#file uploading and carrierwave
gem "mini_magick", github: 'minimagick/minimagick'
gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs'
#built in modules
eval(File.read(File.dirname(__FILE__) + '/built_in_extensions.rb'))
#modules installed from the store

View File

@ -0,0 +1,100 @@
.sign-up{
margin: 150px auto 0;
position: relative;
/*text-align: center;*/
width: 600px;
}
.sign-up.facebook-form{
text-align: center;
}
.sign-up .form{
background-color: #FFFFFF;
box-shadow: 0 10px 20px #CBCBCB;
margin-bottom: 20px;
padding: 15px;
}
.sign-up .login-logo{
border-bottom: 1px solid #EDEDED;
margin: 0;
padding-bottom: 15px;
}
.sign-up .option-block{
margin-top: 15px;
}
.sign-up .or{
margin-top: 15px;
margin-bottom: 15px;
}
.sign-up .or span{
margin-left: 5px;
margin-right: 5px;
}
.sign-up .or .left{
margin-top: 10px;
margin-left: 60px;
width: 160px;
float: left;
}
.sign-up .or .right{
margin-top: 10px;
margin-right: 60px;
width: 160px;
float: right;
}
.sign-up .facebook:hover{
opacity: 0.8;
}
.sign-up .role-label{
display: inline;
margin-left: 3px;
margin-right: 10px;
}
.sign-up .notify{
font-size: 15px;
}
.notify.alert{
padding: 5px 10px 5px 3px;
}
.notify .icon-ok{
color: green;
margin-right: 3px;
margin-left: 3px;
}
.notify .icon-remove{
color: red;
margin-right: 3px;
margin-left: 3px;
}
.sign-up input[type=checkbox]{
margin-top: 0;
}
.sign-up .error{
border-color: #E9322D;
box-shadow: 0 0 6px #F8B987;
color: #B94A48;
}
.line{
border-bottom: 1px solid #EDEDED;
}
.links{
text-align: left;
}
.loader{
width:100px;
margin-left: 3px;
}

View File

@ -1,4 +1,5 @@
class UsersController < ApplicationController
layout "authentication"
def new
@user = User.new
end

11
app/models/category.rb Normal file
View File

@ -0,0 +1,11 @@
class Category
include Mongoid::Document
include Mongoid::Timestamps
field :disable, type: Boolean, default: false
field :title, localize: true
belongs_to :module_app
scope :enabled, ->{ where(:disable.in => [false, nil, ''])}
end

View File

@ -5,6 +5,8 @@ class ModuleApp
field :title, type: String
field :key, type: String
field :sidebar_order,type: Integer,default: 0
has_many :categories, dependent: :destroy, :autosave => true
def get_registration
OrbitApp::Module::Registration.find_by_key(key)

View File

@ -1,3 +1,4 @@
#this class handles user login and password. User has the attributes user name, email and password which he / she can choose
class User
include Mongoid::Document
include Mongoid::Timestamps

View File

@ -0,0 +1,54 @@
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
include CarrierWave::MiniMagick
include CarrierWave::MimeTypes
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fit => [200, 200]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>RulingOrbit | <%= current_site.title %></title>
<!--[if lt IE 9]>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= render 'shared/meta' %>
<%= render 'shared/google_font' %>
<%= stylesheet_link_tag "basic/global" %>
<%= stylesheet_link_tag "basic" %>
<%= stylesheet_link_tag "sign_up" %>
<%= render 'shared/ie_html5_fix' %>
<%= javascript_include_tag "basic" %>
<%= yield :page_specific_css %>
<%= yield :page_specific_javascript %>
<style>
</style>
<%= csrf_meta_tag %>
</head>
<body>
<%= render 'layouts/orbit_bar_backend' %>
<%= yield %>
</body>
</html>

View File

@ -1,2 +0,0 @@
<h1>Users#create</h1>
<p>Find me in app/views/users/create.html.erb</p>

View File

@ -1,3 +1,64 @@
<section id="main-wrap">
<div class="sign-up have-other-sign-in">
<% flash.each do |key, msg| %>
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %>
<% end %>
<div class="form">
<h3 class="login-logo">Sign up with Orbit</h3>
<div class="form-block option-block">
<div class="form-list clearfix">
<%= form_for @user, :html => {:class => 'content form-horizontal'} do |f| %>
<div class="control-group clear">
<label class="control-label" for="user_email"><%= t("users.user_id") %></label>
<div class="controls">
<%= f.text_field :user_name, :placeholder => t("users.user_id"), :id=>"user_id",:class=>"availibility" %>
<span class="loader hide"><img src="/assets/availability-check-loader.gif" /></span>
<span class="notify not-ok hide alert alert-danger"><i class="icon-remove"></i>Not Available</span>
<span class="notify ok alert hide alert-success"><i class="icon-ok"></i>Available</span>
</div>
</div>
<div class="control-group clear">
<label class="control-label" for="user_email"><%= t("user.email")%></label>
<div class="controls">
<%= f.email_field :email, :placeholder => t("users.email"), :id=>"user_email", :class=>"availibility" %>
<span class="loader hide"><img src="/assets/availability-check-loader.gif" /></span>
<span class="notify not-ok hide alert alert-danger"><i class="icon-remove"></i>Not Available</span>
<span class="notify ok hide alert alert-success"><i class="icon-ok"></i>Available</span>
</div>
</div>
<div class="control-group clear">
<label class="control-label" for="user_password">Password</label>
<div class="controls">
<%= f.password_field :password, :placeholder => t(:dots), :id=>"user_password" %>
</div>
</div>
<div class="control-group clear">
<label class="control-label" for="user_password">Confirm Password</label>
<div class="controls">
<%= f.password_field :password, :placeholder => t(:dots), :id=>"confirm_user_password" %>
</div>
</div>
<h3 class="line"></h3>
<div class="pull-right">
<%= f.submit t(:register), :class => 'btn btn-primary' %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</section>
<!--
<h1>Sign Up</h1>
<%= form_for @user do |f| %>
@ -30,4 +91,4 @@
<%= f.password_field :password_confirmation %>
</div>
<div class="actions"><%= f.submit %></div>
<% end %>
<% end %> -->

View File

@ -1 +1,2 @@
gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
gem 'ad_banner', git: 'git@gitlab.tp.rulingcom.com:saurabh/adbanner-test.git'

View File

@ -1,6 +1,6 @@
class KeywordConstraint
def matches?(request)
keywords = %w{admin member desktop user}
keywords = %w{admin member desktop user signup login}
keywords.all? { |k| !request.url.include?(k) }
end
end

View File

@ -44,4 +44,37 @@ en:
site:
system_preference: System Preference
settings: Site Settings
settings: Site Settings
users:
admin_change_password: You cannot change your own password here!
avatar: Profile Picture
change_passwd: Password
setting_privilege: Privilege
email: Email
first_name: First Name
last_name: Last Name
male: Male
name: Name
valid_old_password: Current password doesn't match confirmation
new_password: New password
new_password_note: At least 6 characters
new_password_confirmation: Confirm new password
female: Female
unknown: Information Not Available
office_tel: Office Tel No.
office_tel_note: Public available
sid: ID No.
sid_note: Faculty ID No. or Student ID No.
sex: Gender
user_id: User Account
user_id_note: Should be more than 3 characters and less than 50 characters
user_id_not_null: User account cannot be null
user_id_length: User account should be more than 3 characters
user_id_error: Someone already use that user account
user_basic_id_form: Account Info.
user_basic_data: Personal Profile
dots: ●●●●●●
register: Register
registered: Registered

View File

@ -18,6 +18,42 @@ zh_tw:
logout: 登出
dashboard_: 儀表版
desktop: 桌面
site:
system_preference: 系統狀態
site:
system_preference: 系統狀態
settings: 基本設定
users:
admin_change_password: 您不能在此處修改自己的密碼!
avatar: 大頭貼照
change_passwd: 變更密碼
setting_privilege: 權限設定
email: 電子郵件
first_name: 名字
male: 男性
name: 姓名
valid_old_password: 目前的密碼不符合確認值
new_password: 新密碼
new_password_note: 至少6個字元
new_password_confirmation: 確認新密碼
female: 女性
unknown: 未知
last_name: 姓氏
office_tel: 辦公室電話
office_tel_note: 將公開於網頁
sid: 編號
sid_note: 教職員工編號或學生學號
sex: 性別
user_id: 使用者帳號
user_id_note: 需介於3個字元至50個字元之間
user_id_not_null: 使用者帳號不能是空值
user_id_length: 使用者帳號至少需要3個字元
user_id_error: 該使用者帳號已被使用
user_basic_id_form: 帳號資料
user_basic_data: 個人資料
dots: ●●●●●●
register: 註冊
registered: 已註冊

View File

@ -1,7 +1,5 @@
OrbitStore::Application.routes.draw do
resources :users
get "/pages/edit_view" => "pages#edit_view"
get "/pages/preview" => "pages#preview"
@ -20,9 +18,11 @@ OrbitStore::Application.routes.draw do
# You can have the root of your site routed with "root"
root 'pages#home'
locales = Site.find_by(site_active: true).in_use_locales
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
resources :users
namespace :admin do
resources :dashboards
resources :items

View File

@ -1,5 +1,6 @@
require 'orbit_app/helper/renderer'
require 'orbit_app/helper/side_bar_renderer'
require "orbit_app/helper/context_link_renderer"
require 'orbit_app/register_module'
require 'orbit_app/module/registration'
require 'orbit_app/module/side_bar'

View File

@ -0,0 +1,12 @@
module ContextLinkRenderer
include Renderer
def render(request,params,current_module_app,belong_module_app)
@current_module_app = current_module_app
@belong_module_app = belong_module_app
@request = request
@params = params
content_tag :li, link_to(content_tag(:span, I18n.t(@label_i18n)), eval(@path)), :class => (active? ? 'active' : nil)
end
end

View File

@ -10,7 +10,9 @@ module SideBarRenderer
content_tag :div, class: "sub-nav-block #{@icon_class}" do
concat content_tag :h4, I18n.t(@head_label)
concat (content_tag :ul, class: "nav nav-list" do
@context_links.sort_by {| obj | obj.priority}.map{ |link|
link.render(request, params, @current_module_app, @belong_module_app)
}.join.html_safe
end)
end
end

View File

@ -43,6 +43,7 @@ module OrbitApp
def initialize(name = '',key,get_module_app,&block)
@head_label = name
@context_links = []
@head_link = ""
@app_base_path = ''
@active_for_controllers = []
@ -80,7 +81,23 @@ module OrbitApp
end
def active_for_controllers(var)
@active_for_controllers = var
@active_for_controllers = var
end
def context_link(*var)
var[1].merge!({:module_app_key=>@module_app_key,:get_module_app=>@get_module_app}) unless @module_app_key.nil?
new_context_link = ContextLink.new(*var)
@context_links << new_context_link
end
def finalize!
set_controllers_scope
# set_default_active_app_auth
current_priority = @context_links.count
@context_links.each do |t|
# t.set_module_app = @module_app
t.finalize!
end
end
protected
@ -89,13 +106,70 @@ module OrbitApp
var = @active_for_controllers
@active_for_controllers = []
var[:private].each do |controller|
@active_for_controllers << "admin/"+controller
@active_for_controllers << "#{locale}/admin/"+controller
end unless var[:private].nil?
var[:public].each do |controller|
@active_for_controllers << controller
end unless var[:public].nil?
end
end
class ContextLink
include ContextLinkRenderer
attr_reader :label_i18n,:available_for,:priority,:path,:active_for_action
def initialize(label_i18n="NoNameLink",options={})
@label_i18n = label_i18n
@priority = options[:priority] || 0
@path = options[:link_path] || ""
set_available_for_avoiding_sensitive_links(options[:available_for] )
@active_for_action = options[:active_for_action] || []
@module_app_key = options[:module_app_key]
@get_module_app = options[:get_module_app]
end
def set_available_for_avoiding_sensitive_links(available_for)
sensitive_list = {}
sensitive_list[:module_app] =/.*manager_auth_proc.*/
sensitive_list[:object_auth] = /.*object_auth.*/
sensitive_list.each do |index,regx|
if @path.match(regx)
@available_for = case index
when :module_app
[:admin]
when :object_auth
[:manager,:admin]
end #of case
end #of if
end #of each
@available_for = available_for if @available_for.nil?
end #of def
def get_module_app
@get_module_app.call
end
def active?
for_action = @active_for_action.blank? ? false : active_for_action?
for_action
end
def active_for_action?
@active_for_action[controller] == action
end
def finalize!
set_active_actions
end
protected
def set_active_actions
controller_action_hash = @active_for_action
@active_for_action = Hash[controller_action_hash.map{|controller,action| ["#{locale}/admin/"+controller.to_s,action.to_s]}]
end
end
end
end
end

View File

@ -0,0 +1,19 @@
module OrbitCategory
module Categorizable
def self.included(base)
base.field :category_id, type: BSON::ObjectId
end
def category
Category.find(self.category_id) rescue nil
end
def category=(cate)
self.category_id = Category.find(cate.id).id rescue nil
end
def disable?
Category.find(self.category_id).disable? rescue nil
end
end
end