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

Conflicts:
	config/locales/zh_tw.yml
This commit is contained in:
Matthew K. Fu JuYuan 2012-05-14 12:36:09 +08:00
commit 2cd67356a5
80 changed files with 1216 additions and 511 deletions

View File

@ -10,11 +10,13 @@ gem 'devise', '1.5.3'
gem 'exception_notification' # Send error trace
gem 'execjs'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
gem 'mini_magick'
gem 'mongoid'
gem 'mongoid-tree', :require => 'mongoid/tree'
gem "mongo_session_store-rails3"
gem 'nokogiri'
gem 'radius'

View File

@ -96,6 +96,9 @@ GEM
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
jquery-ui-rails (0.4.0)
jquery-rails
railties (>= 3.1.0)
json (1.6.5)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
@ -115,6 +118,8 @@ GEM
activemodel (~> 3.1)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
mongoid-tree (0.7.0)
mongoid (~> 2.0)
multi_json (1.1.0)
nokogiri (1.5.2)
nokogiri (1.5.2-x86-mingw32)
@ -269,10 +274,12 @@ DEPENDENCIES
execjs
factory_girl_rails
jquery-rails
jquery-ui-rails
kaminari!
mini_magick
mongo_session_store-rails3
mongoid
mongoid-tree
nokogiri
radius
rails (>= 3.1.0, < 3.2.0)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,391 @@
/*
* jQuery UI Nested Sortable
* v 1.3.4 / 28 apr 2011
* http://mjsarfatti.com/sandbox/nestedSortable
*
* Depends:
* jquery.ui.sortable.js 1.8+
*
* License CC BY-SA 3.0
* Copyright 2010-2011, Manuele J Sarfatti
*/
(function($) {
$.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
options: {
tabSize: 20,
disableNesting: 'ui-nestedSortable-no-nesting',
errorClass: 'ui-nestedSortable-error',
listType: 'ol',
maxLevels: 0,
revertOnError: 1
},
_create: function() {
this.element.data('sortable', this.element.data('nestedSortable'));
return $.ui.sortable.prototype._create.apply(this, arguments);
},
destroy: function() {
this.element
.removeData("nestedSortable")
.unbind(".nestedSortable");
return $.ui.sortable.prototype.destroy.apply(this, arguments);
},
_mouseDrag: function(event) {
//Compute the helpers position
this.position = this._generatePosition(event);
this.positionAbs = this._convertPositionTo("absolute");
if (!this.lastPositionAbs) {
this.lastPositionAbs = this.positionAbs;
}
//Do scrolling
if(this.options.scroll) {
var o = this.options, scrolled = false;
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
} else {
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
}
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this, event);
}
//Regenerate the absolute position used for position checks
this.positionAbs = this._convertPositionTo("absolute");
//Set the helper position
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
//Rearrange
for (var i = this.items.length - 1; i >= 0; i--) {
//Cache variables and intersection, continue if no intersection
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
if (!intersection) continue;
if(itemElement != this.currentItem[0] //cannot intersect with itself
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
) {
$(itemElement).mouseenter();
this.direction = intersection == 1 ? "down" : "up";
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
$(itemElement).mouseleave();
this._rearrange(event, item);
} else {
break;
}
// Clear emtpy ul's/ol's
this._clearEmpty(itemElement);
this._trigger("change", event, this._uiHash());
break;
}
}
var parentItem = (this.placeholder[0].parentNode.parentNode
&& $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
? $(this.placeholder[0].parentNode.parentNode)
: null,
level = this._getLevel(this.placeholder),
childLevels = this._getChildLevels(this.helper),
previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
if (previousItem != null) {
while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
if (previousItem[0].previousSibling) {
previousItem = $(previousItem[0].previousSibling);
} else {
previousItem = null;
break;
}
}
}
newList = document.createElement(o.listType);
this.beyondMaxLevels = 0;
// If the item is moved to the left, send it to its parent level
if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
parentItem.after(this.placeholder[0]);
this._clearEmpty(parentItem[0]);
this._trigger("change", event, this._uiHash());
}
// If the item is below another one and is moved to the right, make it a children of it
else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
this._isAllowed(previousItem, level+childLevels+1);
if (!previousItem.children(o.listType).length) {
previousItem[0].appendChild(newList);
}
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
this._trigger("change", event, this._uiHash());
}
else {
this._isAllowed(parentItem, level+childLevels);
}
//Post events to containers
this._contactContainers(event);
//Interconnect with droppables
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
//Call callbacks
this._trigger('sort', event, this._uiHash());
this.lastPositionAbs = this.positionAbs;
return false;
},
_mouseStop: function(event, noPropagation) {
// If the item is in a position not allowed, send it back
if (this.beyondMaxLevels) {
this.placeholder.removeClass(this.options.errorClass);
if (this.options.revertOnError) {
if (this.domPosition.prev) {
$(this.domPosition.prev).after(this.placeholder);
} else {
$(this.domPosition.parent).prepend(this.placeholder);
}
this._trigger("revert", event, this._uiHash());
} else {
var parent = this.placeholder.parent().closest(this.options.items);
for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
parent = parent.parent().closest(this.options.items);
}
parent.after(this.placeholder);
this._trigger("change", event, this._uiHash());
}
}
// Clean last empty ul/ol
for (var i = this.items.length - 1; i >= 0; i--) {
var item = this.items[i].item[0];
this._clearEmpty(item);
}
$.ui.sortable.prototype._mouseStop.apply(this, arguments);
},
serialize: function(o) {
var items = this._getItemsAsjQuery(o && o.connected),
str = []; o = o || {};
$(items).each(function() {
var res = ($(o.item || this).attr(o.attribute || 'id') || '')
.match(o.expression || (/(.+)[-=_](.+)/)),
pid = ($(o.item || this).parent(o.listType)
.parent('li')
.attr(o.attribute || 'id') || '')
.match(o.expression || (/(.+)[-=_](.+)/));
if (res) {
str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
+ '='
+ (pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
}
});
if(!str.length && o.key) {
str.push(o.key + '=');
}
return str.join('&');
},
toHierarchy: function(o) {
o = o || {};
var sDepth = o.startDepthCount || 0,
ret = [];
$(this.element).children('li').each(function () {
var level = _recursiveItems($(this));
ret.push(level);
});
return ret;
function _recursiveItems(li) {
var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
if (id) {
var item = {"id" : id[2]};
if ($(li).children(o.listType).children('li').length > 0) {
item.children = [];
$(li).children(o.listType).children('li').each(function() {
var level = _recursiveItems($(this));
item.children.push(level);
});
}
return item;
}
}
},
toArray: function(o) {
o = o || {};
var sDepth = o.startDepthCount || 0,
ret = [],
left = 2;
ret.push({
"item_id": 'root',
"parent_id": 'none',
"depth": sDepth,
"left": '1',
"right": ($('li', this.element).length + 1) * 2
});
$(this.element).children('li').each(function () {
left = _recursiveArray(this, sDepth + 1, left);
});
ret = ret.sort(function(a,b){ return (a.left - b.left); });
return ret;
function _recursiveArray(item, depth, left) {
var right = left + 1,
id,
pid;
if ($(item).children(o.listType).children('li').length > 0) {
depth ++;
$(item).children(o.listType).children('li').each(function () {
right = _recursiveArray($(this), depth, right);
});
depth --;
}
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
if (depth === sDepth + 1) {
pid = 'root';
} else {
var parentItem = ($(item).parent(o.listType)
.parent('li')
.attr(o.attribute || 'id'))
.match(o.expression || (/(.+)[-=_](.+)/));
pid = parentItem[2];
}
if (id) {
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
}
left = right + 1;
return left;
}
},
_clearEmpty: function(item) {
var emptyList = $(item).children(this.options.listType);
if (emptyList.length && !emptyList.children().length) {
emptyList.remove();
}
},
_getLevel: function(item) {
var level = 1;
if (this.options.listType) {
var list = item.closest(this.options.listType);
while (!list.is('.ui-sortable')) {
level++;
list = list.parent().closest(this.options.listType);
}
}
return level;
},
_getChildLevels: function(parent, depth) {
var self = this,
o = this.options,
result = 0;
depth = depth || 0;
$(parent).children(o.listType).children(o.items).each(function (index, child) {
result = Math.max(self._getChildLevels(child, depth + 1), result);
});
return depth ? result + 1 : result;
},
_isAllowed: function(parentItem, levels) {
var o = this.options;
// Are we trying to nest under a no-nest or are we nesting too deep?
if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
if (o.maxLevels < levels && o.maxLevels != 0) {
this.placeholder.addClass(o.errorClass);
this.beyondMaxLevels = levels - o.maxLevels;
} else {
this.placeholder.removeClass(o.errorClass);
this.beyondMaxLevels = 0;
}
} else {
this.placeholder.addClass(o.errorClass);
if (o.maxLevels < levels && o.maxLevels != 0) {
this.beyondMaxLevels = levels - o.maxLevels;
} else {
this.beyondMaxLevels = 1;
}
}
}
}));
$.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
})(jQuery);

View File

@ -6,4 +6,3 @@
//
//= require jquery
//= require jquery_ujs
//= require news_link

View File

@ -32,3 +32,24 @@ $('.part_kind').live('click', function() {
$('.part_kind_partial').hide();
$('#part_' + $(this).attr('value')).show();
});
$(document).ready(function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'i',
helper: 'clone',
items: 'li',
maxLevels: 3,
opacity: .5,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
stop: function(event, ui) {
$.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
}
});
});

View File

@ -5,6 +5,9 @@
// the compiled file.
//
//= require jquery
//= require jquery.ui.draggable
//= require jquery.ui.droppable
//= require jquery.ui.sortable
//= require jquery_ujs
//= require bootstrap
//= require jquery.isotope.min
@ -12,4 +15,7 @@
//= require orbit-1.0
//= require orbit-bar-search
//= require side_bar_history
//= require page_edit
//= require page_edit
//= require tinymce-jquery
//= require tinymce_orbit
//= require lib/jquery.ui.nestedSortable.js

View File

@ -1,4 +1,4 @@
$(function() {
function load_tinymce() {
$('.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",
@ -22,4 +22,8 @@ $(function() {
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js"
});
}
$(document).ready(function() {
load_tinymce();
});

View File

@ -6,13 +6,14 @@
.nav-list li {
position: relative;
}
.nav-list ul {
margin-left: 10px;
.nav-list ol {
margin-left: 20px;
}
.nav-list ul li {
.nav-list ol li {
padding: 5px 0;
list-style: none;
}
.nav-list ul li a {
.nav-list ol li a {
font-size: 13px;
padding: 3px 0px;
display: block;
@ -148,4 +149,28 @@
}
#main-sidebar .quick-edit a:hover {
background-color: #DDDDDD;
}
ol.nav>li>.icons-moves {
display: none;
}
.sortable i {
position: absolute;
left: -20px;
top: 6px;
margin-right: 0;
opacity: 0.3;
filter: alpha(opacity=30);
}
.sortable i:hover {
cursor:move;
opacity: 0.7;
filter: alpha(opacity=70);
}
.placeholder {
background-color: rgba(0,136,204,.6);
border-radius: 3px;
}
.ui-nestedSortable-error {
background: rgba(255,206,206,.6);
color: #8a1f11;
}

View File

@ -110,10 +110,8 @@
padding:6px;
}
#orbit-bar .nav > li.search {
background-image: none;
overflow: hidden;
width: 28px;
margin-bottom: 0;
position: relative;
}
#orbit-bar .nav > li > a.orbit-bar-home {
@ -685,6 +683,33 @@
#banner [id^="slideshow-"] {
z-index: 2 !important;
}
#back_main .editable {
position: relative;
}
#back_main .editable:after {
content: '';
clear: both;
display: block;
visibility: hidden;
height: 0;
}
#back_main .edit_link a {
position: absolute;
z-index: 10;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-indent: -9999px;
background: url(<%= asset_path 'editicon.png' %>) no-repeat center center rgba(255,255,255,.8);
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1);
}
[class^="icons-"] {
display: inline-block;
width: 16px;
@ -1243,12 +1268,63 @@
.icons-plus {
background-position: -288px -576px;
}
/*20*/
.icons-power {
background-position: -0px -608px;
}
/*20*/
.icons- {
background-position: -0px -608px;
.icons-output {
background-position: -32px -608px;
}
.icons-col-resize {
background-position: -64px -608px;
}
.icons-move {
background-position: -96px -608px;
}
.icons-size-out {
background-position: -128px -608px;
}
.icons-size-in {
background-position: -160px -608px;
}
.icons-slash {
background-position: -192px -608px;
}
.icons-level {
background-position: -224px -608px;
}
.icons-share {
background-position: -256px -608px;
}
.icons-share2 {
background-position: -288px -608px;
}
.icons-re {
background-position: -320px -608px;
}
.icons-insert {
background-position: -352px -608px;
}
.icons-insert2 {
background-position: -384px -608px;
}
.icons-download {
background-position: -416px -608px;
}
.icons-tag-rignt {
background-position: -448px -608px;
}
.icons-tag-top {
background-position: -480px -608px;
}
.icons-tag-bottom {
background-position: -512px -608px;
}
.icons-tag-left {
background-position: -544px -608px;
}
.icons-moves {
background-position: -576px -608px;
}
/*21*/
.icons- {

View File

@ -15,6 +15,12 @@ class Admin::ItemsController < ApplicationController
@item = get_homepage
end
end
def update_position
item = Item.find(params[:id])
item.shift_to(params[:parent_id], params[:position])
render :nothing => true
end
protected

View File

@ -11,7 +11,17 @@ class Admin::ModuleAppsController < ApplicationController
def reload_frontend_pages
@module_app = ModuleApp.find(params[:id])
@categories = @module_app.key.eql?('announcement') ? BulletinCategory.all : nil
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
end
respond_to do |format|
format.js {}
end

View File

@ -22,17 +22,20 @@ class Admin::PagePartsController < ApplicationController
def edit
@part = PagePart.find(params[:id])
@module_apps = ModuleApp.all(:conditions => {:enable_frontend => true})
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
@tag_objects = @r_tag.classify.constantize.all rescue nil
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
end
end
@ -69,10 +72,13 @@ class Admin::PagePartsController < ApplicationController
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
end
respond_to do |format|
format.js {}

View File

@ -20,14 +20,14 @@ class Admin::PagesController < ApplicationController
def new
@item = Page.new
@item.parent = Item.find(params[:parent_id]) rescue nil
@apps = ModuleApp.all
@apps = ModuleApp.excludes(app_pages: nil).entries
@designs = Design.all.entries
@design = Design.first
end
def edit
@item = Page.find(params[:id])
@apps = ModuleApp.all
@apps = ModuleApp.excludes(app_pages: nil).entries
@designs = Design.all.entries
@design = @item.design ? @item.design : @designs.first
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
@ -35,10 +35,13 @@ class Admin::PagesController < ApplicationController
case @item.module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
end
else
@categories = nil

View File

@ -99,9 +99,9 @@ class ApplicationController < ActionController::Base
end
# Render the page
def render_page(param={})
def render_page
if @item
render :text => process_page(@item, param[:id], param), :layout => 'page_layout'
render :text => parse_page_noko(@item), :layout => 'page_layout'
else
render :text => '404 Not Found'
end

View File

@ -24,7 +24,7 @@ class OrbitBackendController< ApplicationController
def check_user_can_use
unless check_permission
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
render :text => '403 Forbidden'
redirect_to root_url
end
end

View File

@ -1,7 +1,7 @@
class OrbitFrontendComponentController< ApplicationController
before_filter :setup_vars
before_filter {|c| c.front_end_available(@app_title)}
layout :false
layout "module_widget"
def setup_vars
@app_title = request.fullpath.split('/')[2]

View File

@ -15,11 +15,11 @@ class PagesController < ApplicationController
def show
#begin
@item = Item.first(:conditions => {:full_name => params[:page_name]})
@item = Item.first(:conditions => {:path => params[:page_name]})
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
case @item._type
when 'Page'
render_page(params)
render_page
when 'Link'
redirect_to "http://#{@item[:url]}"
end
@ -32,17 +32,19 @@ class PagesController < ApplicationController
end
def index_from_link
if params[:page]
redirect_to "/#{@item.full_name}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
else
redirect_to "/#{@item.full_name}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
end
url = "/#{@item.path}"
options = ''
options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank?
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
redirect_to url + options
end
def show_from_link
# debugger
# a=1
redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}"
url = "/#{@item.path}?id=#{params[:id]}"
options = ''
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
redirect_to url + options
end
def load_orbit_bar

View File

@ -8,9 +8,10 @@ module Admin::ItemHelper
dest = admin_page_path(node)
when 'Link'
dest = admin_link_path(node)
no_nested = 'no-nest'
end
ret << "<ul>" unless node.parent.nil?
ret << "<li>"
ret << "<li id='#{node.id}' class='#{no_nested}'>"
ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'>"
ret << (link_to node.i18n_variable[I18n.locale], dest)
ret << "<div class='quick-edit hide'>"
@ -22,22 +23,23 @@ module Admin::ItemHelper
ret << "</div>"
ret << render_children(node)
ret << "</li>"
ret << "</ul>" unless node.parent.nil?
end
ret.html_safe
end
def render_children(parent)
children = parent.ordered_children
if !children.entries.blank?
children = parent.children
if !parent.children.entries.blank?
ret = ''
ret << "<ol class='#{'sortable' if parent.parent.nil?}'>"
children.each do |child|
ret << render_node_and_children(child)
end
ret << '</ol>'
ret
else
''
end
end
end
end

View File

@ -103,11 +103,7 @@ module ApplicationHelper
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
def process_page(page, id, params)
parse_page_noko(page, id, params)
end
def page_metas(page)
tmp_meta = {}
metas = ''
@ -128,7 +124,7 @@ module ApplicationHelper
def page_title(page)
res = "<title>"
page_title = page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]
if page.is_home? && @site.title
if page.root? && @site.title
res << @site.title[I18n.locale]
elsif @site.title && @site.title_always_on
res << @site.title[I18n.locale] + ' - ' + page_title

View File

@ -2,59 +2,31 @@ class Item
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Tree
include Mongoid::Tree::Ordering
field :name, :index => true
field :full_name, :index => true
field :position, :type => Integer
field :is_published, :type => Boolean, :default => false, :index => true
field :enabled_for, :type => Array, :default => nil
field :menu_enabled_for, :type => Array, :default => nil
field :name
field :path
field :is_published, :type => Boolean, :default => false
field :enabled_for, :type => Array, :default => nil
field :menu_enabled_for, :type => Array, :default => nil
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
validates_uniqueness_of :name, :scope => :parent_id
validates_presence_of :name, :full_name, :position
validates_presence_of :name
validates_associated :parent, :children
after_rearrange :rebuild_path
belongs_to :parent, :class_name => "Item"
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :children, :class_name => "Item", :as => 'parent'
before_validation :setup_default_value
def self.find_by_name(item_name)
Item.first(:conditions => { :name => item_name, :is_published => true })
end
# Get an array of ancestors
def ancestors
node, nodes = self, []
nodes << node = node.parent while !node.parent.blank? rescue nil
nodes.reverse
end
# Get an array of ancestor's id
def ancestor_ids
node, nodes = self, []
while !node.parent.blank? do
node = node.parent rescue nil
nodes << node.id if node
end
# nodes << node = node.parent while !node.parent.blank? rescue nil
nodes.reverse
end
# Build the url from the array of ancestors
def url
urls = ancestors.map{ |a| a.name } << self.name
urls.join("/")
end
def ordered_children
self.children.asc(:position)
end
def ordered_and_visible_children
objects = ordered_children
def visible_children
objects = self.children
a = []
if objects
objects.each do |object|
@ -63,23 +35,30 @@ class Item
end
a
end
def shift_to(new_parent, position)
unless self.parent_id.to_s.eql?(new_parent) && self.position.eql?(position.to_i)
new_parent = Item.find(new_parent)
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
if current_position_sibling
current_position_sibling.at_bottom? ? move_below(current_position_sibling) : move_above(current_position_sibling)
elsif self.parent != new_parent
self.parent = new_parent
save!
end
end
end
protected
def setup_default_value
# Set the position value within the parent scope
if self.position.blank?
max_page = Item.where(:parent_id => self.parent_id).count
self.position = (max_page)? max_page + 1 : 1
end
# Build the full_name from the ancestors array
full_node = self.ancestors.map{ |a| a.name }.push( self.name )
# Remove root node if not root
full_node.shift if full_node.size >= 2
self.full_name = full_node.join("/")
def rebuild_path
self.path = (self.ancestors_and_self - [Item.root]).collect{|x| x.name unless x.root?}.join('/')
end
def find_by_parent_and_position(parent, position)
parent.children.detect{|child| child.position == position}
end
# Enable the validation for parent_id
def validates_presence_of_parent_id?
true

View File

@ -3,6 +3,8 @@ class Page < Item
field :content
field :app_frontend_url
field :theme_id, :type => BSON::ObjectId, :default => nil
field :category
field :tag
belongs_to :design
belongs_to :module_app
@ -15,10 +17,6 @@ class Page < Item
before_save :create_parts, :set_key
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
def is_home?
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

View File

@ -11,9 +11,27 @@ class PagePart
field :public_r_tag_option, :default => nil
field :widget_path
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_one :i18n_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
belongs_to :page
belongs_to :module_app
before_save :set_key
def i18n_variable
@i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def title
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
protected
def set_key
title.key = 'title' if title && (title.key.blank? rescue true)
i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true)
end
end

View File

@ -1 +1 @@
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>

View File

@ -1,2 +1,3 @@
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>");
$('#app_page_category').html("<%= escape_javascript(select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}) if @categories %>");
$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>");
$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>");

View File

@ -2,7 +2,7 @@
<% LIST[:page_part_kinds].each do |kind| %>
<%= f.radio_button :kind, kind, :class => 'part_kind' %>
<%= t(kind) %>
<%= t(kind, :scope => 'admin.page_part_kinds') %>
<% end %>
<% LIST[:page_part_kinds].each do |kind| %>

View File

@ -1,3 +1,14 @@
<div>
<%= f.fields_for :title, @part.title do |f| %>
<% @site_valid_locales.each do |locale| %>
<p>
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %>
<%= f.text_field locale %>
</p>
<% end %>
<% end %>
</div>
<span id='module_app_list'>
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %>
</span>
@ -6,7 +17,12 @@
<%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %>
</span>
:
<span id="widget_category">
<%= render 'widget_categories' %>
</span>
<%= t :or_lower %>
<span id="widget_tag">
<%= render 'widget_tags' %>
</span>

View File

@ -2,7 +2,13 @@
<% @site_valid_locales.each do |locale| %>
<div>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale %>
<%= f.text_area locale, :class => 'tinymce_textarea' %>
</div>
<% end %>
<% end %>
<% end %>
<script>
$(document).ready(function() {
load_tinymce();
});
</script>

View File

@ -0,0 +1 @@
<%= select 'page_part', 'tag', @tags.collect{|category| [category[I18n.locale], category.id]}, :selected => (@part ? @part[:tag] : nil), :include_blank => true if @tags && @tags.size > 0 %>

View File

@ -1,2 +1,3 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|widget| [widget.humanize, widget]}) %>")
$('#widget_category').html("<%= j render 'widget_categories' %>")
$('#widget_category').html("<%= j render 'widget_categories' %>")
$('#widget_tag').html("<%= j render 'widget_tags' %>")

View File

@ -1,10 +1,11 @@
<%= flash_messages %>
<h1><%= t('admin.editing_page') %></h1>
<%= form_for @item, :url => admin_page_path(@item) do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit t('update') %> <%= link_back %>
</p>
<% end %>
<div id="poststuff">
<h1><%= t('admin.editing_page') %></h1>
<%= form_for @item, :url => admin_page_path(@item), :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
</div>

View File

@ -1,52 +1,95 @@
<%= f.error_messages %>
<%= f.hidden_field :parent, :value => (@item.parent.id rescue nil) %>
<p>
<%= f.label :name, t('admin.name') %>
<%= f.text_field :name, :class => 'text' %>
</p>
<div class="control-group">
<%= f.label :name, t('admin.name'), :class => 'control-label' %>
<div class="controls">
<%= f.text_field :name, :class => 'text input-xlarge' %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<%= f.fields_for :i18n_variable, (@item.new_record? ? @item.build_i18n_variable : @item.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<p>
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %>
<%= f.text_field locale %>
</p>
<% end %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'text input-xlarge' %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<% end %>
<% end %>
<p>
<%= t('admin.design_name') %>
<%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %>
</p>
<p>
<%= t('admin.theme') %>
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
</p>
<p>
<%= t('admin.module_app') %>
<%= render :partial => "app_selector", :locals => { :f => f } %>
<span id="app_page_url"><%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> </span>
<span id="app_page_category"><%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> </span>
</p>
<p>
<%= f.label :is_published, "#{t('admin.is_published')} ?" %>
<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
</p>
<p>
<%= f.label :menu_enabled_for, "#{t('admin.menu_enabled_for')}:" %>
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag 'page[menu_enabled_for][]', valid_locale, (@item.menu_enabled_for.nil? ? true : @item.menu_enabled_for.include?(valid_locale)) %>
<%= I18nVariable.from_locale(valid_locale) %>
<% end %>
<%= hidden_field_tag 'page[menu_enabled_for][]', '' %>
</p>
<p>
<%= f.label :enabled_for, "#{t('admin.enabled_for')}:" %>
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag 'page[enabled_for][]', valid_locale, (@item.enabled_for.nil? ? true : @item.enabled_for.include?(valid_locale)) %>
<%= I18nVariable.from_locale(valid_locale) %>
<% end %>
<%= hidden_field_tag 'page[enabled_for][]', '' %>
</p>
<div class="control-group">
<%= f.label :name, t('admin.design_name'), :class => 'control-label' %>
<div class="controls">
<%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :name, t('admin.theme'), :class => 'control-label' %>
<div class="controls">
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :name, t('admin.module_app'), :class => 'control-label' %>
<div class="controls">
<%= render :partial => "app_selector", :locals => { :f => f } %>
<span id="app_page_url">
<%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%>
</span>
<span id="app_page_category">
<%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
</span>
<span id="app_page_tag">
<%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%>
</span>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :is_published, "#{t('admin.is_published')} ?", :class => 'control-label' %>
<div class="controls">
<label class="radio">
<%= f.radio_button :is_published, true %>
Yes
</label>
<label class="radio">
<%= f.radio_button :is_published, false %>
No
</label>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :menu_enabled_for, "#{t('admin.menu_enabled_for')}:", :class => 'control-label' %>
<div class="controls">
<% @site_valid_locales.each do |valid_locale| %>
<label class="checkbox">
<%= check_box_tag 'page[menu_enabled_for][]', valid_locale, (@item.menu_enabled_for.nil? ? true : @item.menu_enabled_for.include?(valid_locale)) %>
<%= I18nVariable.from_locale(valid_locale) %>
</label>
<% end %>
<%= hidden_field_tag 'page[menu_enabled_for][]', '' %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :enabled_for, "#{t('admin.enabled_for')}:", :class => 'control-label' %>
<div class="controls">
<% @site_valid_locales.each do |valid_locale| %>
<label class="checkbox">
<%= check_box_tag 'page[enabled_for][]', valid_locale, (@item.enabled_for.nil? ? true : @item.enabled_for.include?(valid_locale)) %>
<%= I18nVariable.from_locale(valid_locale) %>
</label>
<% end %>
<%= hidden_field_tag 'page[enabled_for][]', '' %>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>

View File

@ -1,13 +1,11 @@
<h1><%= t('admin.new_page') %></h1>
<%= flash_messages %>
<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit t('create') %> <%= link_back %>
</p>
<% end %>
<div id="poststuff">
<h1><%= t('admin.new_page') %></h1>
<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
</div>

View File

@ -5,7 +5,9 @@
<%= javascript_include_tag "html5" %>
<![endif]-->
<%#= stylesheet_link_tag "module_widget" %>
<%= javascript_include_tag "module_widget" %>
<%= javascript_include_tag "module" %>
<%#= javascript_include_tag "#{@app_title}/module_widget" %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %>
</head>
<body>

View File

@ -23,9 +23,9 @@
</div>
<div class="viewport">
<div id='back_sidebar' class="overview">
<ul class="nav nav-list">
<ol class="nav nav-list">
<%= yield :sidebar %>
</ul>
</ol>
</div>
</div>
</nav>

View File

@ -204,6 +204,10 @@ en:
options: Options
orig_upload_file: Original filename
page: Page
page_part_kinds:
text: Text Area
public_r_tag: System Widget
module_widget: Plug-in Module Widget
position: Position
published?: Published?
purchase: Purchase

View File

@ -203,6 +203,10 @@ zh_tw:
edit: 編輯
ob_auth:
edit: 分類授權
page_part_kinds:
text: 文字區塊
public_r_tag: 系統模塊
module_widget: 外掛模塊
position: 位置
published?: 發布?
purchase: 購買

View File

@ -54,6 +54,7 @@ Orbit::Application.routes.draw do
get 'add_attribute_field'
end
resources :items
match 'update_position' => 'items#update_position'
resources :links do
member do
get 'delete'

View File

@ -14,7 +14,7 @@ module ParserBackEnd
# }.join(' | ')
# end
# c.define_tag 'link' do |tag|
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
# item = Item.first(:conditions => { :path => tag.attr['name'] })
# ret = ''
# ret << "<a href='"
# ret << eval("admin_#{item._type.downcase}_path(item.id)")
@ -23,64 +23,19 @@ module ParserBackEnd
# ret << "</a>"
# end
def parse_page_edit_noko(page, id = nil)
def parse_page_edit_noko(page)
body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page, true)
public_r_tags = parse_content_edits(body, page, id)
public_r_tags = parse_contents(body, page, true)
parse_images(body, page)
parse_footer(body, page, true)
parse_sub_menu(body, page, true)
parse_footer(body, page)
parse_sub_menu(body, page)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page, id, true)
send("parse_#{tag}s", body, page, true)
end
body.to_html
end
# page_contents
def parse_content_edits(body, page, id)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
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 == content['name'].to_s } rescue nil
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
ret << '</div>'
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
if part[:category]
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?category_id=#{part[:category]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>"
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 if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
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_noko if base.respond_to? :helper_method
end

View File

@ -3,7 +3,7 @@ module ParserCommon
def menu_level(page, current_page, current, menu, edit = false)
res = ''
if page.ordered_and_visible_children.size > 0
if page.visible_children.size > 0
res << "<ul class='"
res << menu.values["class_#{current}"] rescue nil
res << "'>"
@ -12,7 +12,7 @@ module ParserCommon
if menu.values['home'] && current == 1
res << menu_li(page, current_page, current, menu, i, edit)
end
page.ordered_and_visible_children.each do |child|
page.visible_children.each do |child|
res << menu_li(child, current_page, current, menu, i, edit)
i += 1 if i
end
@ -25,18 +25,18 @@ module ParserCommon
res = "<li class='"
res << menu.values["li_class_#{current}"] rescue nil
res << "_#{i}" if i
res << " active" if (current_page.id.eql?(page.id) || current_page.ancestor_ids.include?(page.id))
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
res << "'>"
res << "<a href='/#{edit ? admin_page_path(page.id) : page.full_name}'><span>#{page.i18n_variable[I18n.locale]}</span></a>"
if page.ordered_and_visible_children.size > 0 && current <= menu.levels
res << "<a href='/#{edit ? admin_page_path(page.id) : page.path}'><span>#{page.i18n_variable[I18n.locale]}</span></a>"
if page.visible_children.size > 0 && current <= menu.levels
res << "<span class='dot'></span>"
res << menu_level(page, current_page, current + 1, menu, edit)
end unless (page.is_home? rescue nil)
end unless (page.root? rescue nil)
res << "</li>"
end
# ad_banners
def parse_ad_banners(body = nil, page = nil, id = nil, edit=nil)
def parse_ad_banners(body = nil, page = nil, edit=nil)
body.css('ad_banner').each do |banner|
res = ''
ad_banner = AdBanner.find(banner["id"]) rescue nil
@ -82,7 +82,7 @@ module ParserCommon
end
# page_images
def parse_images(body, page, id = nil, edit=nil)
def parse_images(body, page, edit=nil)
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
@ -109,17 +109,17 @@ module ParserCommon
end
# sub_menus
def parse_sub_menus(body = nil, page = nil, id = nil, edit=nil)
def parse_sub_menus(body = nil, page = nil, edit=nil)
body.css('sub_menu').each do |sub_menu|
menu_page = Page.find(sub_menu['id']) rescue nil
res = ''
if menu_page && menu_page.ordered_and_visible_children.size > 0
if menu_page && menu_page.visible_children.size > 0
res << "<div class='category_list'>"
res << "<h3 class='h3'>#{menu_page.i18n_variable[I18n.locale]}</h3>"
res << "<ul class='list'>"
menu_page.ordered_and_visible_children.each do |child|
menu_page.visible_children.each do |child|
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
res << "<a href='/#{edit ? admin_page_path(child.id) : child.full_name}'>#{child.i18n_variable[I18n.locale]}</a>"
res << "<a href='/#{edit ? admin_page_path(child.id) : child.path}'>#{child.i18n_variable[I18n.locale]}</a>"
res << "</li>"
end
res << "</ul>"
@ -132,7 +132,7 @@ module ParserCommon
end
# page_footer
def parse_footer(body, page, edit=nil)
def parse_footer(body, page)
page_footer = body.css('.page_footer').first
if page_footer
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
@ -146,7 +146,7 @@ module ParserCommon
end
# page_sub_menu
def parse_sub_menu(body, page, edit=nil)
def parse_sub_menu(body, page)
page_sub_menu = body.css('.page_sub_menu').first
if page_sub_menu
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
@ -159,4 +159,50 @@ module ParserCommon
end
end
# page_contents
def parse_contents(body, page, edit=nil)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
category = params[:category_id].blank? ? page[:category] : params[:category_id]
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
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 << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
part_title = part.title[I18n.locale] rescue nil
if edit
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
ret << '</div>'
end
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
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 if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
end

View File

@ -11,7 +11,7 @@ module ParserFrontEnd
# }.join(' | ')
# end
# c.define_tag 'link' do |tag|
# item = Item.first(:conditions => { :full_name => tag.attr['name'] })
# item = Item.first(:conditions => { :path => tag.attr['name'] })
# ret = ''
# ret << "<a href='#{tag.attr['name']}'>"
# ret << item.i18n_variable[I18n.locale]
@ -21,69 +21,18 @@ module ParserFrontEnd
require 'nokogiri'
def parse_page_noko(page, id = nil,params)
def parse_page_noko(page)
body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page)
public_r_tags = parse_contents(body, page, id,params[:preview])
public_r_tags = parse_contents(body, page)
parse_images(body, page)
parse_footer(body, page)
parse_sub_menu(body, page)
public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id)
send("parse_#{tag}s", body, page)
end
body.to_html
end
# page_contents
def parse_contents(body, page, id,preview = false)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
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 << "&category_id=#{params[:category_id]}" if !params[:category_id].blank?
ret << "&tag_id=#{params[:tag_id]}" if !params[:tag_id].blank?
ret << "&preview=true" if preview.eql?('true')
ret << "'></div>"
else
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 ''
when 'module_widget'
# if part[:category]
# ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{part[:category]}'></div>"
# else
# ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
# end
if !params[:category_id].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{params[:category_id]}'></div>"
elsif !params[:tag_id].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&tag_id=#{params[:tag_id]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
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 if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
end

19
lib/tasks/items.rake Normal file
View File

@ -0,0 +1,19 @@
# encoding: utf-8
namespace :items do
task :tree_changes => :environment do
Item.all.each do |item|
item.position -= item.position > 5 ? 2 : 1
item.parent_ids = ancestors(item)
item.rename(:full_name, :path)
item.save
end
end
def ancestors(item)
node, nodes = item, []
nodes << node = node.parent while !node.parent.blank? rescue nil
nodes.reverse
end
end

View File

@ -1,9 +0,0 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require announcement_link

View File

@ -12,18 +12,16 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
date_now = Time.now
if !params[:category_id].blank?
@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)
@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_main]).per(10)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
tmp = AnnouncementTag.find(params[:tag_id]) rescue nil
tmp = AnnouncementTag.where(key: params[:tag_id])[0] unless tmp
@bulletins = tmp.bulletins.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)
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.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_main]).per(10)
else
@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)
@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_main]).per(10)
end
get_categorys
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
end
def show

View File

@ -9,20 +9,21 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
# GET /bulletins.xml
def index
# deadline
# @bulletin_categorys = BulletinCategory.first;
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
@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)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@bulletins = AnnouncementTag.find(params[:tag_id]).bulletins.can_display.widget_datas.limit(9) rescue nil
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.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)
else
@bulletins = Bulletin.can_display.widget_datas.limit(9)
@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
get_categorys
end
def bulletins_and_web_links
@ -30,7 +31,6 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@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

View File

@ -0,0 +1,44 @@
<% if bulletin_category -%>
<div class="modal hide fade in" id="bulletin_category-<%=bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.submit_user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
<% bulletin_category.get_object_auth_by_title('submit').auth_users.each do |user| %>
<div class="checkbox clear checked">
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
</div>
<% end -%>
<divl>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
</div>
<div>
<script type="text/javascript" src="/static/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#bulletin_category-<%=bulletin_category.id%>").on("show", function () {
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -3,9 +3,9 @@
<%= flash_messages %>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] %></h1>
<% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<h1 class="h1"><%= t('announcement.announcement') %></h1>
<% end %>
@ -29,5 +29,5 @@
</table>
<%= paginate @bulletins, :params => {:inner => 'false'} %>
<%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>

View File

@ -0,0 +1,25 @@
<% if @title %>
<h1 class="h1"><%= @title %></h1>
<% end %>
<table class="table table-bordered">
<tr>
<th><%= t('announcement.bulletin.category') %></th>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</table>
<%= paginate @bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -16,4 +16,8 @@
<ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_link" %>
<% end %>

View File

@ -1,20 +1,3 @@
<% # 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>
<div class="topic_next">next page</div>
<ul id="topic_list">
<% @bulletins.each do |post| %>
<li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale].html_safe %></p>
</li>
<% end %>
</ul>
<% end %>
<div id="bulletin_widget">
<%= render 'index' %>
</div>

View File

@ -0,0 +1 @@
$('#bulletin_widget').html("<%= j render 'index' %>")

View File

@ -58,6 +58,7 @@ en:
announcement:
all_articles: List
add_new: Add
announcement: Announcement
categories: Categories
error:
no_avilb_cate_for_posting: You need a category to submit your post,please contact admin
@ -66,8 +67,8 @@ en:
more: more+
bulletins: Bulletins
related_links: Related Links
list_announcement: List Announcement
bulletin:
submit_user_list: Submit User
category: Category
list_lower: " list"
title: Title

View File

@ -37,6 +37,7 @@ zh_tw:
announcement:
add_new: 新增
all_articles: 列表
announcement: 公告
error:
no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類
tags: 標籤
@ -47,9 +48,9 @@ zh_tw:
more: 更多+
bulletins: 公告訊息
related_links: 相關連結
list_announcement: 公告列表
bulletin:
category: 分類
submit_user_list: 張貼人
list_lower: 列表
title: 標題
postdate: 張貼日期
@ -173,7 +174,9 @@ zh_tw:
panel:
bulletin_category:
edit: 修改
delete: 刪除
# Chinese (Taiwan) translations for Ruby on Rails
# by tsechingho (http://github.com/tsechingho)

View File

@ -11,13 +11,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
def index
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_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)
@news_bulletins = NewsBulletin.can_display.where(:news_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_main]).per(10)
elsif !params[:tag_id].blank?
tmp = NewsTag.find(params[:tag_id]) rescue nil
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
@news_bulletins = tmp.news_bulletins.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) rescue nil
@news_bulletins = tmp.news_bulletins.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_main]).per(10) rescue nil
else
@news_bulletins = NewsBulletin.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)
@news_bulletins = NewsBulletin.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_main]).per(10)
end
get_categorys

View File

@ -9,20 +9,19 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
# GET /news_bulletins.xml
def index
# deadline
# @news_bulletin_categorys = NewsBulletinCategory.first;
# @news_bulletins = NewsBulletin.widget_datas(@news_bulletin_categorys.id).limit(9)
@title = params[:part_title]
date_now = Time.now
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).widget_datas.limit(9)
@news_bulletins = NewsBulletin.can_display.where(:news_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(5)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@news_bulletins = NewsTag.find(params[:tag_id]).news_bulletins.can_display.widget_datas.limit(9) rescue nil
@tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.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(5) rescue nil
else
@news_bulletins = NewsBulletin.can_display.widget_datas.limit(9)
@news_bulletins = NewsBulletin.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(5)
end
get_categorys
end
def news_bulletins_and_web_links
@ -30,7 +29,6 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
@selected_tag = NewsTag.find(params[:id]) rescue @tags[0]
@news_bulletins = @selected_tag.get_visible_news_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_news_bulletins
@ -47,6 +45,18 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
@tags = NewsTag.all
get_categorys
end
def home_banner
if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).widget_datas.limit(9)
elsif !params[:tag_id].blank?
@news_bulletins = NewsTag.find(params[:tag_id]).news_bulletins.can_display.widget_datas.limit(9) rescue nil
else
@news_bulletins = NewsBulletin.can_display.widget_datas.limit(9)
end
get_categorys
end
protected

View File

@ -0,0 +1,56 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "inc/permission-checkbox" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("announcement.bulletin.category") %>
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.submit_user_list"), panel_news_back_end_news_bulletin_category_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_news_back_end_news_bulletin_category_setting_path do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
</div>
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(document).ready(function() {
$(".prevent_enter_submit_form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
$('#category_id').change(function() {
$.ajax({
type: 'GET',
dataType: "script",
url:$(this).parents("from").attr("href"),
data:$(this).parents("form").serialize()
});
});
});
</script>

View File

@ -3,9 +3,9 @@
<%= flash_messages %>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] %></h1>
<% else %>
<h1 class="h1"><%= t('news.list_news') %></h1>
<h1 class="h1"><%= t('news.news') %></h1>
<% end %>
<table class="table table-bordered">
@ -28,5 +28,5 @@
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'false'} %>
<%= paginate @news_bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>

View File

@ -0,0 +1,27 @@
<% # encoding: utf-8 %>
<% if @title %>
<h1 class="h1"><%= @title %></h1>
<% end %>
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -0,0 +1,28 @@
<% if @news_bulletins and !@news_bulletins.nil? %>
<h2 class="topic_title"><%= t('news.campus_news')%></h2>
<%#= link_to t('news.more'),panel_news_front_end_news_bulletins_path(), :class => "topic_note" %>
<div class="btn-group topic_note">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<%= t('news.more') %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<% @news_bulletin_categorys.each do |category| %>
<li>
<%= link_to category.i18n_variable[I18n.locale], panel_news_front_end_news_bulletins_path(:category_id => category.id) %>
</li>
<% end %>
</ul>
</div>
<div class="topic_prev">previous page</div>
<div class="topic_next">next page</div>
<ul id="topic_list">
<% @news_bulletins.each do |post| %>
<li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale].html_safe %></p>
</li>
<% end %>
</ul>
<% end %>

View File

@ -1,33 +1,3 @@
<% # encoding: utf-8 %>
<% if @news_bulletins and !@news_bulletins.nil? %>
<h2 class="topic_title"><%= t('news.campus_news')%></h2>
<%#= link_to t('news.more'),panel_news_front_end_news_bulletins_path(), :class => "topic_note" %>
<div class="btn-group topic_note">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<%= t('news.more') %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<% @news_bulletin_categorys.each do |category| %>
<li>
<%= link_to category.i18n_variable[I18n.locale], panel_news_front_end_news_bulletins_path(:category_id => category.id) %>
</li>
<% end %>
</ul>
</div>
<div class="topic_prev">previous page</div>
<div class="topic_next">next page</div>
<ul id="topic_list">
<% @news_bulletins.each do |post| %>
<li>
<div class="news_img"><%= image_tag(post.image.url, :size => "290x130") if post.image.file %></div>
<h3 class="h3 news_title"><%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle[I18n.locale].html_safe %></p>
</li>
<% end %>
</ul>
<% end %>
<div id='news_bulletin_widget'>
<%= render 'index' %>
</div>

View File

@ -0,0 +1 @@
$('#news_bulletin_widget').html("<%= j render 'index' %>")

View File

@ -16,4 +16,8 @@
<ul id='news_bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "announcement_link" %>
<% end %>

View File

@ -63,7 +63,7 @@ en:
more: more+
news_bulletins: NewsBulletins
related_links: Related Links
list_news: List News
news: News
news_bulletin:
category: Category
list_lower: " list"

View File

@ -43,9 +43,9 @@ zh_tw:
sure?: 確定嗎?
campus_news: 校園新聞
more: 更多+
news_bulletins: 公告訊息
news_bulletins: 新聞訊息
related_links: 相關連結
list_news: 公告列表
news: 新聞
news_bulletin:
category: 分類
list_lower: 列表

View File

@ -39,6 +39,7 @@ Rails.application.routes.draw do
end
namespace :widget do
match "news_bulletins" => "news_bulletins#index"
match "home_banner" => "news_bulletins#home_banner"
match "news_bulletins_and_web_links" => "news_bulletins#news_bulletins_and_web_links"
match "reload_news_bulletins" => "news_bulletins#reload_news_bulletins"
match "reload_web_links" => "news_bulletins#reload_web_links"

View File

@ -7,6 +7,6 @@
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["news_bulletins"],
"widgets": ["news_bulletins", "news_bulletins_and_web_links"],
"widgets": ["news_bulletins", "home_banner"],
"enable_frontend": true
}

View File

@ -1,7 +1,7 @@
<tr id="<%= dom_id page_context %>" class="with_action">
<td>
<%= page_context.page.i18n_variable[I18n.locale] %>
<%= page_context.page.path %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<%if is_manager? || is_admin? || page_context.authed_users(:edit).include?(current_user)%>

View File

@ -12,7 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
date_now = Time.now
@web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page( params[:page]).per(20)
@web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page(params[:page]).per(10)
get_categorys
end

View File

@ -8,7 +8,24 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
# GET /web_links
# GET /web_links.xml
def index
if !params[:category_id].blank?
@web_links = WebLink.where(:web_link_category => params[:category_id]).desc( :is_top, :postdate).page( params[:page]).per(10)
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = WebResourceTag.find(params[:tag_id]) rescue nil
@tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag
@web_links = @tag.web_links.desc( :is_top, :postdate).page( params[:page]).per(10)
else
@web_links = WebLink.all.desc( :is_top, :postdate).page( params[:page]).per(10)
end
end
def home_list
@title = params[:part_title]
# deadline

View File

@ -2,7 +2,7 @@
<%= flash_messages %>
<%= paginate @web_links %>
<%= paginate @web_links, :params => {:inner => false}%>
<h1><%= t('web_link.list_web_resource') %></h1>

View File

@ -0,0 +1,9 @@
<div class="quicklinks">
<% if @title %>
<h3 class="link_title"><%= @title %></h3>
<% end %>
<div id='web_links_links'>
<%= render 'web_links' %>
</div>
</div>

View File

@ -1,5 +1,26 @@
<h3 class="link_title"><%= t("announcement.related_links") %></h3>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + " " + t('web_resource.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + " " + t('web_resource.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('web_resource.list_link') %></h1>
<% end %>
<div id='web_links_links'>
<%= render 'web_links' %>
</div>
<table class="table table-bordered">
<tbody>
<tr>
<th><%= t('web_resource.category') %></th>
<th><%= t('web_resource.name') %></th>
</tr>
<% @web_links.each do |post| %>
<tr>
<td><%= post.web_link_category.i18n_variable[I18n.locale] %></td>
<td>
<%= link_to post.name[I18n.locale], post.url, {:target => '_blank', :title => post.name[I18n.locale]} %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @web_links, :params => {:inner => 'false'} %>

View File

@ -25,6 +25,12 @@ en:
announcement:
sure?: Sure?
web_resource:
list_lower: list
list_link: Links list
# admin:
# action: Action

View File

@ -18,102 +18,9 @@ zh_tw:
update: 更新
yes_: "Yes"
admin:
action: 行動
add_language: 新增語言
admin: 管理
action: 行動
announcement: 公告
asset: 資產
attributes: 屬性
cant_delete_self: 您不可以刪除自己。
cant_revoke_self_admin: 您不可以撤銷自己的管理作用。
class: 階級
content: 內容
create_error_link: 創建連接時出錯。
create_error_page: 創建頁面時出錯。
create_success_home: 首頁已成功創建。
create_success_layout: 樣板已成功創建。
create_success_link: 連結已成功創建。
create_success_page: 頁面已成功創建。
create_success_snippet: 片段已成功創建
create_success_user: 用戶已成功創建。。
data: 數據
delete_language: 刪除語言
description: 描述
disable_language: 禁用語言
editing_home: 編輯首頁
editing_layout: 編輯樣板
editing_link: 編輯連結
editing_page: 編輯頁面
editing_snippet: 編輯片段
editing_user_info: 編輯用戶資料
editing_user_role: 編輯用戶角色
email: Email
enable_language: 啟用語言
file_name: 檔名
file_size: 檔案大小
format: 格式
home: 首頁
id: ID
info: 資料
is_published: 被出版
item: 項目
key: 關鍵
language: 語言
layout: 佈局
layout_name: 佈局名字
list_assets: 資產清單
list_items: 項目清單
list_layouts: 佈局清單
list_snippets: 斷片清單
list_users: 使用清單
list_user_infos: 用戶資料清單
list_user_roles: 用戶角色清單
member: 會員
move_down: 往下移
move_up: 往上移
multilingual: 多種語言
my_avatar: 我的頭像
no_home_page: 您沒有首頁
no_layout: 您沒有佈局
name: 名稱
new_asset: 新增資產
new_component: 新增元件
new_home: 新增首頁
new_layout: 新增樣板
new_link: 新增連結
new_page: 新增頁面
new_snippet: 新增片段
new_user: 新增使用
new_user_info: 新增用戶資料
new_user_role: 新增用戶角色
non_multilingual: 非多種語言
options: 選項
orig_upload_file: 原上傳檔名
position: 位置
published?: 發布?
role: 角色
roles: 角色。
title: 標題
translation: 翻譯
type: 類型
update_error_link: 更新鏈接時出現錯誤。
update_error_page: 更新頁面時出現錯誤。
update_success_content: 內容已成功更新。
update_success_home: 首頁已成功更新。
update_success_layout: 樣板已成功更新。
update_success_link: 連結已成功更新。
update_success_page: 頁面已成功更新。
update_success_snippet: 片段已成功更新。
update_success_user: 用戶已成功更新
url: URL
user: 用戶
user_info: 用戶資料
user_panel: 用戶面板
user_role: 用戶角色
panel:
web_resource:
list_lower: 列表
list_link: 鏈接列表

View File

@ -13,11 +13,11 @@ Rails.application.routes.draw do
resources :tags
end
namespace :front_end do
root :to => "web_links#index"
resources :web_links
end
namespace :widget do
match "web_links" => "web_links#index"
match "home_list" => "web_links#home_list"
match "reload_web_links" => "web_links#reload_web_links"
end
end

View File

@ -6,7 +6,6 @@
"intro": "A simple blog……",
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["web_links"],
"widgets": ["web_links"],
"widgets": ["home_list"],
"enable_frontend": true
}