Merge branch 'dashboard' of https://github.com/Rulingcom/orbit into dashboard

Conflicts:
	vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
	vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
	vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb
This commit is contained in:
unknown 2012-04-05 15:16:33 +08:00
commit 9382ef6ae8
164 changed files with 1088 additions and 2321 deletions

View File

@ -6,7 +6,7 @@ gem "brakeman"
gem 'bson_ext'
gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
gem 'devise'
gem 'devise', '1.5.3'
gem 'exception_notification' # Send error trace
gem 'execjs'
gem 'jquery-rails'
@ -16,6 +16,7 @@ gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
gem 'mini_magick'
gem 'mongoid'
gem "mongo_session_store-rails3"
gem 'nokogiri'
gem 'radius'
gem 'rake'
gem 'ruby-debug19'
@ -23,7 +24,7 @@ gem 'rubyzip'
gem 'sinatra'
gem 'sprockets'
gem 'tinymce-rails'
#gem 'therubyracer'
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
# Gems used only for assets and not required
# in production environments by default.

View File

@ -40,6 +40,7 @@ GEM
multi_json (~> 1.0)
archive-tar-minitar (0.5.2)
arel (2.2.3)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
brakeman (1.5.1)
activesupport
@ -71,11 +72,10 @@ GEM
database_cleaner (0.7.1)
delorean (1.2.0)
chronic
devise (2.0.4)
devise (1.5.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1.1)
warden (~> 1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
exception_notification (2.5.2)
@ -116,6 +116,8 @@ GEM
mongo (~> 1.3)
tzinfo (~> 0.3.22)
multi_json (1.1.0)
nokogiri (1.5.2)
nokogiri (1.5.2-x86-mingw32)
orm_adapter (0.0.6)
pdf-writer (1.1.8)
color (>= 1.4.0)
@ -199,6 +201,7 @@ GEM
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
spork (0.9.0)
spork (0.9.0-x86-mingw32)
win32-process
sprockets (2.0.3)
@ -232,6 +235,7 @@ GEM
windows-api (>= 0.3.0)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
@ -242,7 +246,7 @@ DEPENDENCIES
coffee-rails
database_cleaner
delorean
devise
devise (= 1.5.3)
exception_notification
execjs
factory_girl_rails
@ -251,6 +255,7 @@ DEPENDENCIES
mini_magick
mongo_session_store-rails3
mongoid
nokogiri
radius
rails (>= 3.1.0, < 3.2.0)
rake

View File

@ -48,7 +48,7 @@
}
.select-role {
display:none;
overflow:hidden;
padding: 10px 0 0;
}
.file-upload {
position:relative;

View File

@ -1251,6 +1251,7 @@
, complete = function () {
if (startEvent == 'show') that.reset()
that.$element.trigger(completeEvent)
mainTablePosition();
}
this.$element

View File

@ -9,6 +9,12 @@ $('.bulletin_files_block a.delete').live('click', function(){
$('.action a.remove_existing_record').live('click', function(){
$(this).next('.should_destroy').attr('value', 1);
//$("#bulletin_" + $(this).prev().attr('value')).hide();
$("tr#bulletin_" + $(this).prev().attr('value')).hide();
});
$('.quick_edit_cancel').live('click', function(){
tr = $(this).attr('rel');
$('#' + tr).hide();
$("tr#bulletin_file_" + $(this).prev().attr('value')).hide();
$("tr#bulletin_link_" + $(this).prev().attr('value')).hide();
});

View File

@ -0,0 +1,3 @@
/*! HTML5 Shiv pre3.5 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
Uncompressed source: https://github.com/aFarkas/html5shiv */
(function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){l.shivMethods||c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return b[a]=c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}function p(a){var b,c=a.getElementsByTagName("*"),d=c.length,e=RegExp("^(?:"+i().join("|")+")$","i"),f=[];while(d--)b=c[d],e.test(b.nodeName)&&f.push(b.applyElement(q(b)));return f}function q(a){var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(n+":"+a.nodeName);while(d--)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function r(a){var b,c=a.split("{"),d=c.length,e=RegExp("(^|[\\s,>+~])("+i().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),f="$1"+n+"\\:$2";while(d--)b=c[d]=c[d].split("}"),b[b.length-1]=b[b.length-1].replace(e,f),c[d]=b.join("}");return c.join("{")}function s(a){var b=a.length;while(b--)a[b].removeNode()}function t(a){var b,c,d=a.namespaces,e=a.parentWindow;return!o||a.printShived?a:(typeof d[n]=="undefined"&&d.add(n),e.attachEvent("onbeforeprint",function(){var d,e,f,g=a.styleSheets,i=[],j=g.length,k=Array(j);while(j--)k[j]=g[j];while(f=k.pop())if(!f.disabled&&m.test(f.media)){for(d=f.imports,j=0,e=d.length;j<e;j++)k.push(d[j]);try{i.push(f.cssText)}catch(l){}}i=r(i.reverse().join("")),c=p(a),b=h(a,i)}),e.attachEvent("onafterprint",function(){s(c),b.removeNode(!0)}),a.printShived=!0,a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea|object|iframe)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g;(function(){var c=b.createElement("a");c.innerHTML="<xyz></xyz>",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b);var m=/^$|\b(?:all|print)\b/,n="html5shiv",o=!g&&function(){var c=b.documentElement;return typeof b.namespaces!="undefined"&&typeof b.parentWindow!="undefined"&&typeof c.applyElement!="undefined"&&typeof c.removeNode!="undefined"&&typeof a.attachEvent!="undefined"}();l.type+=" print",l.shivPrint=t,t(b)})(this,document)

View File

@ -11,3 +11,4 @@
//= require jquery.tinyscrollbar.min
//= require orbit-1.0
//= require tinymce-jquery
//= require tinymce_orbit

View File

@ -40,16 +40,29 @@ $(document).ready(function(){
}
});
$(document).on('click', '.toggle-tr-edit', function() {
$(this).parents('tr').next('.qe-block').removeClass('hide');
$(this).parents('tr').next('.qe-block').find('.qe-edit-div').addClass('hide');
$(this).parents('tr').next('.qe-block').find('#qe-' + $(this).attr('rel')).toggleClass('hide');
});
$(document).on('click', '.sort-header > .sort', function() {
$.getScript($(this).attr('rel'));
});
var $role = $('.select-role');
var method =$('.privacy:eq(1)').attr('checked');
if(method == 'checked'){
$role.slideDown(0);
}
$('.privacy').each(function($i) {
$(this).click(function() {
switch ($i) {
case 0:
$role.slideUp(300);
break;
case 1:
$role.slideDown(300);
break;
}
});
});
/*tinyscrollbar&windows-Size*/
resize();
var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2;
@ -86,6 +99,10 @@ function mainTablePosition() {
var $height = $('#main-wrap > .subnav').height()
var $table = $('#main-wrap > .table')
//alert ($table.height())
$height = $height-17;
if($height<0){
$height = 0;
}
$table.stop().animate({marginTop:$height},500)
//$table.css({marginTop : $height})
}

View File

@ -0,0 +1,26 @@
$(function() {
$('.tinymce_textarea').tinymce({
theme: 'advanced',
plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Skin options
skin : "o2k7",
skin_variant : "silver",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js"
});
});

View File

@ -98,7 +98,7 @@ h1, h2, h3, h4, h5, h6 {
border-radius: 0 0 4px 4px;
}
table .span1-2 {
width: 94px;
min-width: 85px;
float: none;
margin-left: 0;
}

View File

@ -9,9 +9,9 @@
.main-list {
margin-bottom: 0;
}
.main-list thead th {
background-color: rgba(0,0,0,0.05);
border-right: 1px solid #ddd;
.main-wrap>.main-list thead th {
background-color: transparent;
border-right: medium none;
}
.main-list thead th:last-child {
border-right: none;
@ -29,19 +29,22 @@
}
.main-list tbody .quick-edit {
position:relative;
height:40px;
height:20px;
}
.main-list tbody .quick-edit .nav {
/*left: -55px;*/
position: absolute;
/*top: -3px;*/
width: 350px;
left: -8px;
}
.main-list td {
/*height:80px;*/
background-color: #FFFFFF;
border-bottom: 1px solid #DDDDDD;
border-top: medium none;
}
.main-list .nav {
margin-top: 15px;
margin-top: 0;
margin-bottom: 3px;
}
.main-list tr.with_action:hover .hide {
@ -53,7 +56,7 @@
}
.main-list .label-td {
background-color: rgba(255, 255, 255, 1);
height: 60px;
height: 40px;
overflow: hidden;
position: absolute;
width: 100%;
@ -75,6 +78,15 @@
-moz-border-radius: 3px;
z-index: 5;
}
.table-label {
background-color: #F2F2F2;
position: relative;
}
.table-label .main-list thead th {
background-color: #F2F2F2;
border-right: 1px solid #DDDDDD;
border-top: 1px solid #DDDDDD !important;
}
.route-group .route {
padding: 0;
}
@ -109,6 +121,9 @@ legend {
border-radius: 0;
border-left: none;
border-right: none;
position: fixed;
top: 30px;
z-index: 50;
}
.subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover {
-moz-border-radius: 0;

View File

@ -2,7 +2,6 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
-webkit-text-size-adjust:none;
}
html, body{
background: url(<%= asset_path 'background.jpg' %>) repeat left top;
height: 100%;
}
/*自定*/

View File

@ -350,8 +350,6 @@
border-top: none;
}
#post-body .editor {
background-color: #333333;
height: 20px;
margin: 8px 0;
width: 100%;
}

View File

@ -59,7 +59,7 @@
}
.select-role {
display:none;
overflow:hidden;
padding: 10px 0;
}
.file-upload {
position:relative;

View File

@ -1,8 +1,7 @@
class Admin::ObjectAuthsController < ApplicationController
include OrbitCoreLib::PermissionUnility
layout "admin"
before_filter :authenticate_user!
before_filter :check_if_user_can_do_object_auth
before_filter :force_order
# before_filter :is_admin? ,:only => :index
@ -84,6 +83,12 @@ class Admin::ObjectAuthsController < ApplicationController
end
private
def force_order
authenticate_user!
check_if_user_can_do_object_auth
end
def check_if_user_can_do_object_auth
unless check_permission(:manager)
render :nothing => true, :status => 403

View File

@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base
# Render the page
def render_page(id = nil)
if @item
render :text => parse_page(@item, id)
render :text => process_page(@item, id), :layout => 'page_layout'
else
render :text => '404 Not Found'
end

View File

@ -1,12 +1,12 @@
class OrbitBackendController< ApplicationController
before_filter :authenticate_user!
before_filter :force_order,:except => [:public]
before_filter :setup_vars
# before_filter {|c| c.front_end_available(@app_title)}
before_filter :check_user_can_use,:except => [:public]
# before_filter :check_user_can_use
include OrbitCoreLib::PermissionUnility
include AdminHelper
layout 'admin'
layout 'new_admin'
def setup_vars
@app_title = request.fullpath.split('/')[2]
@ -15,6 +15,11 @@ class OrbitBackendController< ApplicationController
private
def force_order
authenticate_user!
check_user_can_use
end
def check_user_can_use
unless check_permission
redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])

View File

@ -1,5 +1,7 @@
class PagesController < ApplicationController
include ApplicationHelper
before_filter :get_item, :only => [:index_from_link, :show_from_link]
def index

View File

@ -107,4 +107,51 @@ module ApplicationHelper
end
end
def process_page(page, id)
parse_page_noko(page, id)
end
def page_metas(page)
metas = ''
@site.page_metas.each do |meta|
name, content = meta.get_name_content
metas << "<meta name=#{name} content=#{content} />\n"
end rescue nil
return metas
end
def page_title(page)
"<title>#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}</title>\n"
end
def page_stylesheets(page)
stylesheets = ''
stylesheets << "<link href='/assets/bootstrap.css.erb' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/style.css.erb' 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='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme
stylesheets
end
def page_javascripts(page)
javascripts = ''
javascripts << "<script type='text/javascript' src='/static/jquery.js'></script>\n"
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/bootstrap.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/jquery.tinyscrollbar.min.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/jquery.isotope.min.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/orbit-1.0.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/orbit_bar.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>"
end
javascripts
end
end

View File

@ -3,6 +3,8 @@ class Layout < DesignFile
attr_reader :content
field :body
embeds_one :menu
embedded_in :design
embeds_many :layout_parts
@ -18,7 +20,9 @@ class Layout < DesignFile
end
def parse_layout
parse_layout_contents(self)
html = Nokogiri::HTML(self.file.read)
self.body = html.at_css("body").inner_html
parse_body(self)
end
end

15
app/models/meta.rb Normal file
View File

@ -0,0 +1,15 @@
class Meta
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :value, :default => nil
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
def get_name_content
[self.key, self.value ? self.value : self.i18n_variable[I18n.locale]]
end
end

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

@ -0,0 +1,11 @@
class Meta
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :value, :default => nil
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
end

View File

@ -0,0 +1,5 @@
class PageMeta < Meta
belongs_to :page
end

View File

@ -0,0 +1,5 @@
class SiteMeta < Meta
belongs_to :site
end

View File

@ -1,6 +1,6 @@
class ObjectAuth < PrototypeAuth
include OrbitCoreLib::ObjectTokenUnility
validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| }
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
belongs_to :obj_authable, polymorphic: true
# > - Something.find_with_auth(query)
# > - or Something.find(query).auth

View File

@ -6,11 +6,13 @@ class Page < Item
belongs_to :design
belongs_to :module_app
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_many :page_parts, :autosave => true, :dependent => :destroy
has_many :page_contexts, :autosave => true, :dependent => :destroy
has_many :page_metas, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :page_parts, :allow_destroy => true
before_save :create_parts
before_save :create_parts, :set_key
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
@ -18,6 +20,10 @@ class Page < Item
self.parent ? false : true
end
def title
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
protected
def create_parts
@ -27,4 +33,10 @@ class Page < Item
end
end
def set_key
if title.new_record?
title.key = 'title'
end
end
end

View File

@ -13,6 +13,8 @@ class Site
field :school
field :department
has_many :site_metas, :autosave => true, :dependent => :destroy
def generate_keys
private_key = OpenSSL::PKey::RSA.generate(2048)
self.public_key = private_key.public_key.to_s

View File

@ -1,3 +1,7 @@
<%= flash_messages %>
<%= parse_page_edit(@item).html_safe %>
<%= page_stylesheets(@item).html_safe %>
<%= page_javascripts(@item).html_safe %>
<%= parse_page_edit_noko(@item).html_safe %>

View File

@ -28,7 +28,7 @@
<% if user_signed_in? %>
<li class="dropdown active">
<a class="orbit-bar-account" href="#" data-toggle="dropdown">
<img class="member-img" src="/assets/menber-pic.png" />
<img class="member-img" src="/assets/person.png" />
<%#= image_tag current_user.avatar.thumb.url, :class => 'member-img' %>
<span class="member-name"><%= current_user.name %></span>
</a>

View File

@ -9,8 +9,9 @@
<%= 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.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') if is_manager? %>
<% end -%>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('users') do -%>

View File

@ -5,7 +5,7 @@
<title><%= @title || APP_CONFIG['orbit'] %></title>
<link rel="shortcut icon" href="/favicon.ico">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= stylesheet_link_tag "admin" %>
<%= javascript_include_tag "admin" %>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title><%= @title || APP_CONFIG['orbit'] %></title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= stylesheet_link_tag "devise" %>
<%= javascript_include_tag "devise" %>

View File

@ -2,7 +2,7 @@
<html>
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%#= stylesheet_link_tag "module_widget" %>
<%= javascript_include_tag "module_widget" %>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title><%= @title || APP_CONFIG['orbit'] %></title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= stylesheet_link_tag "new_admin" %>
<%= javascript_include_tag "new_admin" %>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<%= page_title(@item).html_safe %>
<%= page_metas(@item).html_safe %>
<%= @metas %>
<!--[if lt IE 9]>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= page_stylesheets(@item).html_safe %>
<%= page_javascripts(@item).html_safe %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -5,7 +5,7 @@
<title><%= @title || APP_CONFIG['orbit'] %></title>
<link rel="shortcut icon" href="/favicon.ico">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<%= javascript_include_tag "html5" %>
<![endif]-->
<%= stylesheet_link_tag "site_editor" %>
<%= javascript_include_tag "site_editor" %>

View File

@ -19,7 +19,7 @@ module Orbit
# Add directories for plugins
config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules)
config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules)
config.paths.app.views << "app/views/devise"
config.paths["app/views"] += %W(#{config.root}/app/views/devise)
# Settings in config/environments/* take precedence over those specified here.

184
lib/noko/layout.html Executable file
View File

@ -0,0 +1,184 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RulingSite</title>
<link rel="stylesheet" type="text/css" href="themes/ini.css" media="all" style=""/>
<link rel="stylesheet" type="text/css" href="themes/comp.css" media="all" style=""/>
<link rel="stylesheet" type="text/css" href="default.css" media="all" style=""/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.tinyscrollbar.min.js"></script>
<script type="text/javascript" src="javascript/rc.js"></script>
<script type="text/javascript" src="javascript/ccu.js"></script>
</head>
<body>
<div id="wrapper">
<div id="header" class="header">
<h1 id="logo" class="ini_heading"><a href="">國立政治大學</a><span>National Chengchi University</span></h1>
<div id="nav" class="header_nav">
<ul class="nav_1">
<li><a href="#" class="nav1">在校學生</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav2">校友</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav3">教職員工</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav4">訪客</a></li>
</ul>
<ul class="nav_2">
<li><a href="#">網站地圖</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#">iNCCU 愛政大</a></li><span class="line">&nbsp;|&nbsp;</span>
<li>
<a href="#" class="mail">郵件信箱</a>
<ul class="nav_menu2">
<li class="mail">郵件信箱</li>
<li><a href="">教職員生</a></li>
<li><a href="">校友</a></li>
</ul>
</li>
</ul>
</div>
<nav id="nav2" class="site_menu menu">
<ul class="nav ini_list page_menu" level='1' id='nav' class='nav ini_list' home='true' li_class='nav' li_incremental='true'>
<li><a href=""><span>關於政大</span></a></li>
<li>
<a href=""><span>學術單位</span></a>
<span class="dot"></span>
<ul class="site_menu2 page_menu" level='2' id='navi' li_class='navi'>
<li><a href=""><span>文學院</span></a></li>
<li><a href=""><span>理學院</span></a></li>
<li><a href=""><span>社會科學學院</span></a></li>
<li><a href=""><span>法學院</span></a></li>
<li><a href=""><span>商學院</span></a></li>
<li><a href=""><span>外國語文學院</span></a></li>
<li><a href=""><span>傳播學院</span></a></li>
<li><a href=""><span>國際事務學院</span></a></li>
<li><a href=""><span>教育學院</span></a></li>
</ul>
</li>
<li>
<a href=""><span>研究單位</span></a>
<span class="dot"></span>
<ul class="site_menu2 ini_list">
<li><a href=""><span>國際關係研究中心</span></a></li>
<li><a href=""><span>選舉研究中心</span></a></li>
<li><a href=""><span>第三部門研究中心</span></a></li>
<li><a href=""><span>創新與創造力研究中心</span></a></li>
<li><a href=""><span>台灣研究中心</span></a></li>
<li><a href=""><span>中國大陸研究中心</span></a></li>
<li><a href=""><span>人文研究中心</span></a></li>
<li><a href=""><span>心智、大腦與學習研究中心</span></a></li>
<li><a href=""><span>原住民族研究中心</span></a></li>
<li><a href=""><span>附屬研究中心</span></a></li>
</ul>
</li>
<li>
<a href=""><span>行政組織</span></a>
<span class="dot"></span>
<ul class="site_menu2">
<li><a href=""><span>教務處</span></a></li>
<li><a href=""><span>學生事務處</span></a></li>
<li><a href=""><span>總務處</span></a></li>
<li><a href=""><span>研究發展處</span></a></li>
<li><a href=""><span>國際合作事務處</span></a></li>
<li><a href=""><span>秘書處</span></a></li>
<li><a href=""><span>會計室</span></a></li>
<li><a href=""><span>人事室</span></a></li>
<li><a href=""><span>圖書館</span></a></li>
<li><a href=""><span>體育室</span></a></li>
<li><a href=""><span>公共行政及企業管理教育中心</span></a></li>
<li><a href=""><span>社會科學資料中心</span></a></li>
<li><a href=""><span>電子計算機中心</span></a></li>
<li><a href=""><span>附設公務人員教育中心</span></a></li>
<li><a href=""><span>教學發展中心</span></a></li>
<li><a href=""><span>華語文教學中心</span></a></li>
<li><a href=""><span>創新育成中心</span></a></li>
<li><a href=""><span>附設實驗國民小學</span></a></li>
<li><a href=""><span>附屬高級中學</span></a></li>
<li><a href=""><span>性別平等教育委員會</span></a></li>
</ul>
</li>
<li><a href=""><span>招生入學</span></a></li>
<li>
<a href=""><span>資訊服務</span></a>
<ul class="site_menu2">
<li><a href=""><span>校務系統</span></a></li>
<li><a href=""><span>校園授權軟體</span></a></li>
<li><a href=""><span>校園網路</span></a></li>
<li><a href=""><span>校園資訊服務</span></a></li>
<li><a href=""><span>教學軟硬體資源</span></a></li>
</ul>
</li>
<li><a href=""><span>聯絡我們</span></a></li>
</ul>
</nav>
<div id="banner_box">
<div id="banner" name='content_1' class="banner page_content">
</div>
</div>
</div>
<div id="main_content" class="content">
<div class="content2">
<div class="topic_news">
<div class="topic_news2">
<div class="main_content page_content" name='content_2'>
</div>
<div class="news_content page_content" name='content_2' main='true'>
</div>
<div class="sidebar page_content" name='content_7'>
</div>
</div>
</div>
<div class="clear"></div>
<div class="post_panel">
<div class="post_panel2">
<div class="announcements page_content" name='content_3'>
</div>
<div class="events page_content" name='content_4'>
</div>
</div>
</div>
<div class="clear"></div>
<div class="links_panel">
<div class="links_panel2">
<div class="adbanner1 page_content" name='content_5'>
</div>
<div class="quicklinks page_content" name='content_6'>
</div>
</div>
</div>
</div>
</div>
<div id="footer" class="footer">
<div class="copyright">
<p>
本網站著作權屬於國立政治大學,請詳見使用規則。
</p>
<p>
總機電話02-29393091<br/>
傳真02-29379611<br/>
地址11605 台北市文山區指南路二段64號<br/>
</p>
</div>
<div class="notice">
校園安全緊急通報&nbsp;|&nbsp;著作權&nbsp;|&nbsp;個人資料保護宣告&nbsp;|&nbsp;資訊安全宣告&nbsp;|&nbsp;聯絡我們
</div>
<div class="ruling">
<a href="">
<img src="images/ruling.png" alt="Rulingdigital" name="ruling_pic" id="ruling_pic" class="ruling_pic page_image" />
</a>
</div>
</div>
</div>
</body>
</html>

View File

@ -21,11 +21,19 @@ module OrbitCoreLib
def authed_users(title=nil)
users = []
unless title.nil?
users = self.object_auths.where(title: title )[0].auth_users_after_block_list rescue []
users = case title
when :all
ary = self.object_auths.collect{|t| t.auth_users}
ary.flatten!
when nil
if self.object_auths.count ==1
self.object_auths.first.auth_users_after_block_list rescue []
else
users = self.object_auths.collect{|t| t.auth_users_after_block_list} rescue []
users.flatten!.uniq!
logger.info "Warning calling a auth commend without specificed value( has multi-auths ), return empty"
[]
end
else
self.object_auths.where(title: title).first.auth_users rescue []
end
users
end

View File

@ -1,109 +1,52 @@
module ParserBackEnd
require 'radius'
include ParserCommon
def parse_page_edit(page)
if page._type == 'Page'
layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
context = parser_context_edit(page)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
end
require 'nokogiri'
# c.define_tag 'language_bar' do
# @site.in_use_locales.map{ |locale|
# lang = I18nVariable.first(:conditions => {:key => locale})[locale]
# if I18n.locale.to_s.eql?(locale)
# lang
# else
# "<a href='?locale=#{locale}'>#{lang}</a>"
# end
# }.join(' | ')
# end
# c.define_tag 'link' do |tag|
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
# ret = ''
# ret << "<a href='"
# ret << eval("admin_#{item._type.downcase}_path(item.id)")
# ret << "' class='nav'>"
# ret << item.i18n_variable[I18n.locale]
# ret << "</a>"
# end
def parse_page_edit_noko(page, id = nil)
body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page, true)
public_r_tags = parse_contents(body, page, id)
parse_images(body, page)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id)
end
def parser_context_edit(page, attributes = {})
Radius::Context.new do |c|
c.define_tag 'snippet' do |tag|
snippet = Snippet.first(:conditions => {:name => tag.attr['name']})
if snippet
snippet.content
else
t('nothing')
body.to_html
end
end
c.define_tag 'language_bar' do
@site.in_use_locales.map{ |locale|
lang = I18nVariable.first(:conditions => {:key => locale})[locale]
if I18n.locale.to_s.eql?(locale)
lang
else
"<a href='?locale=#{locale}'>#{lang}</a>"
end
}.join(' | ')
end
c.define_tag 'css' do |tag|
assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip))
res = ''
assets.each do |asset|
res << "<link href='#{asset.data.file.url}' rel='stylesheet' type='text/css' /> " if asset.data.file.content_type.eql?('text/css')
end
res
end
c.define_tag 'image' do |tag|
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
if image
res = "<img src=#{image.file.url} "
tag.attr.each do |l|
res << "#{l[0]}='#{l[1]}' "
end
res << '>'
end
end
c.define_tag 'stylesheets' do |tag|
res = ''
res << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />" if page.design.reset_css
res << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />" if page.design.default_css
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme
res
end
c.define_tag 'javascripts' do |tag|
res = ''
res << "<script type='text/javascript' src='/static/jquery.js'></script>"
res << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>"
res << "<script type='text/javascript' src='/static/kernel.js'></script>"
res << "<script type='text/javascript' src='/assets/event.js'></script>"
page.design.javascripts.each do |js|
res << "<script type='text/javascript' src='#{js.file.url}'></script>"
end
res
end
c.define_tag 'ad_banner' do |tag|
res = ''
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
</script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' "
res << "alt='#{ad_image.picture_intro || ' '}' "
res << "time_to_next='#{ad_image.get_delay_time}' "
res << "link_open='#{ad_image.link_open}' "
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "/>"
end
res << "</div>"
end
end
c.define_tag 'layout_part' do |tag|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
# page_contents
def parse_contents(body, page, id)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}'>"
ret << tag.expand
ret << '</div>'
end
c.define_tag 'content' do |tag|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
if (content["main"] == "true" && !page.module_app.nil?)
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true&page_id=#{page.id}"
ret << "&category_id=#{page.category}" if page[:category]
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>"
@ -119,31 +62,25 @@ module ParserBackEnd
end
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
public_r_tags << part.public_r_tag
else
''
end
ret << '</div>'
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
c.define_tag 'link' do |tag|
item = Item.first(:conditions => { :full_name => tag.attr['name'] })
ret = ''
ret << "<a href='"
ret << eval("admin_#{item._type.downcase}_path(item.id)")
ret << "' class='nav'>"
ret << item.i18n_variable[I18n.locale]
ret << "</a>"
end
c.define_tag 'menu' do |tag|
home = get_homepage
menu = page.design.layout.menu
menu_level(home, 0, menu, true)
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
def self.included(base)
base.send :helper_method, :parse_page_edit if base.respond_to? :helper_method
base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method
end
end

View File

@ -44,4 +44,56 @@ module ParserCommon
res << "</li>"
end
# ad_banners
def parse_ad_banners(body = nil, page = nil, id = nil)
body.css('ad_banner').each do |banner|
res = ''
ad_banner = AdBanner.find(banner["id"]) rescue nil
if ad_banner && ad_banner.display?
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
</script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' "
res << "alt='#{ad_image.picture_intro || ' '}' "
res << "time_to_next='#{ad_image.get_delay_time}' "
res << "link_open='#{ad_image.link_open}' "
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "/>"
end
res << "</div>"
end
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
banner.swap(fragment)
end
end
# page_images
def parse_images(body, page)
body.css('.page_image').each do |page_image|
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image
if image
res = "<img src=#{image.file.url} "
page_image.attributes.each do |l|
res << "#{l[0]}='#{l[1]}' "
end
res << '>'
end
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
page_image.swap(fragment)
end
end
# page_menu
def parse_menu(body, page, edit=nil)
page_menu = body.css('.page_menu').first
home = get_homepage
menu = page.design.layout.menu
fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, true))
page_menu.swap(fragment)
end
end

View File

@ -1,137 +1,52 @@
module ParserFrontEnd
require 'radius'
include ParserCommon
# c.define_tag 'language_bar' do
# @site.in_use_locales.map{ |locale|
# lang = I18nVariable.first(:conditions => {:key => locale})[locale]
# if I18n.locale.to_s.eql?(locale)
# lang
# else
# "<a href='?locale=#{locale}'>#{lang}</a>"
# end
# }.join(' | ')
# end
# c.define_tag 'link' do |tag|
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
# ret = ''
# ret << "<a href='#{tag.attr['name']}'>"
# ret << item.i18n_variable[I18n.locale]
# ret << '</a>'
# end
# end
def parser_context(page, attributes = {}, id = nil)
Radius::Context.new do |c|
c.define_tag 'snippet' do |tag|
snippet = Snippet.first(:conditions => {:name => tag.attr['name']})
if snippet
snippet.content
else
t('nothing')
require 'nokogiri'
def parse_page_noko(page, id = nil)
body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page)
public_r_tags = parse_contents(body, page, id)
parse_images(body, page)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id)
end
body.to_html
end
c.define_tag 'language_bar' do
@site.in_use_locales.map{ |locale|
lang = I18nVariable.first(:conditions => {:key => locale})[locale]
if I18n.locale.to_s.eql?(locale)
lang
else
"<a href='?locale=#{locale}'>#{lang}</a>"
end
}.join(' | ')
end
c.define_tag 'locale' do |tag|
case attributes[:locale]
when 'create'
var = I18nVariable.new(:key => (tag.attr['name'] rescue nil), :document_class => 'Text')
@site.valid_locales.each do |locale|
var[locale] = tag.attr[locale] rescue nil
end
var.save!
res = ''
res << "<r:locale id='#{var.id}' "
res << "name='#{var.key}' " if var.key
@site.valid_locales.each do |locale|
res << "#{locale}='#{var[locale]}' "
end
res << '/>'
when 'show'
var = I18nVariable.find(tag.attr['id'])
res = ''
res << "<r:locale "
res << "name='#{var.key}' " if var.key
@site.valid_locales.each do |locale|
res << "#{locale}='#{var[locale]}' "
end
res << '/>'
when 'destroy'
var = I18nVariable.find(tag.attr['id'])
var.destroy
end
end
c.define_tag 'css' do |tag|
assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip))
res = ''
assets.each do |asset|
res << "<link href='#{asset.data.file.url}' rel='stylesheet' type='text/css' /> " if asset.data.file.content_type.eql?('text/css')
end
res
end
c.define_tag 'stylesheets' do |tag|
res = ''
res << "<link href='/assets/bootstrap.css.erb' rel='stylesheet' type='text/css'/>"
res << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css'/>"
res << "<link href='/assets/style.css.erb' rel='stylesheet' type='text/css'/>"
res << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />" if page.design.reset_css
res << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' /> " if page.design.default_css
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
res << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />" if theme
res
end
c.define_tag 'javascripts' do |tag|
res = ''
res << "<script type='text/javascript' src='/static/jquery.js'></script>"
res << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>"
res << "<script type='text/javascript' src='/static/kernel.js'></script>"
res << "<script type='text/javascript' src='/assets/bootstrap.js'></script>"
res << "<script type='text/javascript' src='/assets/jquery.tinyscrollbar.min.js'></script>"
res << "<script type='text/javascript' src='/assets/jquery.isotope.min.js'></script>"
res << "<script type='text/javascript' src='/assets/orbit-1.0.js'></script>"
res << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>"
res << "<script type='text/javascript' src='/assets/event.js'></script>"
page.design.javascripts.each do |js|
# res << "<script type='text/javascript' src='#{js.file.url}'></script>"
end
res
end
c.define_tag 'ad_banner' do |tag|
res = ''
ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
if ad_banner && ad_banner.display?
res << "<script type='text/javascript'>
$(document).ready(function(){ $('#slideshow-#{ad_banner.title.dehumanize}').cycle({delay: -1000, fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout }); });
</script>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}'>"
ad_banner.ad_images.each do |ad_image|
res << "<img src='#{ad_image.file}' "
res << "alt='#{ad_image.picture_intro || ' '}' "
res << "time_to_next='#{ad_image.get_delay_time}' "
res << "link_open='#{ad_image.link_open}' "
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "/>"
end
res << "</div>"
end
res
end
c.define_tag 'image' do |tag|
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
if image
res = "<img src=#{image.file.url} "
tag.attr.each do |l|
res << "#{l[0]}='#{l[1]}' "
end
res << '>'
end
end
c.define_tag 'layout_part' do |tag|
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
part.content
end
c.define_tag 'content' do |tag|
# page_contents
def parse_contents(body, page, id)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
if (content["main"] == "true" && !page.module_app.nil?)
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
ret << "/#{id}" if id
ret << "?inner=true&page_id=#{page.id}"
ret << "&category_id=#{page.category}" if page[:category]
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
@ -143,38 +58,20 @@ module ParserFrontEnd
end
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
public_r_tags << part.public_r_tag
else
''
end
end
ret
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
c.define_tag 'link' do |tag|
item = Item.first(:conditions => { :full_name => tag.attr['name'] })
ret = ''
ret << "<a href='#{tag.attr['name']}'>"
ret << item.i18n_variable[I18n.locale]
ret << '</a>'
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
c.define_tag 'menu' do |tag|
home = get_homepage
menu = page.design.layout.menu
menu_level(home, 0, menu)
end
end
end
def parse_page(page, id = nil)
if page._type == 'Page'
layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
context = parser_context(page, {}, id)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
end
end
def self.included(base)
base.send :helper_method, :parse_page if base.respond_to? :helper_method
public_r_tags.uniq
end
end

View File

@ -1,37 +1,25 @@
module ParserLayout
require 'radius'
include ParserCommon
require 'nokogiri'
def parse_layout_contents(layout)
content = layout.content.force_encoding('UTF-8')
context = parser_layout_contents(layout)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(content)
def parse_body(layout)
body = Nokogiri::HTML(layout.body)
body.css('.page_content').each do |content|
layout.layout_parts.build(:name => content['name'])
end
def parser_layout_contents(layout)
Radius::Context.new do |c|
c.define_tag 'javascripts' do |tag|
body.css('.page_image').each do |image|
image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(image.to_html)) }
image.update_attributes(:name => image['name'], :html_id => image['id'], :html_class => image['class']) if image
end
c.define_tag 'stylesheets' do |tag|
end
c.define_tag 'ad_banner' do |tag|
end
c.define_tag 'menu' do |tag|
body.css('.page_menu').each do |menu|
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
layout.menu.levels = i = tag.attr['level'].to_i
layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1
layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']})
tag.expand
end
c.define_tag 'content' do |tag|
layout.layout_parts.new(:name => tag.attr['name'])
end
c.define_tag 'image' do |tag|
image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) }
image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image
end
layout.menu.levels = i = menu['level'].to_i
layout.menu.values.merge!({'home' => menu['home']}) if i == 1
layout.menu.values.merge!({"id_#{i}" => menu['id'], "class_#{i}" => menu['class'], "li_class_#{i}" => menu['li_class'], "li_incremental_#{i}" => menu['li_incremental']})
end
end
def parse_html_image(html)
@ -41,4 +29,6 @@ module ParserLayout
}
}
end
end

13
lib/tasks/noko.rake Normal file
View File

@ -0,0 +1,13 @@
# encoding: utf-8
namespace :nokogiri do
task :layout => :environment do
l = Design.first(:conditions => {:title => 'CCU'}).layout
l.layout_parts.destroy rescue nil
l.menu.destroy rescue nil
l.design.save
l = Design.first(:conditions => {:title => 'CCU'}).layout
l.file = File.open("#{Rails.root}/lib/noko/layout.html")
l.design.save
end
end

View File

@ -1,6 +1,4 @@
class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController
layout 'new_admin'
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
def index
@bulletin_categorys = BulletinCategory.all

View File

@ -1,5 +1,4 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
layout 'new_admin'
before_filter :authenticate_user!
before_filter :is_admin?
@ -181,7 +180,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
respond_to do |format|
format.js
end
end
# PUT /bulletins/1
@ -241,7 +239,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
end
# DELETE /bulletins/1
@ -269,6 +266,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# end
def load_quick_edit
@bulletin = Bulletin.find(params[:id])
@type = params[:type]
@bulletin_categories = BulletinCategory.all
get_tags
end
protected
def get_categorys(id = nil)

View File

@ -2,7 +2,6 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll
before_filter :authenticate_user!
include AdminHelper
# layout 'admin'
layout 'new_admin'
def setting
@bulletin_categorys = BulletinCategory.all
@ -18,7 +17,7 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll
else
first_category = @bulletin_categorys.first
end
preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check')
@users_array = preload_object_auth.first.privilege_users rescue []
respond_to do |format|
format.html

View File

@ -2,7 +2,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
@app_title = 'announcement'
end
# GET /bulletins
@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
date_now = Time.now
if params[:category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[: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)
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[: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
@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)
@bulletins = Bulletin.can_display.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
get_categorys
@ -23,7 +23,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
end
def show
@bulletin = Bulletin.find(params[:id])
@bulletin = Bulletin.can_display.where.where(_id: params[:id])
get_categorys
end

View File

@ -2,7 +2,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
@app_title = 'announcement'
end
# GET /bulletins
@ -14,9 +14,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
# @bulletin_categorys = BulletinCategory.first;
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
if params[:category_id]
@bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
else
@bulletins = Bulletin.widget_datas.limit(9)
@bulletins = Bulletin.can_display.widget_datas.limit(9)
end
get_categorys
@ -26,14 +26,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def bulletins_and_web_links
@tags = AnnouncementTag.all
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end
def reload_bulletins
@selected_tag = AnnouncementTag.find(params[:tag_id])
@bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
end
def reload_web_links

View File

@ -19,12 +19,14 @@ class Bulletin
field :is_top, :type => Boolean, :default => false
field :is_hot, :type => Boolean, :default => false
field :is_hidden, :type => Boolean, :default => false
field :is_checked, :type => Boolean, :default => false
field :is_checked, :type => Boolean, :default => nil
field :not_checked_reason
field :public, :type => Boolean, :default => true
scope :can_display,where(is_checked: true)
mount_uploader :image, ImageUploader
belongs_to :bulletin_category
@ -47,28 +49,17 @@ class Bulletin
def self.search( search = nil, category_id = nil )
if category_id.to_s.size > 0 and search.to_s.size > 0
key = /#{search}/
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif category_id.to_s.size > 0 and search.to_s.size < 1
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
elsif search.to_s.size > 0 and category_id.to_s.size < 1
key = /#{search}/
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
else
find(:all).desc( :is_top, :postdate)
end
end
@ -88,6 +79,10 @@ class Bulletin
end
def is_expired?
Date.today > self.deadline ? true : false rescue false
#some dates might sat as nil so rescue false
end
def is_top?
self.is_top
@ -101,6 +96,15 @@ class Bulletin
self.is_hidden
end
def is_checked?
self.is_checked
end
def is_check_rejected?
self.is_checked == false
end
def save_bulletin_links
self.bulletin_links.each do |t|
if t.should_destroy

View File

@ -10,40 +10,45 @@
<% if bulletin.is_hidden? %>
<span class="label"><%= t(:hidden) %></span>
<% end %>
</td>
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
<td>
<%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% unless bulletin.is_check_rejected?%>
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#" class='toggle-tr-edit' rel='basic'><%= t(:basic) %></a></li>
<li><a href="#" class='toggle-tr-edit' rel='picture'><%= t(:picture) %></a></li>
<li><a href="#" class='toggle-tr-edit' rel='tags'><%= t(:tags) %></a></li>
<li><a href="#" class='toggle-tr-edit' rel='link'><%= t(:link) %></a></li>
<li><a href="#" class='toggle-tr-edit' rel='file'><%= t(:file) %></a></li>
<li><%= link_to t(:basic), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'basic'), :remote => true %></li>
<li><%= link_to t(:picture), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'links'), :remote => true %></li>
<li><%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<%#= debugger %>
<%#= a=1 %>
<% if (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) and !bulletin.is_expired? %>
<li><%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
<% end %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
</ul>
</div>
</td>
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%></td>
<td><%= bulletin.postdate %></td>
<td><%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %></td>
<td>
<div class="label-group">
<div class="label-td">
<% bulletin.sorted_tags.each do |tag| %>
<span class="label label-tags"><%= tag[I18n.locale] %></span>
<% end %>
</div>
</div>
</td>
<td><%= User.from_id(bulletin.update_user_id).name rescue ''%></td>
</tr>
<%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %>
<% content_for :page_specific_javascript do %>
<script>
</script>
<% end %>
<tr id="<%= dom_id bulletin, :edit %>" class="qe-block hide" />

View File

@ -1,7 +1,6 @@
<% # encoding: utf-8 %>
<%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %>
<%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
@ -27,17 +26,12 @@
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= hidden_field_tag 'bulletin_link[bulletin_id]', @bulletin_link.bulletin_id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a
</div>
<% end %>
<% end %>

View File

@ -1,4 +1,4 @@
<thead>
<!--<thead>
<tr class="sort-header">
<th class="span1 strong">
<input type="checkbox">
@ -33,6 +33,18 @@
<%= content_tag(:b, nil, :class => is_sort?('update_user_id')) %>
</th>
</tr>
</thead>-->
<thead>
<tr>
<th class="span1"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span7"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
</tr>
</thead>
<tbody class="sort-holder">
<%= render :partial => 'bulletin', :collection => @bulletins %>

View File

@ -53,5 +53,45 @@
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
<div class="table-label">
<table class="table main-list">
<thead>
<tr class="sort-header">
<th class="span1 strong">
<input type="checkbox">
<a href class="list-remove"><i class="icon-trash"></i></a>
</th>
<th class="sort span1-2 <%= is_sort_active?('status') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('status')) %>">
<%= t('bulletin.status') %>
<%= content_tag(:b, nil, :class => is_sort?('status')) %>
</th>
<th class="sort span1-2 <%= is_sort_active?('category') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('category')) %>">
<%= t('bulletin.category') %>
<%= content_tag(:b, nil, :class => is_sort?('category')) %>
</th>
<th class="sort span7 <%= is_sort_active?('title') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('title')) %>">
<%= t('bulletin.title') %>
<%= content_tag(:b, nil, :class => is_sort?('title')) %>
</th>
<th class="sort span1-2 <%= is_sort_active?('postdate') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('postdate')) %>">
<%= t('bulletin.start_date') %>
<%= content_tag(:b, nil, :class => is_sort?('postdate')) %>
</th>
<th class="sort span1-2 <%= is_sort_active?('deadline') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('deadline')) %>">
<%= t('bulletin.end_date') %>
<%= content_tag(:b, nil, :class => is_sort?('deadline')) %>
</th>
<th class="sort span1-2 <%= is_sort_active?('tags') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('tags')) %>">
<%= t('bulletin.tags') %>
<%= content_tag(:b, nil, :class => is_sort?('tags')) %>
</th>
<th class="sort span1-2 <%= is_sort_active?('update_user_id') %>" rel="<%= panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %>">
<%= t('bulletin.last_modified') %>
<%= content_tag(:b, nil, :class => is_sort?('update_user_id')) %>
</th>
</tr>
</thead>
</table>
</div>
</div>
</div>

View File

@ -1,11 +1,41 @@
<% # encoding: utf-8 %>
<!--Widget start-->
<%= f.error_messages %>
<!--Widget start-->
<div id="sub-wiget">
<% if params[:action] != 'new' %>
<div id="widget-audit" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="A" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Audit</h3>
<div class="widget-content">
<% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %>
<div class="controls">
<%= f.label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('announcement.bulletin.fact_check_pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true, :class => 'privacy'} : {})%>
<%= t('announcement.bulletin.fact_check_not_pass') %>
<% end -%>
<div class="select-role">
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
</div>
</div>
<% end %>
</div>
</div>
<% elsif current_user.admin? %>
<%= f.hidden_field :is_checked,:value => true%>
<% end %>
<div id="widget-picture" class="widget-box widget-size-300">
<div class="widget-action clear">
<a class="action"><i title="Upload pictures" class="icon-exclamation-sign icon-white tip"></i></a>
@ -61,9 +91,18 @@
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i>Status</h3>
<div class="widget-content clear">
<div class="controls">
<%= f.check_box :is_top %><%= t('top') %>
<%= f.check_box :is_hot %><%= t('hot') %>
<%= f.check_box :is_hidden %><%= t('hide') %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_top %>
<%= t('top') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hot %>
<%= t('hot') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hidden %>
<%= t('hide') %>
<% end -%>
</div>
</div>
</div>
@ -75,9 +114,11 @@
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
<div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %>
<% end %>
<% end %>
</div>
</div>
@ -90,6 +131,15 @@
<div id="post-body">
<div id="post-body-content" class="clear">
<div class="field">
<%= f.label :image, t('announcement.image') %><br />
<%= f.file_field :image %>
<% if @bulletin.image.file %>
<%= check_box_tag 'bulletin[image_del]' %>
<%= t('announcement.刪除已上傳檔案') %>
<% end %>
</div>
<%= f.label :category %>
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
@ -113,19 +163,19 @@
<% end %>
</div>
<div class="title">
<div class="editor">
<%= f.label :subtitle %>
<%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%" %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
<% end %>
</div>
<div class="title">
<div class="editor">
<%= f.label :text %>
<%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%" %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
<% end %>
</div>
@ -135,7 +185,6 @@
</div>
<div class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear">
@ -181,10 +230,6 @@
</div>
</div>
</div>
<div class="main-wiget">
<div id="widget-file" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
@ -232,8 +277,8 @@
</div>
</div>
<!--Post End-->
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
@ -260,11 +305,4 @@
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
});
</script>
<script type="text/javascript">
$(function() {
$('textarea').tinymce({
theme: 'advanced'
});
});
</script>
<% end %>

View File

@ -1,17 +1,10 @@
<!-- <tr class="qe-block hide"> -->
<tr class="qe-block hide">
<td colspan="8">
<legend><%= t(:quick_edit) %> - <span class='qe_title'></span>Basic / Picture / Tags / Link / File</legend>
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'form-horizontal'} do |f| %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %>
<td colspan="8">
<legend><%= t(:quick_edit) %> - <span class='qe_title'></span><%= t(type) %></legend>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'form-horizontal'} do |f| %>
<%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_#{@type}", :locals => { :f => f, :bulletin => @bulletin } %>
<div class="form-actions">
<%= f.submit t(:submit), :class => 'btn btn-primary' %>
<%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %>
<%= f.submit t(:cancel), :class => 'btn quick_edit_cancel', :type => 'reset', :rel => dom_id(@bulletin, :edit) %>
</div>
<% end %>
</td>
</tr>
</td>

View File

@ -1,4 +1,4 @@
<div id="qe-basic" class="qe-edit-div hide">
<div id="qe-basic" class="qe-edit-div">
<div id="widget-category">
<div class="control-group">
<label class="control-label"><%= t(:category) %></label>

View File

@ -1,4 +1,4 @@
<div id="qe-file" class="qe-edit-div hide">
<div id="qe-file" class="qe-edit-div">
<div id="widget-file">
<div class="control-group">
<table class="table table-condensed">

View File

@ -1,4 +1,4 @@
<div id="qe-link" class="qe-edit-div hide">
<div id="qe-link" class="qe-edit-div">
<div id="widget-link">
<div class="control-group">
<table id="bulletin_links" class="table table-condensed">

View File

@ -1,4 +1,4 @@
<div id="qe-picture" class="qe-edit-div hide">
<div id="qe-picture" class="qe-edit-div">
<div id="widget-picture">
<div class="control-group">
<label class="control-label">Picture</label>

View File

@ -32,7 +32,7 @@
</div>
</div> -->
<div id="qe-tags" class="qe-edit-div hide">
<div id="qe-tags" class="qe-edit-div">
<div id="widget-tags">
<div class="form-horizontal">
<% @tags.each do |tag| %>

View File

@ -1,7 +1,10 @@
<h1><%= t('announcement.editing_announcement') %></h1>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %>
<ul class="breadcrumb">
<li><span>Home</span><span class="divider">/</span></li>
<li><span>Library</span><span class="divider">/</span></li>
<li class="text-blue"><%= t('announcement.editing_announcement') %></li>
</ul>
<div id="poststuff">
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%#= link_back %>
<% end %>
</div>

View File

@ -0,0 +1,2 @@
$("#<%= dom_id @bulletin, :edit %>").show()
$("#<%= dom_id @bulletin, :edit %>").html("<%= j render :partial => 'quick_edit', :locals => {:type => @type} %>")

View File

@ -1,5 +1,5 @@
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path, :html => {:class => 'clear'} do |f| %>
<div id="poststuff">
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%#= link_back %>
</div>

View File

@ -1,11 +1,3 @@
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<ul>
<li>
<b><%= t('announcement.category') %></b>

View File

@ -0,0 +1,15 @@
<h1><%= bulletin_category.key %></h1>
<table>
<tr>
<th><%= t('bulletin.status') %></th>
<th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.action') %></th>
</tr>
<% bulletin_category.bulletins.each do |post| %>
<%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %>
<% end %>
</table>

View File

@ -0,0 +1,7 @@
<%= content_tag :div ,:id => "users_checkbox_ary", do -%>
<% sys_users = User.all -%>
<% sys_users.each do |user| -%>
<%= label_tag "lab-user-#{user.id}", user.name rescue '' -%>
<%= check_box_tag "[users][#{user.id}]", 'true',users.include?(user) -%>
<% end -%>
<% end -%>

View File

@ -0,0 +1,50 @@
<%= render 'panel/announcement/back_end/bulletins/filter' %>
<table id="bulettin_sort_list" class="table main-list">
<%= render 'panel/announcement/back_end/bulletins/bulletins' %>
</table>
<div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div>
<!--
<% content_for :secondary do %>
<%#= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<fieldset><legend><%= t('bulletin.search') %></legend>
<%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %>
<%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%>
Category <%#= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %>
KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %>
</fieldset>
<br />
<br />
<h1><%= t('bulletin.list_announcement') %></h1>
<div id="check_block">
<h1>Check Please</h1>
<%#= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%>
</div>
<br />
-->

View File

@ -0,0 +1,20 @@
<%= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %>
<br/>
<%= form_tag('', :remote => true) %>
<%= label_tag :category, t("announcement.bulletin.category") %>
<%= select_tag "category_id", options_from_collection_for_select(@bulletin_categorys, "id", "key") %>
<br/>
<%= label_tag :role, t("admin.roles") %>
<%= content_tag :div do -%>
<% form_tag :action => "update_setting" do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<%= submit_tag "Update" %>
<% end -%>
<% end -%>
<script type="text/javascript" charset="utf-8">
$('#category_id').change(function() {
$(this).parents('form').submit();
});
</script>

View File

@ -0,0 +1 @@
$("#users_checkbox_ary").replaceWith('<%= (render :partial => 'privilege_user', :locals => {:users => @users_array}).html_safe%>');

View File

@ -1,7 +1,6 @@
<% # encoding: utf-8 %>
<% if @bulletins and !@bulletins.nil? %>
<h2 class="topic_title"><%= t('announcement.campus_news')%></h2>
<%= link_to t('announcement.more'),panel_announcement_front_end_bulletins_path(), :class => "topic_note" %>
<div class="topic_prev">previous page</div>

View File

@ -10,6 +10,9 @@ Rails.application.routes.draw do
resources :bulletins do
match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit
member do
get 'load_quick_edit'
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
end

View File

@ -1,6 +0,0 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/

View File

@ -1,16 +0,0 @@
source "http://rubygems.org"
# Declare your gem's dependencies in NewBlog.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gem "mongoid"
gemspec
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

View File

@ -1,101 +0,0 @@
PATH
remote: .
specs:
NewBlog (0.0.1)
rails (~> 3.1.0.rc6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0)
actionpack (= 3.1.0)
mail (~> 2.3.0)
actionpack (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.2)
rack-cache (~> 1.0.3)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.0)
activemodel (3.1.0)
activesupport (= 3.1.0)
bcrypt-ruby (~> 3.0.0)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
activesupport (3.1.0)
multi_json (~> 1.0)
arel (2.2.1)
bcrypt-ruby (3.0.0)
bson (1.3.1)
builder (3.0.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mongo (1.3.1)
bson (>= 1.3.1)
mongoid (2.1.9)
activemodel (~> 3.0)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
multi_json (1.0.3)
polyglot (0.3.2)
rack (1.3.2)
rack-cache (1.0.3)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.0)
actionmailer (= 3.1.0)
actionpack (= 3.1.0)
activerecord (= 3.1.0)
activeresource (= 3.1.0)
activesupport (= 3.1.0)
bundler (~> 1.0)
railties (= 3.1.0)
railties (3.1.0)
actionpack (= 3.1.0)
activesupport (= 3.1.0)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2)
rdoc (3.9.4)
sprockets (2.0.0)
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
PLATFORMS
ruby
DEPENDENCIES
NewBlog!
mongoid

View File

@ -1,20 +0,0 @@
Copyright 2011 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,3 +0,0 @@
= NewBlog
This project rocks and uses MIT-LICENSE.

View File

@ -1,39 +0,0 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'NewBlog'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test

View File

@ -1,7 +0,0 @@
/*
*This is a manifest file that'll automatically include all the stylesheets available in this directory
*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_tree .
*/

View File

@ -1,51 +0,0 @@
/* module */
#module{
float: left;
width: 170px;
margin-left: 20px;
}
.production {
padding: 10px;
font-size: 12px;
border: 1px solid #e1e1e1;
margin-bottom: 10px;
background: #DDDAD0;
color: #484339;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 0 5px #33322C;
-webkit-box-shadow: 0 0 5px #33322C;
box-shadow: 0 0 5px #33322C;
text-shadow: 0 1px 0 #fff;
line-height: 1.4;
font-family: Arial;
}
.production h2{
font-size: 18px;
margin-bottom: 10px;
text-shadow: 0 1px 0 #fff;
border-left: 4px solid #B6300C;
line-height: 20px;
padding-left: 5px;
}
.production table{
border: 1px solid #9b968c;
padding: 5px;
width: 145px;
}
.production th{
background: #d3cfc3;
font-weight: bold;
}
.production th, .production tr, .production td{
border: 1px solid #9b968c;
padding: 5px;
}
.production a{
color: #9a460e;
text-decoration: none;
}
.production a:hover{
text-decoration: underline;
}

View File

@ -1,23 +0,0 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
# Set I18n.locale
def set_locale
# update session if passed
session[:locale] = params[:locale] if params[:locale]
# set locale based on session or default
begin
# check if locale is valid for non site pages
if !VALID_LOCALES.include?(session[:locale])
I18n.locale = I18n.default_locale
else
I18n.locale = session[:locale]
end
rescue
I18n.locale = I18n.default_locale
end
end
end

View File

@ -1,84 +0,0 @@
class Panel::NewBlog::BackEnd::PostsController < ApplicationController
layout 'admin'
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
# GET /posts/1
# GET /posts/1.xml
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/new
# GET /posts/new.xml
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end
# POST /posts
# POST /posts.xml
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.create_post_success')) }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# PUT /posts/1
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.update_post_success')) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /posts/1
# DELETE /posts/1.xml
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(panel_new_blog_posts_url) }
format.xml { head :ok }
end
end
end

View File

@ -1,7 +0,0 @@
class Panel::NewBlog::FrontEnd::CommentsController < OrbitFrontendController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to panel_new_blog_front_end_post_url(@post)
end
end

View File

@ -1,13 +0,0 @@
class Panel::NewBlog::FrontEnd::PostsController < OrbitFrontendController
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
end

View File

@ -1,12 +0,0 @@
class Panel::NewBlog::Widget::PostsController < OrbitWidgetController
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
end
def latest_post
@post = Post.all.last
end
end

View File

@ -1,6 +0,0 @@
module ApplicationHelper
def check_show_frontend
front_end_available(NewBlog::MOUDLEAPP_TITLE)
end
end

View File

@ -1,5 +0,0 @@
module NewBlogHelper
def self.check_show_frontend
ApplicationController.front_end_available(NewBlog::MOUDLEAPP_TITLE)
end
end

View File

@ -1,7 +0,0 @@
class Comment
include Mongoid::Document
include Mongoid::Timestamps
field :name, :type => String
field :body, :type => String
embedded_in :post, :inverse_of => :comments
end

View File

@ -1,10 +0,0 @@
class Post
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
field :title, :type => String
field :body, :type => String
embeds_many :comments
validates_presence_of :title, :body
end

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body class="edit preview">
<div class="wapper">
<%= yield %>
</div>
</body>
</html>

View File

@ -1,3 +0,0 @@
<div class="production">
<%= yield %>
</div>

Some files were not shown because too many files have changed in this diff Show More