merge with november_presentation
This commit is contained in:
parent
fa27bfc86b
commit
d465febca7
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
<p class="new_file">
|
||||
<%= 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" %>
|
||||
</p>
|
||||
<% end %>
|
|
@ -1,6 +1,6 @@
|
|||
<h1><%= t('admin.editing_design') %></h1>
|
||||
|
||||
<%= form_for @design, :url => admin_design_path(@design) do |f| %>
|
||||
<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<p>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<h1><%= t('admin.new_design') %></h1>
|
||||
|
||||
<%= form_for :design, :url => admin_designs_path do |f| %>
|
||||
<%= form_for :design, :url => admin_designs_path,:html => {:multipart => true} do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Module.instance_eval do
|
||||
def using_object_ids?
|
||||
false
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
# encoding: utf-8
|
||||
|
||||
namespace :app_auth do
|
||||
|
||||
task :build => :environment do
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -5,6 +5,7 @@ Spork.prefork do
|
|||
# Loading more in this block will cause your tests to run faster. However,
|
||||
# if you change any configuration or code from libraries loaded here, you'll
|
||||
# need to restart spork for it take effect.
|
||||
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
|
@ -54,4 +55,4 @@ end
|
|||
# - Any code that is left outside of the blocks will be ran during preforking
|
||||
# and during each_run!
|
||||
# - These instructions should self-destruct in 10 seconds. If they don't,
|
||||
# feel free to delete them.
|
||||
# feel free to delete them.
|
|
@ -0,0 +1,25 @@
|
|||
<h1><%= t('blog.list_post') %></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('blog.title') %></th>
|
||||
<th><%= t('blog.body') %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.title %></td>
|
||||
<td><%= post.body %></td>
|
||||
<td><%= link_to t('blog.show'), panel_blog_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path %>
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"title": "NewBlog",
|
||||
"version": "0.1",
|
||||
"organization": "Rulingcom",
|
||||
"author": "RD dep",
|
||||
"intro": "A simple blog……",
|
||||
"update_info": "Some info",
|
||||
"create_date": "11-11-2011"
|
||||
}
|
84
vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb
vendored
Normal file
84
vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
class Panel::Blog::BackEnd::PostsController < ApplicationController
|
||||
|
||||
layout 'admin'
|
||||
|
||||
def index
|
||||
@posts = Post.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @posts }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /posts/1
|
||||
# GET /posts/1.xml
|
||||
def show
|
||||
@post = Post.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @post }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /posts/new
|
||||
# GET /posts/new.xml
|
||||
def new
|
||||
@post = Post.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @post }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /posts/1/edit
|
||||
def edit
|
||||
@post = Post.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /posts
|
||||
# POST /posts.xml
|
||||
def create
|
||||
@post = Post.new(params[:post])
|
||||
|
||||
respond_to do |format|
|
||||
if @post.save
|
||||
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) }
|
||||
format.xml { render :xml => @post, :status => :created, :location => @post }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /posts/1
|
||||
# PUT /posts/1.xml
|
||||
def update
|
||||
@post = Post.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @post.update_attributes(params[:post])
|
||||
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /posts/1
|
||||
# DELETE /posts/1.xml
|
||||
def destroy
|
||||
@post = Post.find(params[:id])
|
||||
@post.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(panel_blog_posts_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
<%= f.error_messages %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :title %><br />
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :body %><br />
|
||||
<%= f.text_area :body %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
|
@ -0,0 +1,32 @@
|
|||
<% content_for :secondary do %>
|
||||
<ul class="list">
|
||||
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<h1><%= t('blog.list_post') %></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('blog.title') %></th>
|
||||
<th><%= t('blog.body') %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.title %></td>
|
||||
<td><%= truncate(post.body,:length=>15) %></td>
|
||||
<td><%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
5
vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb
vendored
Normal file
5
vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<h2><%=@post.title%></h2>
|
||||
<p>
|
||||
<%= @post.body%>
|
||||
</p>
|
|
@ -0,0 +1,13 @@
|
|||
<% content_for :secondary do %>
|
||||
<ul class="list">
|
||||
<li><%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %></li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
<h1><%= t('blog.new_post') %></h1>
|
||||
<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
|
||||
<%= link_back %>
|
|
@ -0,0 +1,34 @@
|
|||
<p id="notice"><%= flash_messages %></p>
|
||||
|
||||
<p>
|
||||
<b><%= t('blog.body') %></b>
|
||||
<%=h @post.body %>
|
||||
</p>
|
||||
|
||||
<h2><%= t('blog.comments') %></h2>
|
||||
|
||||
<% @post.comments.each do |c| %>
|
||||
<p>
|
||||
<b><%=h c.name %> said:</b><br />
|
||||
<%= time_ago_in_words(c.created_at) %> ago
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%=h c.body %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
|
||||
<p>
|
||||
|
||||
<%= f.label :name, "Author" %><br />
|
||||
<%= f.text_field :name %><br />
|
||||
<%= f.label :body, "Comment Description" %><br />
|
||||
<%= f.text_area :body %>
|
||||
<%= hidden_field_tag :post_id, @post.id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.submit "Add Comment" %>
|
||||
</p>
|
||||
<% end %>
|
|
@ -0,0 +1,32 @@
|
|||
<% content_for :secondary do %>
|
||||
<ul class="list">
|
||||
<li><%= link_to t('blog.new_post'), new_panel_blog_post_path, :class => 'seclink1' %></li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<h1><%= t('blog.list_post') %></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('blog.title') %></th>
|
||||
<th><%= t('blog.body') %></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.title %></td>
|
||||
<td><%= truncate(post.body,:length=>15) %></td>
|
||||
<td><%= link_to t('blog.show'), panel_blog_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<h2><%=@post.title%></h2>
|
||||
<p>
|
||||
<%= @post.body%>
|
||||
</p>
|
|
@ -0,0 +1,13 @@
|
|||
<% content_for :secondary do %>
|
||||
<ul class="list">
|
||||
<li><%= link_to t('blog.index'), panel_blog_posts_path, :class => 'seclink2' %></li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
<h1><%= t('blog.new_post') %></h1>
|
||||
<%= form_for @post, :url => panel_blog_posts_path do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
|
||||
<%= link_back %>
|
|
@ -0,0 +1,38 @@
|
|||
<p id="notice"><%= flash_messages %></p>
|
||||
|
||||
<p>
|
||||
<b><%= t('blog.body') %></b>
|
||||
<%=h @post.body %>
|
||||
</p>
|
||||
|
||||
<h2><%= t('blog.comments') %></h2>
|
||||
|
||||
<% @post.comments.each do |c| %>
|
||||
<p>
|
||||
<b><%=h c.name %> said:</b><br />
|
||||
<%= time_ago_in_words(c.created_at) %> ago
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%=h c.body %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %>
|
||||
<p>
|
||||
|
||||
<%= f.label :name, "Author" %><br />
|
||||
<%= f.text_field :name %><br />
|
||||
<%= f.label :body, "Comment Description" %><br />
|
||||
<%= f.text_area :body %>
|
||||
<%= hidden_field_tag :post_id, @post.id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.submit "Add Comment" %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> |
|
||||
<%= link_back %>
|
|
@ -0,0 +1,16 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<div class="widget_index">
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('blog.title') %></th>
|
||||
<th><%= t('blog.body') %></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= link_to post.title,panel_blog_post_path(post) %></td>
|
||||
<td><%= post.body.truncate(14) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
7
vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb
vendored
Normal file
7
vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<div class="widget_latest_post">
|
||||
<h2><%= @post.title %> </h2>
|
||||
<p>
|
||||
<%= @post.body %>
|
||||
</p>
|
||||
</div>
|
|
@ -0,0 +1,16 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<div class="widget_index">
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('blog.title') %></th>
|
||||
<th><%= t('blog.body') %></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= link_to post.title,panel_blog_front_end_post_path(post) %></td>
|
||||
<td><%= post.body.truncate(14) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
7
vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb
vendored
Normal file
7
vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%=stylesheet_link_tag "NewBlog/application"%>
|
||||
<div class="widget_latest_post">
|
||||
<h2><%= @post.title %> </h2>
|
||||
<p>
|
||||
<%= @post.body %>
|
||||
</p>
|
||||
</div>
|
|
@ -0,0 +1,20 @@
|
|||
zh_tw:
|
||||
|
||||
_locale: 中文
|
||||
|
||||
add: 新增
|
||||
back: 回去
|
||||
create: 創造
|
||||
delete: 刪除
|
||||
disable: 禁用
|
||||
edit: 編輯
|
||||
enable: 啟用
|
||||
hide: 隱藏
|
||||
homepage: 首頁
|
||||
no_: "No"
|
||||
nothing: 無
|
||||
show: 顯示
|
||||
sure?: 您肯定嗎?
|
||||
update: 更新
|
||||
yes_: "Yes"
|
||||
|
|
@ -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
|
Loading…
Reference in New Issue