diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index 8d2ca97c..29047c7b 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -1,3 +1,7 @@ +function get_part_id(){ + return $(".edit_page_part").attr("action").split('/').pop(); +} + $("div.editable").live("mouseenter mouseleave", function (event) { $(this).children('.edit_link').toggle(); }); @@ -21,11 +25,11 @@ $("#page_module_app_id").live('change', function() { }); $("#module_app_list select").live('change', function() { - $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets'); + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets?part_id=' + get_part_id()); }); $("#widget_list select").live('change', function() { - $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val()); + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val() + '&part_id=' + get_part_id()); }); $("#tag_list select").live('change', function() { diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index 975485a3..d73d7768 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -14,7 +14,6 @@ function load_tinymce() { theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, - relative_urls : false, // Skin options skin : "o2k7", diff --git a/app/assets/stylesheets/default_widget.css b/app/assets/stylesheets/default_widget.css new file mode 100644 index 00000000..96e490c4 --- /dev/null +++ b/app/assets/stylesheets/default_widget.css @@ -0,0 +1,195 @@ +body{ + margin:10px; + padding:0; +} +a{ + color:#333; + text-decoration: none; +} +a:hover{ + color:#888; + text-decoration: none; +} +h2{ + margin:0 0 10px; +} + +ul{ + margin:0; + padding:0; +} + +li{ + list-style:none; +} +.eletb{ + border-collapse:collapse; + width:600px; +} +.eletb td{ + border: 1px solid #EEEEEE; + padding: 5px; + vertical-align: middle; + text-align: center; +} +.news{ + font-size:12px; + margin:0 0 20px; + position:relative; + width:600px; +} +.news ul{ + margin:0 0 10px; +} +.news li{ + padding:5px 0; +} +.more{ + background:#eee; + border-radius: 5px; + clear:both; + display:inline; + padding:3px; + text-align: center; +} +.top{ + color:#e21f1f; +} + +.elements{ + background: none repeat scroll 0 0 #f2f2f2; + border-radius: 5px 5px 5px 5px; + display: inline-block; + height: 50px; + padding: 10px; + text-align: center; + vertical-align: top; + width: 50px; + word-wrap: break-word; +} +.elementlist{ + margin:0 0 20px; +} +/* 1 */ + +.newstb{ + border-collapse:collapse; + width:600px; +} + +.newstb th{ + background: none repeat scroll 0 0 #eee; + padding: 5px; + text-align: left; +} +.newstb td{ + border: 1px solid #EEEEEE; + padding: 5px; +} + + +/* 2 */ + +.news2{} + +.news2 li{ + border-bottom:1px solid #eee; +} + +.news2 .newsimg{ + display: inline-block; + margin: 0 10px 0 0; + vertical-align: top; +} + +.news2 .app-pic{ + height:50px; + width:50px; + display: inline-block; +} +.news2 ul{ + display: inline-block; + width:570px; +} + + +/* 3 */ + +.news3{} + +.news3 li{ + border-bottom:1px solid #eee; + overflow: hidden; +} + +.news3 .img{ + float:left; + margin:0 10px 0 0; +} + +.news3 .hot, .news3 .title, .news3 .date, .news3 .tags, .news3 .text{ + display:block; + margin:0 0 5px; + text-align: left; +} + +.news3 .wrap{ + overflow: hidden; +} + + + + +/* 4 */ + +.news4{} + +.news4 li{ + border-bottom:1px solid #eee; + overflow: hidden; +} + +.news4 .img{ + float:right; + margin:0 0 0 10px; +} + +.news4 .hot, .news4 .title, .news4 .date, .news4 .tags, .news4 .text{ + display:block; + margin:0 0 5px; + text-align: left; +} + +.news4 .wrap{ + overflow: hidden; +} + + + +/* 5 */ + +.news5{ + overflow: hidden; +} + +.news5 .img{ + float:left; + margin:0 10px 0 0; +} +.news5 ul{ + float: left; + text-align: left; + width: 540px; +} +.news5 li{ + border-bottom:1px solid #eee; +} + +.news5 .more{} +.news5 .hot, .news5 .title, .news5 .date, .news5 .tags, .news5 .text{ + +} + +.news5 .wrap{ + overflow: hidden; +} \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index f78c6ae3..58af08af 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -90,6 +90,7 @@ class Admin::PagePartsController < ApplicationController end def reload_widgets + @part = PagePart.find params[:part_id] @categories =[] @module_app = ModuleApp.find(params[:id]) @@ -112,6 +113,7 @@ class Admin::PagePartsController < ApplicationController @tags = ArchiveTag.all end + @part.widget_path = @module_app.widgets.first if @module_app.needs_to_widget_option? respond_to do |format| format.js {} end diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index 2f58d9ed..0ef39633 100644 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -39,7 +39,7 @@ class FrontController < ApplicationController res << "'>" i = nil i = 1 if menu.values["li_incremental_#{current}"] - children = current == 1 ? page.visible_children.reverse : page.visible_children + children = current == 1 ? page.visible_children : page.visible_children children.each do |child| res << menu_li(child, current_page, current, menu, i) i += 1 if i diff --git a/app/controllers/orbit_widget_controller.rb b/app/controllers/orbit_widget_controller.rb index 47e24fe0..8f4b25da 100644 --- a/app/controllers/orbit_widget_controller.rb +++ b/app/controllers/orbit_widget_controller.rb @@ -1,3 +1,10 @@ class OrbitWidgetController< OrbitFrontendComponentController +before_filter :get_wiget_options + def get_wiget_options + @wiget_options = {} + if params[:widget_options] + @wiget_options = (eval('{'+ params[:widget_options] +'}') rescue {}) + end + end end \ No newline at end of file diff --git a/app/models/item.rb b/app/models/item.rb index 81366a21..1809e2b2 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -56,7 +56,7 @@ class Item end def show_in_sitemap_for(locale) - if !sitemap_enabled[locale].blank? + if sitemap_enabled && !sitemap_enabled[locale].blank? sitemap_enabled[locale].eql?('true') ? true : false else true diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 669d82aa..50a6c268 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -12,12 +12,13 @@ class ModuleApp field :update_info field :create_date field :enable_frontend, type: Boolean, :default => true - + field :app_pages ,type: Array # field :widgets ,type: Array field :widgets ,type: Hash field :widget_fields ,type: Array - + field :widget_options,type:Hash + field :widget_options_fields_i18n,type:Hash has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app @@ -79,6 +80,14 @@ class ModuleApp end end + def needs_to_widget_option? + if self.widget_options + self.widget_options.has_key? widgets.first + else + false + end + end + protected def set_key diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 994424c8..a36c498a 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -14,6 +14,7 @@ class PagePart field :widget_style field :widget_field , :type => Array + field :widget_options ,:type=>Hash field :widget_data_count belongs_to :page @@ -22,6 +23,11 @@ class PagePart before_save :delete_empty_widget_field after_save :update_parent + def widget_options_uri + self.widget_options.map{|t| "#{t[0]}: #{t[1]}"}.join(',') rescue '' + end + + protected def delete_empty_widget_field @@ -35,4 +41,5 @@ class PagePart self.page.save end + end \ No newline at end of file diff --git a/app/models/tag.rb b/app/models/tag.rb index ad63434b..758c7899 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,4 +1,45 @@ -class Tag < ProtoTag - belongs_to :module_app +# class Tag < ProtoTag +# belongs_to :module_app + +# end + +class Tag + include Mongoid::Document + include Mongoid::Timestamps + include Impressionist::Impressionable + + is_impressionable :counter_cache => { :column_name => :view_count } + + field :key + field :view_count, :type => Integer, :default => 0 + #field :cloud_amper,:type: Integer,:default=> 0 + + def self.sorted_for_cloud + tags = {} + self.all.each{ |tag| + tags.merge!({tag => self.get_impressionist(tag)}) + } + if !tags.blank? + sorted_tags = tags.sort{|a,b| a[1]<=>b[1]}.reverse + sorted_tags[0][1] = :hot1 + offset = (sorted_tags.size - 1) / 3 + i = 1 + class_i = 2 + sorted_tags[1..-1].collect!{ |x| + x[1] = "hot#{class_i}" + i == offset ? i = 1 : i += 1 if class_i < 4 + class_i += 1 if i == offset && class_i < 4 + } + sorted_tags + else + [] + end + end + + protected + + def self.get_impressionist(item_tag = self) + item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count + end end diff --git a/app/views/admin/page_parts/_edit.html.erb b/app/views/admin/page_parts/_edit.html.erb index 828e03a2..78a20b37 100644 --- a/app/views/admin/page_parts/_edit.html.erb +++ b/app/views/admin/page_parts/_edit.html.erb @@ -12,6 +12,6 @@ <% end %>

- <%= f.submit t(:update) %> <%= link_back %> + <%= f.submit t(:update_) %> <%= link_back %>

<% end %> diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 44358601..a1cec8d0 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -46,7 +46,6 @@ <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %> -
-<%= f.label :widget_data_count %> -<%= f.text_field :widget_data_count %> -
+ + <%= render 'widget_options' %> + diff --git a/app/views/admin/page_parts/_widget_fields.html.erb b/app/views/admin/page_parts/_widget_fields.html.erb index 21196b5b..81b49992 100644 --- a/app/views/admin/page_parts/_widget_fields.html.erb +++ b/app/views/admin/page_parts/_widget_fields.html.erb @@ -1,4 +1,3 @@ - <% if (@module_app && @module_app.widget_fields) %> <%= label_tag('widget_field') %> @@ -9,4 +8,6 @@ <%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %>
<% end %> + <%= label_tag :widget_data_count %> + <%= text_field_tag :widget_data_count,@part.widget_data_count %> <% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/reload_widgets.js.erb b/app/views/admin/page_parts/reload_widgets.js.erb index c66c44e9..76f49d91 100644 --- a/app/views/admin/page_parts/reload_widgets.js.erb +++ b/app/views/admin/page_parts/reload_widgets.js.erb @@ -2,4 +2,6 @@ $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.coll $('#widget_style_list').html("<%= escape_javascript(select 'page_part', 'widget_style', @module_app.widgets[@widget_path]) if !@widget_path.blank? %>"); $('#widget_field').html("<%= j render 'widget_fields' %>"); $('#widget_category').html("<%= j render 'widget_categories' %>"); -$('#widget_tag').html("<%= j render 'widget_tags' %>"); \ No newline at end of file +$('#widget_tag').html("<%= j render 'widget_tags' %>"); + +$("#widget_options").html("<%= j render 'widget_options'%>"); \ No newline at end of file diff --git a/app/views/front/show_page_sub_menu.html.erb b/app/views/front/show_page_sub_menu.html.erb index 7dfcb0af..ebe51f73 100644 --- a/app/views/front/show_page_sub_menu.html.erb +++ b/app/views/front/show_page_sub_menu.html.erb @@ -1,7 +1,7 @@ <% if @menu_page && @menu_page.visible_children.size > 0 %>

<%= @menu_page.title %>

-