diff --git a/Gemfile b/Gemfile index 4873ae0..dbf24ea 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,14 @@ gem 'bson_ext' gem 'mongoid_slug', github: 'digitalplaywright/mongoid-slug' gem 'carrierwave' gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' +gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs' +gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', + :github => 'anjlab/bootstrap-rails', + :branch => '3.0.0' + +gem "font-awesome-rails", github: "bokmann/font-awesome-rails" +gem 'rmagick' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index cd0ee63..88d7ae7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,27 @@ +GIT + remote: git://github.com/ahoward/mongoid-grid_fs.git + revision: 059012a2c2a9e0a5d6e67137752c3e918689c88a + specs: + mongoid-grid_fs (1.9.0) + mime-types (~> 1.19) + mongoid (>= 3.0, < 5.0) + +GIT + remote: git://github.com/anjlab/bootstrap-rails.git + revision: addb7143365f97f938e3bdbb2ccfc52591230eda + branch: 3.0.0 + specs: + anjlab-bootstrap-rails (3.0.0.rc2) + railties (>= 3.0) + sass (>= 3.2) + +GIT + remote: git://github.com/bokmann/font-awesome-rails.git + revision: 24ad375ed3db511c84310085889b2cbf0f650420 + specs: + font-awesome-rails (4.0.3.0) + railties (>= 3.2, < 5.0) + GIT remote: git://github.com/digitalplaywright/mongoid-slug.git revision: fb929a5d5b2a580fed367c6cd25772ce9e92e80a @@ -108,6 +132,7 @@ GEM rake (10.1.1) rdoc (3.12.2) json (~> 1.4) + rmagick (2.13.2) sass (3.2.13) sass-rails (4.0.1) railties (>= 4.0.0, < 5.0) @@ -144,16 +169,20 @@ PLATFORMS ruby DEPENDENCIES + anjlab-bootstrap-rails! bson_ext carrierwave carrierwave-mongoid coffee-rails (~> 4.0.0) + font-awesome-rails! jbuilder (~> 1.2) jquery-rails mongoid! + mongoid-grid_fs! mongoid_slug! puma rails (= 4.0.2) + rmagick sass-rails (~> 4.0.0) sdoc turbolinks diff --git a/app/assets/images/orbit-logo.png b/app/assets/images/orbit-logo.png new file mode 100644 index 0000000..5083d81 Binary files /dev/null and b/app/assets/images/orbit-logo.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d6925fa..3885622 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,5 +12,6 @@ // //= require jquery //= require jquery_ujs +//= require twitter/bootstrap //= require turbolinks //= require_tree . diff --git a/app/assets/javascripts/extensions.js.coffee b/app/assets/javascripts/extensions.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/extensions.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3192ec8..f2ea9a9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -9,5 +9,7 @@ * compiled file, but it's generally better to create a new file per style scope. * *= require_self + *= require twitter/bootstrap + *= require sticky-footer-navbar *= require_tree . */ diff --git a/app/assets/stylesheets/extensions.css.scss b/app/assets/stylesheets/extensions.css.scss new file mode 100644 index 0000000..996db48 --- /dev/null +++ b/app/assets/stylesheets/extensions.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the extensions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sticky-footer-navbar.css b/app/assets/stylesheets/sticky-footer-navbar.css new file mode 100644 index 0000000..6978a99 --- /dev/null +++ b/app/assets/stylesheets/sticky-footer-navbar.css @@ -0,0 +1,46 @@ +/* Sticky footer styles +-------------------------------------------------- */ + +html, +body { + height: 100%; + /* The html and body elements cannot have any padding or margin. */ +} + +/* Wrapper for page content to push down footer */ +#wrap { + min-height: 100%; + height: auto !important; + height: 100%; + /* Negative indent footer by its height */ + margin: 0 auto -60px; + /* Pad bottom by footer height */ + padding: 0 0 60px; +} + +/* Set the fixed height of the footer here */ +#footer { + height: 60px; + background-color: #f5f5f5; +} + + +/* Custom page CSS +-------------------------------------------------- */ +/* Not required for template or sticky footer method. */ + +#wrap > .container { + padding: 60px 15px 0; +} +.container .credit { + margin: 20px 0; +} + +#footer > .container { + padding-left: 15px; + padding-right: 15px; +} + +code { + font-size: 80%; +} \ No newline at end of file diff --git a/app/controllers/api/v1/extensions_controller.rb b/app/controllers/api/v1/extensions_controller.rb new file mode 100644 index 0000000..736e434 --- /dev/null +++ b/app/controllers/api/v1/extensions_controller.rb @@ -0,0 +1,15 @@ +module Api + module V1 + class ExtensionsController < ApplicationController + respond_to :json + + def index + respond_with Extension.all + end + + def show + respond_with Extension.find(params[:id]) + end + end + end +end diff --git a/app/controllers/api/v1/templates_controller.rb b/app/controllers/api/v1/templates_controller.rb index a4875de..4c72edd 100644 --- a/app/controllers/api/v1/templates_controller.rb +++ b/app/controllers/api/v1/templates_controller.rb @@ -1,74 +1,15 @@ -class TemplatesController < ApplicationController - before_action :set_template, only: [:show, :edit, :update, :destroy] +module Api + module V1 + class TemplatesController < ApplicationController + respond_to :json - # GET /templates - # GET /templates.json - def index - @templates = Template.all - end + def index + respond_with Template.all + end - # GET /templates/1 - # GET /templates/1.json - def show - end - - # GET /templates/new - def new - @template = Template.new - end - - # GET /templates/1/edit - def edit - end - - # POST /templates - # POST /templates.json - def create - @template = Template.new(template_params) - - respond_to do |format| - if @template.save - format.html { redirect_to @template, notice: 'Template was successfully created.' } - format.json { render action: 'show', status: :created, location: @template } - else - format.html { render action: 'new' } - format.json { render json: @template.errors, status: :unprocessable_entity } + def show + respond_with Template.find(params[:id]) end end end - - # PATCH/PUT /templates/1 - # PATCH/PUT /templates/1.json - def update - respond_to do |format| - if @template.update(template_params) - format.html { redirect_to @template, notice: 'Template was successfully updated.' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @template.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /templates/1 - # DELETE /templates/1.json - def destroy - @template.destroy - respond_to do |format| - format.html { redirect_to templates_url } - format.json { head :no_content } - end - end - - private - # Use callbacks to share common setup or constraints between actions. - def set_template - @template = Template.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def template_params - params.require(:template).permit(:title, :author) - end end diff --git a/app/controllers/extensions_controller.rb b/app/controllers/extensions_controller.rb new file mode 100644 index 0000000..d51d301 --- /dev/null +++ b/app/controllers/extensions_controller.rb @@ -0,0 +1,74 @@ +class ExtensionsController < ApplicationController + before_action :set_extension, only: [:show, :edit, :update, :destroy] + + # GET /extensions + # GET /extensions.json + def index + @extensions = Extension.all + end + + # GET /extensions/1 + # GET /extensions/1.json + def show + end + + # GET /extensions/new + def new + @extension = Extension.new + end + + # GET /extensions/1/edit + def edit + end + + # POST /extensions + # POST /extensions.json + def create + @extension = Extension.new(extension_params) + + respond_to do |format| + if @extension.save + format.html { redirect_to @extension, notice: 'Extension was successfully created.' } + format.json { render action: 'show', status: :created, location: @extension } + else + format.html { render action: 'new' } + format.json { render json: @extension.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /extensions/1 + # PATCH/PUT /extensions/1.json + def update + respond_to do |format| + if @extension.update(extension_params) + format.html { redirect_to @extension, notice: 'Extension was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @extension.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /extensions/1 + # DELETE /extensions/1.json + def destroy + @extension.destroy + respond_to do |format| + format.html { redirect_to extensions_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_extension + @extension = Extension.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def extension_params + params.require(:extension).permit(:title, :author, :preview, :preview_cache, :extension, :extension_cache) + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f2992..9cf010c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,6 @@ class HomeController < ApplicationController def index + @templates = Template.desc(:created_at).limit(3) + @extensions = Extension.desc(:created_at).limit(3) end end diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index a4875de..3093a6c 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -69,6 +69,6 @@ class TemplatesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def template_params - params.require(:template).permit(:title, :author) + params.require(:template).permit(:title, :author,:preview, :preview_cache, :template, :template_cache) end end diff --git a/app/helpers/extensions_helper.rb b/app/helpers/extensions_helper.rb new file mode 100644 index 0000000..383b12c --- /dev/null +++ b/app/helpers/extensions_helper.rb @@ -0,0 +1,2 @@ +module ExtensionsHelper +end diff --git a/app/models/extension.rb b/app/models/extension.rb new file mode 100644 index 0000000..0fd5dd6 --- /dev/null +++ b/app/models/extension.rb @@ -0,0 +1,15 @@ +class Extension + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::Slug + + field :title, type: String + field :author, type: String + field :preview, type: String + field :extension, type: String + field :description, type: String + slug :title, history: true + + mount_uploader :preview, ImageUploader + mount_uploader :extension, ProductUploader +end diff --git a/app/models/template.rb b/app/models/template.rb index 7ff7020..d1c993e 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,11 +1,14 @@ class Template include Mongoid::Document include Mongoid::Timestamps + include Mongoid::Slug field :title, type: String field :author, type: String + field :preview, type: String + field :template, type: String + slug :title, history: true mount_uploader :preview, ImageUploader mount_uploader :template, ProductUploader - end diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index e8e12b7..b21ba97 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -3,7 +3,7 @@ class ImageUploader < CarrierWave::Uploader::Base # Include RMagick or MiniMagick support: - # include CarrierWave::RMagick + include CarrierWave::RMagick # include CarrierWave::MiniMagick # Choose what kind of storage to use for this uploader: @@ -32,9 +32,9 @@ class ImageUploader < CarrierWave::Uploader::Base # end # Create different versions of your uploaded files: - # version :thumb do - # process :scale => [50, 50] - # end + version :thumb do + process :resize_to_fit => [300, 300] + end # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: diff --git a/app/views/extensions/_form.html.erb b/app/views/extensions/_form.html.erb new file mode 100644 index 0000000..1d0b1ef --- /dev/null +++ b/app/views/extensions/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_for(@extension) do |f| %> + <% if @extension.errors.any? %> +
+ + <%= f.file_field :extension %> + <%= f.hidden_field :extension_cache %> +
+ +Author: <%= extension.author %>
+<%=image_tag extension.preview.thumb.url%>
+<%=link_to 'Download', extension.extension.url, :class=> 'btn btn-success'%>
+<%= link_to 'View details »'.html_safe ,extension, :class=>"btn btn-primary"%>
+<%= notice %>
+ ++ Title: + <%= @extension.title %> +
+ ++ Author: + <%= @extension.author %> +
+ +<%= link_to 'Edit', edit_extension_path(@extension) %> | +<%= link_to 'Back', extensions_path %> diff --git a/app/views/extensions/show.json.jbuilder b/app/views/extensions/show.json.jbuilder new file mode 100644 index 0000000..b6032ff --- /dev/null +++ b/app/views/extensions/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @extension, :id, :title, :author, :created_at, :updated_at diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 2085730..c49580a 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,2 +1,25 @@ -Find me in app/views/home/index.html.erb
+Author: <%= template.author %>
+<%=image_tag template.preview.thumb.url%>
+<%= link_to 'View details »'.html_safe ,template, :class=>"btn btn-primary"%>
+Author: <%= extension.author %>
+<%=image_tag extension.preview.thumb.url%>
+<%= link_to 'View details »'.html_safe ,extension, :class=>"btn btn-primary"%>
+- + <%= f.file_field :template %> <%= f.hidden_field :template_cache %>
+Title | -Author | -- | - | - |
---|---|---|---|---|
<%= template.title %> | -<%= template.author %> | -<%= link_to 'Show', template %> | -<%= link_to 'Edit', edit_template_path(template) %> | -<%= link_to 'Destroy', template, method: :delete, data: { confirm: 'Are you sure?' } %> | -
Author: <%= template.author %>
+<%=image_tag template.preview.thumb.url%>
+<%=link_to 'Download', template.template.url, :class=> 'btn btn-success'%>
+<%= link_to 'View details »'.html_safe ,template, :class=>"btn btn-primary"%>
+