Added Items,Pages, Some UI for backend

This commit is contained in:
Saurabh Bhatia 2014-04-08 18:46:27 +08:00
parent 47da9ac309
commit 0ff748acc4
54 changed files with 444 additions and 48 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="38px" height="38px" viewBox="0 0 38 38" enable-background="new 0 0 38 38" xml:space="preserve">
<path fill="#FFFFFF" d="M20.286,1C11.055,1,3.571,8.483,3.571,17.714c0,1.519,0.204,2.991,0.584,4.39
C2.233,23.636,1,25.995,1,28.643C1,33.258,4.742,37,9.357,37c2.648,0,5.007-1.232,6.539-3.155c1.399,0.38,2.871,0.585,4.39,0.585
C29.518,34.43,37,26.945,37,17.714C37,8.483,29.518,1,20.286,1z M9.357,33.143c-2.485,0-4.5-2.015-4.5-4.5
c0-2.484,2.015-4.5,4.5-4.5s4.5,2.016,4.5,4.5C13.857,31.128,11.842,33.143,9.357,33.143z M20.27,29.287
c-0.881,0-1.739-0.102-2.563-0.289c0.005-0.118,0.009-0.236,0.009-0.355c0-4.615-3.742-8.356-8.357-8.356
c-0.123,0-0.245,0.004-0.367,0.009c-0.189-0.83-0.292-1.692-0.292-2.58c0-6.391,5.181-11.571,11.572-11.571
c6.391,0,11.57,5.18,11.57,11.571C31.841,24.105,26.66,29.287,20.27,29.287z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the admin/items controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -22,10 +22,10 @@
*/
@font-face {
font-family: 'FontAwesome';
src:url(<%= asset_path'fontawesome-webfont.eot' %>);
src:url(<%= asset_path'fontawesome-webfont.eot?#iefix' %>) format('embedded-opentype'),
url(<%= asset_path'fontawesome-webfont.woff' %>) format('woff'),
url(<%= asset_path'fontawesome-webfont.ttf' %>) format('truetype');
src:url('<%= asset_path'fontawesome-webfont.eot' %>');
src:url('<%= asset_path'fontawesome-webfont.eot?#iefix' %>') format('embedded-opentype'),
url('<%= asset_path'fontawesome-webfont.woff' %>') format('woff'),
url('<%= asset_path'fontawesome-webfont.ttf' %>') format('truetype');
font-weight: normal;
font-style: normal;
}

View File

@ -7,10 +7,10 @@
}
@font-face {
font-family: 'entypo';
src:url(<%= asset_path 'entypo.eot' %>);
src:url(<%= asset_path 'entypo.eot?#iefix' %>) format('embedded-opentype'),
url(<%= asset_path 'entypo.svg#entypo' %>) format('svg'),
url(<%= asset_path 'entypo.woff' %>) format('woff'),
src:url('<%= asset_path 'entypo.eot' %>');
src:url('<%= asset_path 'entypo.eot?#iefix' %>') format('embedded-opentype'),
url('<%= asset_path 'entypo.svg#entypo' %>') format('svg'),
url('<%= asset_path 'entypo.woff' %>') format('woff'),
url('<%= asset_path 'entypo.ttf' %>');
font-weight: normal;
font-style: normal;

View File

@ -14,10 +14,10 @@
display: inline-block;
background-position: center;
background-repeat: no-repeat;
background-image: url(<%= asset_path 'orbit-logo.svg' %>);
background-image: url('<%= asset_path 'orbit-logo.svg' %>');
/* For Suck IE */
background-image: url(<%= asset_path 'orbit-logo.png' %>)\9;
background-image: url('<%= asset_path 'orbit-logo.png' %>');
}
#orbit-bar.navbar .nav > li > a {
color: #EEE;
@ -238,7 +238,7 @@
/*Language & flag*/
#orbit-bar #orbit-language [class^="flag-"],
#orbit-bar #orbit-language [class*=" flag-"] {
background-image: url(<%= asset_path 'flag.png' %>);
background-image: url('<%= asset_path 'flag.png' %>');
background-repeat: no-repeat;
background-color: transparent;
display: inline-block;
@ -288,7 +288,7 @@
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (max--moz-device-pixel-ratio: 2) {
#orbit-bar #orbit-language [class^="flag-"],
#orbit-bar #orbit-language [class*=" flag-"] {
background-image: url(<%= asset_path 'flag@2x.png' %>);
background-image: url('<%= asset_path 'flag@2x.png' %>');
background-size: 96px 192px;
}
}

View File

@ -0,0 +1,3 @@
// Place all the styles related to the designs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the module_store controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the sites controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,8 @@
class Admin::ItemsController < ApplicationController
include OrbitHelper
layout "structure"
def index
@items = Page.all
end
end

View File

@ -3,6 +3,8 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :set_locale
helper_method :current_site
def default_url_options(options={})
{ locale: I18n.locale }
end
@ -19,4 +21,7 @@ class ApplicationController < ActionController::Base
@key = Template::KEY
end
def current_site
@current_site = Site.find_by(site_active: true)
end
end

View File

@ -0,0 +1,4 @@
class DesignsController < ApplicationController
def index
end
end

View File

@ -0,0 +1,4 @@
class ModuleStoreController < ApplicationController
def index
end
end

View File

@ -0,0 +1,29 @@
class SitesController < ApplicationController
def mail_setting
end
def site_info
end
def responsive_setting
end
def search_engine
end
def sitemap
end
def system_info
end
def preference
end
def update_manager
end
def update_orbit
end
end

View File

@ -0,0 +1,2 @@
module Admin::ItemsHelper
end

View File

@ -132,4 +132,7 @@ module ApplicationHelper
data
end
def active_for_action(controller_name, action_name)
((controller.controller_name.eql?(controller_name) || request.fullpath.eql?(controller_name)) && controller.action_name.eql?(action_name)) ? 'active' : nil
end
end

View File

@ -0,0 +1,2 @@
module DesignsHelper
end

View File

@ -0,0 +1,2 @@
module ModuleStoreHelper
end

View File

@ -16,6 +16,10 @@ module OrbitHelper
end
end
def page_url(url)
"#{request.host_with_port}/#{locale}#{url}"
end
def self.set_site_locale(locale)
@site_locale = locale
end

View File

@ -0,0 +1,2 @@
module SitesHelper
end

21
app/models/site.rb Normal file
View File

@ -0,0 +1,21 @@
class Site
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
field :school, type: String
field :department, type: String
field :address, type: String
field :footer, type: String
field :sub_menu, type: String
field :terms_of_use, type: String
field :google_analytics, type: String
field :in_use_locales, :type => Array
field :valid_locales, :type => Array
field :site_active, :type => Boolean
def to_param
I18n.locale = :en
title.parameterize
end
end

View File

@ -0,0 +1,3 @@
<% @items.each do |i|%>
<%= link_to i.name, page_url(i.url) %>
<% end %>

View File

@ -0,0 +1,2 @@
<h1>Designs#index</h1>
<p>Find me in app/views/designs/index.html.erb</p>

View File

@ -0,0 +1,29 @@
<ul class="nav" role="navigation">
<!-- menu -->
<li id="orbit-start" class="dropdown">
<a class="orbitlogo" href="<%= admin_dashboards_path %>" role="button" class="dropdown-toggle" data-toggle="dropdown" title="<%= t('dashboard_')%>"></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-start">
<li><%= link_to content_tag(:i, nil, :class => 'icons-gauge') + ' ' + t(:dashboard_), admin_dashboards_path, tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-users') + ' ' + t(:member_), tabindex: '-1' %></li>
<% if (is_admin? rescue false) %>
<li class="divider"></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-cog') + ' ' + t('site.settings'), admin_items_path, tabindex: '-1' %></li>
<% end %>
</ul>
</li>
<!-- home -->
<li id="orbit-home">
<a href="<%= root_path %>" role="button" title="<%= t('homepage')%>">
<i class="icons-house"></i> <span class="hide"><%= t(:homepage) %></span>
</a>
</li>
<!-- Desktop -->
<li id="orbit-desktop">
<a href="" role="button" title="<%= t('desktop')%>">
<i class="icons-screen"></i> <span class="hide"><%= t(:desktop) %></span>
</a>
</li>
</ul>

View File

@ -0,0 +1,6 @@
<header id="orbit-bar" class="orbit-bar navbar">
<div class="navbar-inner">
<%= render "layouts/left_menu" %>
<%= render "layouts/right_menu" %>
</div>
</header>

View File

@ -0,0 +1,41 @@
<ul class="nav pull-right" role="navigation">
<!-- search -->
<li id="search" class="searchClear">
<form id="search_form" method="get" action="/site_search">
<%= text_field_tag 'q','', {:class => "search-query input-medium", :placeholder => "Search", 'x-webkit-speech' => ''} %>
</form>
</li>
<!-- Language -->
<li id="orbit-language" class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown" title="<%= t('site.language')%>"><%= t(:_locale, :locale => I18n.locale) %></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-language">
</ul>
</li>
<!-- user -->
<li id="orbit-user" class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
<%= image_tag 'menber-pic.png', class: "user-pic" %>
<span><%= %></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-user">
<li><%= link_to content_tag(:i, nil, class: 'icons-tools') + ' ' + t("users.change_passwd"), tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-vcard') + ' ' + t("users.user_basic_data"), tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-screen') + ' ' + t(:desktop), tabindex: '-1' %></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-logout') + ' ' + t(:logout), tabindex: '-1' %></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#"><i class="icons-lifebuoy"></i> <%= t(:help) %></a></li>
</ul>
</li>
<% else %>
<!-- login -->
<li id="orbit-login">
<a href="#login" role="button" data-toggle="modal" title="<%= t('login')%>">
<i class="icons-login"></i> <span class="hide"><%= t(:login) %></span>
</a>
</li>
</ul>

View File

@ -1,17 +1,6 @@
<div id="sidebar-menu">
<div class="scroller">
<ul class="sidebar-nav">
<%= Rails.logger.info"@@@@@@@@@@@@@@@"+OrbitApp::Module::SideBarRegistration.all.inspect %>
<% OrbitApp::Module::SideBarRegistration.all.sort{|x,y| x.get_module_app_key <=> y.get_module_app_key}.each do |t| %>
<%= t.render_head(request, params, @module_app) %>
<% end %>
</ul>
</div>
<div class="sub-nav-arrow"></div>
</div>
<div class="sub-nav-block-list">
<% OrbitApp::Module::SideBarRegistration.all.sort{|x,y| x.get_module_app_key <=> y.get_module_app_key}.each do |t| %>
<%= t.render(request, params, @module_app) %>
<% end %>
</div>
<nav id="sidebar">
<h2 class="position">
<%= link_to content_tag(:i, nil, :class => (local_assigns.has_key? :icon) ? icon : 'icons-gauge'), (local_assigns.has_key? :link_url) ? link_url : admin_dashboards_path %>
</h2>
<%= render ((local_assigns.has_key? :side_bar_content) ? side_bar_content : 'layouts/side_bar_content') %>
</nav>

View File

@ -0,0 +1,16 @@
<div id="sidebar-menu">
<div class="scroller">
<ul class="sidebar-nav">
<% OrbitApp::Module::SideBarRegistration.all.sort{|x,y| x.get_module_app_key <=> y.get_module_app_key}.each do |t| %>
<%= t.render_head(request, params, @module_app) %>
<% end %>
</ul>
</div>
<div class="sub-nav-arrow"></div>
</div>
<div class="sub-nav-block-list">
<% OrbitApp::Module::SideBarRegistration.all.sort{|x,y| x.get_module_app_key <=> y.get_module_app_key}.each do |t| %>
<%= t.render(request, params, @module_app) %>
<% end %>
</div>

View File

@ -8,14 +8,9 @@
</head>
<body>
<body id="dashboards">
<nav id="sidebar">
<h2 class="position">
<%= link_to content_tag(:i, nil, :class => (local_assigns.has_key? :icon) ? icon : 'icons-gauge'), (local_assigns.has_key? :link_url) ? link_url : admin_dashboards_path %>
</h2>
<%= render ((local_assigns.has_key? :side_bar) ? side_bar : 'layouts/side_bar') %>
</nav>
<%= yield %>
<%= render 'layouts/orbit_bar_backend' %>
<%= render 'layouts/side_bar' %>
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<html>
<head>
<title><%= current_site.title || t('site.settings') %></title>
<%= render 'shared/meta' %>
<%= render 'shared/google_font' %>
<%= stylesheet_link_tag "structure" %>
<%= render 'shared/ie_html5_fix' %>
<%= csrf_meta_tag %>
</head>
<body id="sideset">
<%= render 'layouts/orbit_bar_backend' %>
<%= render 'shared/side_bar' %>
<section id="main-wrap">
<div class="wrap-inner">
<%= yield %>
</div>
</section>
</body>
</html>

View File

@ -0,0 +1,2 @@
<h1>ModuleStore#index</h1>
<p>Find me in app/views/module_store/index.html.erb</p>

View File

@ -0,0 +1 @@
<link href='http://fonts.googleapis.com/css?family=Quicksand|Varela+Round|Chivo|Raleway|Playfair+Display+SC|Archivo+Black&subset=latin,latin-ext' rel='stylesheet' type='text/css'>

View File

@ -0,0 +1,4 @@
<!-- IE HTML5 Fix -->
<!--[if IE]>
<script src="<%= asset_path 'html5.js' %>"></script>
<![endif]-->

View File

@ -0,0 +1,5 @@
<link rel="shortcut icon" href="<%= asset_path 'favicon.ico' %>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

View File

@ -0,0 +1,29 @@
<nav id="sidebar">
<h2 class="position"><a href="#"><i class="icons-cog"></i></a></h2>
<div id="sidebar-menu">
<div class="scroller">
<ul class="sidebar-nav no-sub-nav">
<li title="<%= t('site_structure') %>"><%= link_to admin_items_path do %><span><i class="icons-flow-tree"></i></span><%end%></li>
<li title="<%= t('site_map') %>"><%= link_to admin_site_sitemap_path(current_site), :class => active_for_action('sites', 'sitemap') do %><span><i class="icons-directions"></i></span><%end%></li>
<li title="<%= t('modules') %>"><%= link_to admin_module_store_path, :class => active_for_action('module_store', 'index') do %><span><i class="icons-layout"></i></span><%end%></li>
<li title="<%= t('templates') %>"><%= link_to admin_designs_path, :class => active_for_action('template_store', 'index') do %><span><i class="icons-brush"></i></span><%end%></li>
<li title="<%= t('site_info') %>"><%= link_to admin_site_site_info_path(current_site), :class => active_for_action('sites', 'site_info') do %><span><i class="icons-browser"></i></span><%end%></li>
<li title="<%= t('mobile_settings') %>"><%= link_to admin_site_responsive_setting_path(current_site), :class => active_for_action('sites', 'responsive_setting') do %><span><i class="icons-mobile"></i></span><%end%></li>
<li title="<%= t('search_engine') %>"><%= link_to admin_site_search_engine_path(current_site), :class => active_for_action('sites', 'search_engine') do %><span><i class="icons-search"></i></span><%end%></li>
<li title="<%= t('preference') %>"><%= link_to admin_site_preference_path(current_site), :class => active_for_action('sites', 'preference') do %><span><i class="icons-cog"></i></span><%end%></li>
<li title="<%= t('update_manager') %>"><%= link_to admin_site_update_manager_path(current_site), :class => active_for_action('sites', 'update_manager') do %><span><i class="icon-refresh"></i></span><%end%></li>
<li title="<%= t("site.system_preference") %>"><%= link_to admin_site_system_info_path(current_site), :class => active_for_action('sites', 'system_info') do %><span><i class="icons-info-2"></i></span><%end%></li>
</ul>
</div>
<div class="sub-nav-arrow"></div>
</div>
</nav>

View File

@ -20,4 +20,26 @@
# available at http://guides.rubyonrails.org/i18n.html.
en:
_locale: English
more: "More"
site_: Site
site_info: Site Info
site_map: Site Map
sitemap: Sitemap
site_name: Site Name
site_structure: Structure
modules: Modules
mobile_settings: Mobile Settings
search_engine: Search Engine
templates: Templates
preference: Preferences
update_manager: Update Manager
locale: Locale
login: Login
logout: Logout
language: Language
dashboard_: Dashboard
desktop: Desktop
homepage: Homepage
site:
system_preference: System Preference

View File

@ -1,2 +1,23 @@
zh_tw:
more: "更多"
more: "更多"
site_: 網站
site_info: 基本資訊
site_map: 網站地圖
site_structure: 網站架構
sitemap: 網站地圖
site_name: 網站名稱
mobile_settings: 行動設定
modules: 網站模組
search_engine: 搜尋引擎
templates: 網站模版
preference: 系統偏好
update_manager: 更新管理員
homepage: 首頁
locale: 位置
login: 登入
logout: 登出
dashboard_: 儀表版
desktop: 桌面
site:
system_preference: 系統狀態

View File

@ -17,9 +17,28 @@ OrbitStore::Application.routes.draw do
# You can have the root of your site routed with "root"
root 'pages#home'
scope "(:locale)", locale: /en|zh_tw/ do
locales = Site.find_by(site_active: true).in_use_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
resources :dashboards
resources :items
resources :sites do
get 'mail_setting'
get 'site_info'
get 'responsive_setting'
get 'search_engine'
get 'sitemap'
get 'system_info'
get 'preference'
get 'update_manager'
get 'update_orbit'
end
resources :designs
get 'module_store' => 'module_store#index'
end
get ':page(/:page)(/:page)(/:page)', to: 'pages#show', constraints: KeywordConstraint.new
resources :pages

View File

@ -49,7 +49,6 @@ module OrbitApp
@get_module_app = get_module_app
@sidebar_order = 0
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
finalize!
SideBarRegistration.add(self)
SideBarRegistration.all_get_ordered!
end
@ -78,14 +77,6 @@ module OrbitApp
def head_link_path(var)
@head_link = var
end
def finalize!
set_controllers_scope
current_priority = @context_links.count
@context_links.each do |t|
t.finalize!
end
end
end
end
end

View File

@ -0,0 +1,9 @@
require 'test_helper'
class Admin::ItemsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,9 @@
require 'test_helper'
class DesignsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,9 @@
require 'test_helper'
class ModuleStoreControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class SitesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

21
test/fixtures/sites.yml vendored Normal file
View File

@ -0,0 +1,21 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
title: MyString
school: MyString
department: MyString
address: MyString
footer: MyString
sub_menu: MyString
terms_of_use: MyString
google_analytics: MyString
two:
title: MyString
school: MyString
department: MyString
address: MyString
footer: MyString
sub_menu: MyString
terms_of_use: MyString
google_analytics: MyString

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Admin::ItemsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class DesignsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class ModuleStoreHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class SitesHelperTest < ActionView::TestCase
end

7
test/models/site_test.rb Normal file
View File

@ -0,0 +1,7 @@
require 'test_helper'
class SiteTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end