diff --git a/app/assets/stylesheets/feile.css.erb b/app/assets/stylesheets/feile.css.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index f2c01451..6f3f1c3d 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -4,7 +4,7 @@ class Admin::AppAuthsController < ApplicationController before_filter :is_admin? def index - @roles = Role.all.entries + @user_roles = UserRole.all.entries apps = Purchase.where(:type =>"App") @app_auth_data = apps.entries.map do |app| app_c = eval(app.app_controller) diff --git a/app/models/design/design.rb b/app/models/design/design.rb index f39a4816..e77f7f0f 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -24,6 +24,35 @@ class Design after_save :procs_embedded_objects # after_destroy :del_embedded_objects + # validate do + # errors.add('atttribute1', 'error for 1') if files_with_duplicate? + # errors.add('atttribute2', 'error for 1') if files_with_noname? + # end + + def files_with_duplicate? + [self.javascripts, self.images,self.themes].each do |objects_hash| + ary = objects_hash.collect{ |k| k.file_filename} + ary.compact! + # debugger + return true if(ary.count!=ary.uniq.count) + end + false + end + + def files_with_noname? + [self.javascripts, self.images,self.themes].each do |objects_hash| + objects_hash.each{ |k| + return true if(k.file_filename.nil? && !k.to_save?) + } + end + false + end + def new_files=(*attrs) + attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs + self.files=([items_ary, key]) + end + end + def javascripts=(*attrs) self.files = (attrs << 'javascripts') end @@ -45,6 +74,7 @@ class Design files = eval(attrs.last) end attrs[0].each do |a| + if a[:id].blank? && !a[:file].blank? files.build(:file => a[:file], :to_save => true) else @@ -86,12 +116,14 @@ class Design end end end + self.valid? end def process_object(object) if object.to_save if object.file_filename.nil? - new_object = self.send(object._type.downcase.pluralize).build(object) + new_object = self.send(object._type.downcase.pluralize).build(object.attributes) + new_object.file = object.file object.destroy new_object.to_save = false new_object.save diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index 205b5350..c2945069 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -18,7 +18,7 @@ <% end %>
-<%= fields_for "design[" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> +<%= fields_for "design[new_files][" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> <%= f.file_field :file, :class => "multi_files" %>
<% end %> \ No newline at end of file diff --git a/app/views/admin/designs/edit.html.erb b/app/views/admin/designs/edit.html.erb index 5e7e705a..16ec7d4c 100644 --- a/app/views/admin/designs/edit.html.erb +++ b/app/views/admin/designs/edit.html.erb @@ -1,6 +1,6 @@diff --git a/app/views/admin/designs/new.html.erb b/app/views/admin/designs/new.html.erb index ded2237a..10316f40 100644 --- a/app/views/admin/designs/new.html.erb +++ b/app/views/admin/designs/new.html.erb @@ -1,6 +1,6 @@
<%= t('blog.title') %> | +<%= t('blog.body') %> | ++ | + | + |
---|---|---|---|---|
<%= post.title %> | +<%= post.body %> | +<%= link_to t('blog.show'), panel_blog_post_path(post) %> | +<%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %> | +<%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> | +
<%= t('blog.title') %> | +<%= t('blog.body') %> | ++ | + | + |
---|---|---|---|---|
<%= post.title %> | +<%= truncate(post.body,:length=>15) %> | +<%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %> | +<%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %> | +<%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> | +
+ <%= @post.body%> +
diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb new file mode 100644 index 00000000..03508f90 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb @@ -0,0 +1,13 @@ +<% content_for :secondary do %> +<%= flash_messages %>
+ ++ <%= t('blog.body') %> + <%=h @post.body %> +
+ +
+ <%=h c.name %> said:
+ <%= time_ago_in_words(c.created_at) %> ago
+
+ <%=h c.body %> +
+<% end %> + +<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %> +
+
+ <%= f.label :name, "Author" %>
+ <%= f.text_field :name %>
+ <%= f.label :body, "Comment Description" %>
+ <%= f.text_area :body %>
+ <%= hidden_field_tag :post_id, @post.id %>
+
+ <%= f.submit "Add Comment" %> +
+<% end %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb new file mode 100644 index 00000000..477429cd --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb @@ -0,0 +1,32 @@ +<% content_for :secondary do %> +<%= t('blog.title') %> | +<%= t('blog.body') %> | ++ | + | + |
---|---|---|---|---|
<%= post.title %> | +<%= truncate(post.body,:length=>15) %> | +<%= link_to t('blog.show'), panel_blog_post_path(post) %> | +<%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %> | +<%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> | +
+ <%= @post.body%> +
diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb new file mode 100644 index 00000000..fc4e591d --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb @@ -0,0 +1,13 @@ +<% content_for :secondary do %> +<%= flash_messages %>
+ ++ <%= t('blog.body') %> + <%=h @post.body %> +
+ +
+ <%=h c.name %> said:
+ <%= time_ago_in_words(c.created_at) %> ago
+
+ <%=h c.body %> +
+<% end %> + +<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %> +
+
+ <%= f.label :name, "Author" %>
+ <%= f.text_field :name %>
+ <%= f.label :body, "Comment Description" %>
+ <%= f.text_area :body %>
+ <%= hidden_field_tag :post_id, @post.id %>
+
+ <%= f.submit "Add Comment" %> +
+<% end %> + + +<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> | +<%= link_back %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb new file mode 100644 index 00000000..cd16cfc7 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb @@ -0,0 +1,16 @@ +<%=stylesheet_link_tag "NewBlog/application"%> + \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb new file mode 100644 index 00000000..2312fc74 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb @@ -0,0 +1,7 @@ +<%=stylesheet_link_tag "NewBlog/application"%> + \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb new file mode 100644 index 00000000..0ea7639f --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb @@ -0,0 +1,16 @@ +<%=stylesheet_link_tag "NewBlog/application"%> + \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb new file mode 100644 index 00000000..2312fc74 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb @@ -0,0 +1,7 @@ +<%=stylesheet_link_tag "NewBlog/application"%> + \ No newline at end of file diff --git a/vendor/plugins/NewBlog/config/locales/zh_tw.yml b/vendor/plugins/NewBlog/config/locales/zh_tw.yml new file mode 100644 index 00000000..d34b583d --- /dev/null +++ b/vendor/plugins/NewBlog/config/locales/zh_tw.yml @@ -0,0 +1,20 @@ +zh_tw: + + _locale: 中文 + + add: 新增 + back: 回去 + create: 創造 + delete: 刪除 + disable: 禁用 + edit: 編輯 + enable: 啟用 + hide: 隱藏 + homepage: 首頁 + no_: "No" + nothing: 無 + show: 顯示 + sure?: 您肯定嗎? + update: 更新 + yes_: "Yes" + diff --git a/vendor/plugins/NewBlog/config/routes.rb b/vendor/plugins/NewBlog/config/routes.rb new file mode 100644 index 00000000..b619df18 --- /dev/null +++ b/vendor/plugins/NewBlog/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + + namespace :panel do + namespace :blog do + root :to => "posts#index" + resources :posts + resources :comments + match "widget_latest_post" => "posts#widget_latest_post" + match "widget_index" => "posts#widget_index" + end + end + +end