mcms_resources 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/controllers/admin/resources_controller.rb +172 -0
- data/app/models/resource.rb +58 -0
- data/app/views/admin/resources/_form.html.erb +29 -0
- data/app/views/admin/resources/_record.html.erb +46 -0
- data/app/views/admin/resources/_records.html.erb +13 -0
- data/app/views/admin/resources/_submenu.html.erb +30 -0
- data/app/views/admin/resources/edit.html.erb +25 -0
- data/app/views/admin/resources/index.html.erb +50 -0
- data/app/views/admin/resources/new.html.erb +13 -0
- data/app/views/admin/resources/show.html.erb +22 -0
- data/app/views/shared/admin/_error_messages.html.erb +27 -0
- data/app/views/shared/admin/_form_actions.html.erb +35 -0
- data/config/routes.rb +18 -0
- data/lib/generators/mcms_resources/USAGE +8 -0
- data/lib/generators/mcms_resources/mcms_resources_generator.rb +25 -0
- data/lib/mcms_resources/engine.rb +13 -0
- data/lib/mcms_resources/version.rb +3 -0
- data/lib/mcms_resources.rb +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/mcms_resources_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +177 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'McmsResources'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
@@ -0,0 +1,172 @@
|
|
1
|
+
=begin
|
2
|
+
@Name: Admin Resources controller
|
3
|
+
@Use: Creating , modifying, deleting resources for the cms
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class Admin::ResourcesController < ApplicationController
|
9
|
+
|
10
|
+
#before_filter :authenticate_user!
|
11
|
+
prepend_before_filter :authenticate_user!
|
12
|
+
|
13
|
+
#load_and_authorize_resource :class => false
|
14
|
+
load_and_authorize_resource
|
15
|
+
|
16
|
+
#Assigning a layout admin for admin side controller
|
17
|
+
layout '/mcms/main_layout'
|
18
|
+
|
19
|
+
# GET /admin/images
|
20
|
+
# This is a default method for listing all assets for mcms_resources
|
21
|
+
def index
|
22
|
+
|
23
|
+
#checking params type whether file or image and the perticaular file types will be sorted
|
24
|
+
@type = params[:type]
|
25
|
+
|
26
|
+
if @type == 'image'
|
27
|
+
@resources = Resource.all_images.paginate({
|
28
|
+
:page => params[:page],
|
29
|
+
:per_page => resource_per_page
|
30
|
+
})
|
31
|
+
elsif @type == 'file'
|
32
|
+
@resources = Resource.all_files.paginate({
|
33
|
+
:page => params[:page],
|
34
|
+
:per_page => resource_per_page
|
35
|
+
})
|
36
|
+
else
|
37
|
+
@resources = Resource.paginate({
|
38
|
+
:page => params[:page],
|
39
|
+
:per_page => resource_per_page
|
40
|
+
})
|
41
|
+
end
|
42
|
+
|
43
|
+
respond_to do |format|
|
44
|
+
format.html{}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET /admin/images/1
|
49
|
+
# This is a method for showing an image
|
50
|
+
def show
|
51
|
+
@resource = Resource.find(params[:id]) || not_found
|
52
|
+
|
53
|
+
respond_to do |format|
|
54
|
+
format.html{}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# GET /admin/images/new
|
60
|
+
# This is method for opening form for uploading a resource
|
61
|
+
# Checks the type of resource needs to be uploaded and open the file field
|
62
|
+
def new
|
63
|
+
@resource = Resource.new
|
64
|
+
@type = 'file' if params[:type] == 'file'
|
65
|
+
respond_to do |format|
|
66
|
+
format.html{}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# GET /admin/images/1/edit
|
71
|
+
#This method opens the edit form for file upload
|
72
|
+
def edit
|
73
|
+
|
74
|
+
@resource = Resource.find(params[:id])
|
75
|
+
@resource.type = 'Resource'
|
76
|
+
@type = 'file' if params[:type] == 'file'
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
# POST /admin/images
|
81
|
+
# This method creates file record and upload resources to the local server
|
82
|
+
def create
|
83
|
+
@resource = Resource.new(params[:resource])
|
84
|
+
|
85
|
+
@resource.assetable_id = 1
|
86
|
+
@resource.assetable_type = 'User'
|
87
|
+
|
88
|
+
if params[:resource]
|
89
|
+
if image_types.include? params[:resource][:data].content_type
|
90
|
+
@resource.type = 'Ckeditor::Picture'
|
91
|
+
else
|
92
|
+
@resource.type = 'Ckeditor::AttachmentFile'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
respond_to do |format|
|
97
|
+
|
98
|
+
if @resource.save
|
99
|
+
|
100
|
+
#Checking resource type for image or file and redirecting as per the lists with conditions
|
101
|
+
if @resource.is_type_image?
|
102
|
+
redirect_path = admin_resources_path(:type => 'image')
|
103
|
+
else
|
104
|
+
redirect_path = admin_resources_path(:type => 'file')
|
105
|
+
end
|
106
|
+
|
107
|
+
format.html { redirect_to redirect_path, notice: 'Resource was successfully uploaded.' }
|
108
|
+
else
|
109
|
+
format.html { render action: "new", :type => @type }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# PUT /admin/resources/1
|
115
|
+
# This method updates file record and upload resources to the local server
|
116
|
+
def update
|
117
|
+
@resource = Resource.find(params[:id])
|
118
|
+
|
119
|
+
@resource.assetable_id = 1
|
120
|
+
@resource.assetable_type = 'User'
|
121
|
+
|
122
|
+
if image_types.include? params[:resource][:data].content_type
|
123
|
+
@resource.type = 'Ckeditor::Picture'
|
124
|
+
else
|
125
|
+
@resource.type = 'Ckeditor::AttachmentFile'
|
126
|
+
end
|
127
|
+
|
128
|
+
respond_to do |format|
|
129
|
+
if @resource.update_attributes(params[:resource])
|
130
|
+
format.html { redirect_to admin_resources_path, notice: 'Resource was successfully updated.' }
|
131
|
+
format.json { head :no_content }
|
132
|
+
else
|
133
|
+
format.html { render action: "edit" }
|
134
|
+
format.json { render json: @resource.errors, status: :unprocessable_entity }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
# DELETE /admin/images/1
|
141
|
+
# This method destroys file records
|
142
|
+
def destroy
|
143
|
+
@resource = Resource.find(params[:id])
|
144
|
+
@resource.destroy
|
145
|
+
|
146
|
+
respond_to do |format|
|
147
|
+
format.html { redirect_to admin_resources_url }
|
148
|
+
format.json { head :no_content }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
protected #protected methods start here
|
153
|
+
|
154
|
+
#Defining a not_found method for avoiding error raise
|
155
|
+
def not_found
|
156
|
+
raise ActionController::RoutingError.new('Not Found')
|
157
|
+
end
|
158
|
+
|
159
|
+
#defining number of resource records per page to display
|
160
|
+
#maximum upto 10 records per page .
|
161
|
+
def resource_per_page
|
162
|
+
10
|
163
|
+
end
|
164
|
+
|
165
|
+
#Initializing image types array
|
166
|
+
#Images can only contain jpeg, png, gif, tif file formats
|
167
|
+
def image_types
|
168
|
+
["image/jpeg", "image/png", "image/jpg", "image/gif", "image/tif"]
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
=begin
|
2
|
+
@Name: Admin Resource model
|
3
|
+
@Use: Creating , modifying, deleting images and files for the cms
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
=end
|
8
|
+
class Resource < ActiveRecord::Base
|
9
|
+
|
10
|
+
#Redefining the table name for the Image model as mcms_assets
|
11
|
+
self.table_name = 'mcms_assets'
|
12
|
+
|
13
|
+
#Defining has_attached_file as association and some paperclip extensions
|
14
|
+
has_attached_file :data,
|
15
|
+
:styles => lambda{ |a| ["image/jpeg", "image/png", "image/jpg", "image/gif"].include?( a.content_type ) ? { :thumb => '60x60', :small => '110x110>', :medium => '225x255>', :content => '450x450>'} : {} },
|
16
|
+
:url => lambda{ |a| ["image/jpeg", "image/png", "image/jpg", "image/gif"].include?( a.content_type ) ? "/ckeditor_assets/pictures/:id/:style_:basename.:extension" : "/ckeditor_assets/attachments/:id/:filename" },
|
17
|
+
:path => lambda{ |a| ["image/jpeg", "image/png", "image/jpg", "image/gif"].include?( a.content_type ) ? ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension" : ":rails_root/public/ckeditor_assets/attachments/:id/:filename" }
|
18
|
+
|
19
|
+
|
20
|
+
#Including validations for images as size, content_type, etc
|
21
|
+
#validates :data, :presence => true
|
22
|
+
validates_attachment_presence :data
|
23
|
+
validates_attachment_size :data, :less_than => 5.megabytes
|
24
|
+
|
25
|
+
#Writing attribute accessibles
|
26
|
+
attr_accessible :data, :data_file_name, :data_content_type, :data_file_size
|
27
|
+
|
28
|
+
#Writing scope for a definite case of searching records
|
29
|
+
scope :all_images, lambda { where("data_content_type LIKE"+" 'image%'") }
|
30
|
+
scope :all_files, lambda { where("data_content_type NOT LIKE"+" 'image%'" ) }
|
31
|
+
|
32
|
+
#after_post_process :save_image_dimensions
|
33
|
+
|
34
|
+
#Checking for a image type file
|
35
|
+
def is_type_image?
|
36
|
+
image_types.include? self.data_content_type
|
37
|
+
end
|
38
|
+
|
39
|
+
protected #protected methods start here
|
40
|
+
|
41
|
+
#Saving image dimensions
|
42
|
+
def save_image_dimensions
|
43
|
+
if data.content_type == "image/jpeg" || "image/png" || "image/jpg" || "image/gif"
|
44
|
+
geo = Paperclip::Geometry.from_file(data.queued_for_write[:original])
|
45
|
+
self.width = geo.width
|
46
|
+
self.height = geo.height
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#Initializing image types array
|
51
|
+
#Can only contain jpeg, png, gif, jpg and tif file formats
|
52
|
+
def image_types
|
53
|
+
["image/jpeg", "image/png", "image/jpg", "image/gif", "image/tif"]
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/images/_form.html.erb
|
3
|
+
@Use: This is a partial html page for form of creating and saving an image
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!-- Started the resource form -->
|
10
|
+
<%= form_for [:admin, @resource] do |f| %>
|
11
|
+
|
12
|
+
<!-- Render error messages partial for showing validaton error messages-->
|
13
|
+
<%= render :partial => "/shared/admin/error_messages",
|
14
|
+
:locals => {
|
15
|
+
:object => f.object,
|
16
|
+
:include_object_name => true
|
17
|
+
} %>
|
18
|
+
|
19
|
+
<!-- Added hidden field for choosing type of resource. It can be of image or file -->
|
20
|
+
<%= hidden_field_tag :type , @type %>
|
21
|
+
<div class="field">
|
22
|
+
<%= f.file_field :data %>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<!-- Render partial for form actions like submit buttons for the form -->
|
26
|
+
<%= render :partial => "/shared/admin/form_actions", :locals => { :f => f } %>
|
27
|
+
|
28
|
+
<!-- End of Form-->
|
29
|
+
<% end %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/blog/posts/_post.html.erb
|
3
|
+
@Use: This is a partial for showing post records
|
4
|
+
@Created date: 08-06-2012
|
5
|
+
@Modified Date: 31-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!-- Started the list record div -->
|
10
|
+
<div class="alert issues-comment">
|
11
|
+
<div class="body">
|
12
|
+
<span class="mini-icon mini-icon-issue-comment"></span>
|
13
|
+
<span class='title'>
|
14
|
+
|
15
|
+
<!-- Checking for the type of record . If Ckeditor::Picture showing the image neither file name -->
|
16
|
+
<% if record.type == "Ckeditor::Picture"%>
|
17
|
+
<%= image_tag record.data.url(:thumb), :style => 'height: 60px;width: 60px;' %>
|
18
|
+
<% else %>
|
19
|
+
<%= record.data_file_name %>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
</span>
|
23
|
+
|
24
|
+
<span class='actions'>
|
25
|
+
|
26
|
+
<!-- Added action links like deleting and view or download files -->
|
27
|
+
<%= link_to image_tag("icons/delete.png"), admin_resource_path(record) ,
|
28
|
+
:class => "cancel confirm-delete",
|
29
|
+
:title => 'Delete',
|
30
|
+
:method => :delete,
|
31
|
+
:confirm => "Are you sure to delete ?" %>
|
32
|
+
|
33
|
+
<!-- Checking for the type of record . If Ckeditor::Picture showing the image neither download file -->
|
34
|
+
<% if record.type == "Ckeditor::Picture"%>
|
35
|
+
|
36
|
+
<%= link_to image_tag("icons/application_go.png"), record.data.url(:original),
|
37
|
+
:title => 'Show', :target => "_blank" %>
|
38
|
+
<% else %>
|
39
|
+
<%= link_to image_tag("icons/download.jpeg"), record.data.url,
|
40
|
+
:title => 'Download'%>
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
</span>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: admin/images/_records.html.erb
|
3
|
+
@Use: This is a partial for showing image records
|
4
|
+
@Created date: 25-07-2012
|
5
|
+
@Modified Date: 25-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<ul id='sortable_list'>
|
9
|
+
|
10
|
+
<!-- Added partial for loop through resources -->
|
11
|
+
<%= render :partial => 'record', :collection => @resources %>
|
12
|
+
|
13
|
+
</ul>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/images/_submenu.html.erb
|
3
|
+
@Use: This is a partial html page for submenus
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 27-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!-- Started submenu list right side bar -->
|
10
|
+
<div id="your-repos" class="repos">
|
11
|
+
<div class="top-bar">
|
12
|
+
<h2>Submenu Lists </h2>
|
13
|
+
<%= link_to 'New Image', new_admin_resource_path, :class =>"button new-repo" %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<!-- ul started for adding lists-->
|
17
|
+
<ul class="repo-list" id="repo-listing">
|
18
|
+
<li class="submenu">
|
19
|
+
<%= link_to 'Add Resource', new_admin_resource_path, :class=>"owner" %>
|
20
|
+
</li>
|
21
|
+
|
22
|
+
<li class="submenu">
|
23
|
+
<%= link_to 'All Files', admin_resources_path(:type => 'file'), :class=>"owner" %>
|
24
|
+
</li>
|
25
|
+
|
26
|
+
<li class="submenu">
|
27
|
+
<%= link_to 'All Images', admin_resources_path(:type => 'image'), :class=>"owner" %>
|
28
|
+
</li>
|
29
|
+
</ul>
|
30
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/images/edit.html.erb
|
3
|
+
@Use: This is a partial html page for form of editing and updating an image
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 25-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<h1>Editing resource</h1>
|
9
|
+
<div>
|
10
|
+
|
11
|
+
<!-- Checking for resources either an image or file . If file then only form is called for uploading else showing the image with form-->
|
12
|
+
<% unless @type == 'file' %>
|
13
|
+
<h4>Existing Image</h4>
|
14
|
+
<%= image_tag @resource.data.url(:small) %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div style="margin-top: 10px;">
|
19
|
+
<h4>
|
20
|
+
Upload New Resource To Replace
|
21
|
+
</h4>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<!-- Rendering the form for editing image-->
|
25
|
+
<%= render 'form' %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/images/index.html.erb
|
3
|
+
@Use: This is a html page for listing images with some common edit, delete preview links for desired operations
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!--Added partial for include javascripts and css-->
|
10
|
+
<%= render :partial => "/shared/admin/includes" %>
|
11
|
+
|
12
|
+
<!-- Added flash hash loop through for extracting flash messages like flash-error, flash-message, etc -->
|
13
|
+
<% flash.each do |key, value| %>
|
14
|
+
<div id='flash' class="flash flash-<%= key %>">
|
15
|
+
<%= value %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<!-- Started the listing records div -->
|
20
|
+
<div id='records' class="news">
|
21
|
+
|
22
|
+
<!-- Checked if records present start the listing -->
|
23
|
+
<% if @resources.any? %>
|
24
|
+
|
25
|
+
<!-- Added will_paginate for pagination in rails -->
|
26
|
+
<%= will_paginate @resources %>
|
27
|
+
|
28
|
+
<!-- Render partial for individual records displaying-->
|
29
|
+
<%= render :partial => "records" %>
|
30
|
+
|
31
|
+
<!-- Added will_paginate for pagination in rails -->
|
32
|
+
<%= will_paginate @resources %>
|
33
|
+
|
34
|
+
<% else %>
|
35
|
+
|
36
|
+
<!-- If records not present showing No items -->
|
37
|
+
<p>
|
38
|
+
<strong>
|
39
|
+
<%= 'No Items Yet' %>
|
40
|
+
</strong>
|
41
|
+
</p>
|
42
|
+
<% end %>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<br />
|
47
|
+
|
48
|
+
<!-- Rendering submenu for displaying at the right side -->
|
49
|
+
<%= render :partial => 'submenu' %>
|
50
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/images/new.html.erb
|
3
|
+
@Use: This is a partial html page for form of creating and saving an image
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<h1>New Image</h1>
|
9
|
+
|
10
|
+
<!-- Render form for taking inputs -->
|
11
|
+
<%= render 'form' %>
|
12
|
+
|
13
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/admin/resources/show.html.erb
|
3
|
+
@Use: This is a partial html page for show an image
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
<!-- Added notice flash messages -->
|
9
|
+
<p id="notice"><%= notice %></p>
|
10
|
+
|
11
|
+
<div>
|
12
|
+
<%= image_tag @resource.image.url(:large) %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<!-- links added to edit or getting back to lists -->
|
16
|
+
<div>
|
17
|
+
<%= link_to 'Edit', edit_admin_resource_path(@resource) %> |
|
18
|
+
<%= link_to 'Back', admin_resources_path %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/shared/admin/_error_messages.html.erb
|
3
|
+
@Use: This is a partial html page for showing validation error messages with the rails error object
|
4
|
+
@Created date: 24-07-2012
|
5
|
+
@Modified Date: 24-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!-- Added checking of error object -->
|
10
|
+
<% if object.errors.any? %>
|
11
|
+
<div class="error-explanation" id="error-explanation">
|
12
|
+
<p><%= t('.problems_in_following_fields') %>:</p>
|
13
|
+
<ul>
|
14
|
+
<% unless defined?(include_object_name) and include_object_name %>
|
15
|
+
<% object.errors.each do |key, value| %>
|
16
|
+
<li><%= value %></li>
|
17
|
+
<% end %>
|
18
|
+
<% else %>
|
19
|
+
|
20
|
+
<!-- Showing error object full erro messages -->
|
21
|
+
<% object.errors.full_messages.each do |value| %>
|
22
|
+
<li><%= value %></li>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!--
|
2
|
+
@Name: views/shared/admin/_form_actions.html.erb
|
3
|
+
@Use: This is a partial for common submit button
|
4
|
+
@Created date: 25-07-2012
|
5
|
+
@Modified Date: 25-07-2012
|
6
|
+
@Company: Mindfire Solutions
|
7
|
+
-->
|
8
|
+
|
9
|
+
<!-- Manipulating submit buttons texts and cancel button texts -->
|
10
|
+
<%
|
11
|
+
submit_button_text ||= t('.save')
|
12
|
+
submit_button_id ||= "submit_button"
|
13
|
+
submit_button_title ||= nil
|
14
|
+
cancel_button_text ||= t('.cancel')
|
15
|
+
cancel_title = t('.cancel_lose_changes')
|
16
|
+
cancel_button_id ||= "cancel_button"
|
17
|
+
unless f.nil?
|
18
|
+
cancel_url ||= admin_resources_path
|
19
|
+
end
|
20
|
+
%>
|
21
|
+
<div class='form-actions'>
|
22
|
+
<div class='form-actions-left'>
|
23
|
+
<%= submit_tag submit_button_text,
|
24
|
+
:id => submit_button_id,
|
25
|
+
:name => nil,
|
26
|
+
:class => "wymupdate button",
|
27
|
+
:tooltip => submit_button_title %>
|
28
|
+
|
29
|
+
<%= link_to(cancel_button_text, cancel_url,
|
30
|
+
:title => cancel_title,
|
31
|
+
:id => cancel_button_id,
|
32
|
+
:class => "close_dialog button") %>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</div>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
@File Name : routes.rb
|
4
|
+
@Company Name : Mindfire Solutions Private Limited
|
5
|
+
@Date Created : 01-08-2012
|
6
|
+
@Date Modified : 01-08-2012
|
7
|
+
@Last Modification Details :
|
8
|
+
@Purpose : To redirect the pages throughout the application.
|
9
|
+
|
10
|
+
=end
|
11
|
+
Rails.application.routes.draw do
|
12
|
+
namespace :admin, :path => 'mcms' do
|
13
|
+
#root :to => 'images#index'
|
14
|
+
resources :resources do
|
15
|
+
match 'resources/new/:type', :to => 'resources#new'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
@File Name : mcms_resources_generator.rb
|
4
|
+
@Company Name : Mindfire Solutions Pvt. Ltd.
|
5
|
+
@Date Created : 01-08-2012
|
6
|
+
@Date Modified : 01-08-2012
|
7
|
+
@Last Modification Details :
|
8
|
+
@Purpose : This file is responsible to install assets and views for mcms_resources module in other application/module
|
9
|
+
|
10
|
+
=end
|
11
|
+
class McmsResourcesGenerator < Rails::Generators::NamedBase
|
12
|
+
source_root File.expand_path('../templates', __FILE__)
|
13
|
+
|
14
|
+
# @Params : None
|
15
|
+
# @Returns : None
|
16
|
+
# @Purpose : To Copy all the migrations from db/migrate of engine to db/migrate of application
|
17
|
+
def add_migrations
|
18
|
+
|
19
|
+
say "copying migrations......."
|
20
|
+
|
21
|
+
# running command line command to copy engine's migration file
|
22
|
+
rake("mcms_resources_engine:install:migrations")
|
23
|
+
|
24
|
+
end # end method
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module McmsResources
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
require 'paperclip'
|
5
|
+
require 'will_paginate'
|
6
|
+
|
7
|
+
config.autoload_paths += %W( #{config.root}/lib )
|
8
|
+
config.autoload_paths += Dir["#{config.root}/lib/**/"]
|
9
|
+
|
10
|
+
require 'yaml'
|
11
|
+
YAML::ENGINE.yamler= 'syck'
|
12
|
+
end
|
13
|
+
end
|