-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
433 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class ImagesController < ApplicationController | ||
|
||
def index | ||
@images = Image.all | ||
end | ||
|
||
def create | ||
@upload = Image.new(params[:uploads]) | ||
|
||
respond_to do |format| | ||
if @upload.save | ||
format.html { redirect_to upload_path(@upload), notice: 'Upload Lykkedes.' } | ||
format.json { render action: 'show', status: :created, location: @upload } | ||
else | ||
format.html { render action: 'new' } | ||
format.json { render json: @upload.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class UploadSectionsController < ApplicationController | ||
before_action :set_upload_section, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /upload_sections | ||
# GET /upload_sections.json | ||
def index | ||
@upload_sections = UploadSection.all | ||
end | ||
|
||
# GET /upload_sections/1 | ||
# GET /upload_sections/1.json | ||
def show | ||
end | ||
|
||
# GET /upload_sections/new | ||
def new | ||
@upload_section = UploadSection.new | ||
end | ||
|
||
# GET /upload_sections/1/edit | ||
def edit | ||
end | ||
|
||
# POST /upload_sections | ||
# POST /upload_sections.json | ||
def create | ||
@upload_section = UploadSection.new(upload_section_params) | ||
|
||
respond_to do |format| | ||
if @upload_section.save | ||
format.html { redirect_to @upload_section, notice: 'Upload section was successfully created.' } | ||
format.json { render action: 'show', status: :created, location: @upload_section } | ||
else | ||
format.html { render action: 'new' } | ||
format.json { render json: @upload_section.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /upload_sections/1 | ||
# PATCH/PUT /upload_sections/1.json | ||
def update | ||
respond_to do |format| | ||
if @upload_section.update(upload_section_params) | ||
format.html { redirect_to @upload_section, notice: 'Upload section was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: 'edit' } | ||
format.json { render json: @upload_section.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /upload_sections/1 | ||
# DELETE /upload_sections/1.json | ||
def destroy | ||
@upload_section.destroy | ||
respond_to do |format| | ||
format.html { redirect_to upload_sections_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_upload_section | ||
@upload_section = UploadSection.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def upload_section_params | ||
params.require(:upload_section).permit(:section_id, :upload_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Image < ActiveRecord::Base | ||
self.table_name = 'uploads' | ||
has_many :sections, through: :upload_sections | ||
|
||
attr_accessible :title, :size, :filetype, :file | ||
mount_uploader :file, ImageUploader | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class Section < ActiveRecord::Base | ||
|
||
has_many :users, through: :user_sections | ||
has_many :uploads, through: :upload_sections | ||
belongs_to :page | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
class Upload < ActiveRecord::Base | ||
|
||
has_many :sections, through: :upload_sections | ||
|
||
attr_accessible :title, :size, :filetype, :file | ||
mount_uploader :file, UploadUploader | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class ImageUploader < CarrierWave::Uploader::Base | ||
require 'carrierwave/processing/mini_magick' | ||
include CarrierWave::MiniMagick | ||
|
||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility: | ||
# include Sprockets::Helpers::RailsHelper | ||
# include Sprockets::Helpers::IsolatedHelper | ||
|
||
# Choose what kind of storage to use for this uploader: | ||
storage :file | ||
# storage :fog | ||
|
||
# Override the directory where uploaded files will be stored. | ||
# This is a sensible default for uploaders that are meant to be mounted: | ||
def store_dir | ||
"uploads/upload/#{mounted_as}/#{model.id}" | ||
end | ||
|
||
# Provide a default URL as a default if there hasn't been a file uploaded: | ||
# def default_url | ||
# # For Rails 3.1+ asset pipeline compatibility: | ||
# # asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) | ||
# | ||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_') | ||
# end | ||
|
||
# Process files as they are uploaded: | ||
# process :scale => [200, 300] | ||
# | ||
# def scale(width, height) | ||
# # do something | ||
# end | ||
|
||
# Create different versions of your uploaded files: | ||
version :thumb do | ||
process :resize_to_fill => [75, 75] | ||
end | ||
|
||
version :small do | ||
process :resize_to_limit => [100, 100] | ||
end | ||
|
||
version :medium do | ||
process :resize_to_limit => [300, 300] | ||
end | ||
|
||
version :large do | ||
process :resize_to_limit => [800, 600] | ||
end | ||
|
||
version :gallery do | ||
process :resize_to_fill => [972, 350] | ||
end | ||
# Add a white list of extensions which are allowed to be uploaded. | ||
# For images you might use something like this: | ||
def extension_white_list | ||
%w(jpg jpeg gif png) | ||
end | ||
|
||
# Override the filename of the uploaded files: | ||
# Avoid using model.id or version_name here, see uploader/store.rb for details. | ||
# def filename | ||
# "something.jpg" if original_filename | ||
# end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class UploadUploader < CarrierWave::Uploader::Base | ||
|
||
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility: | ||
# include Sprockets::Helpers::RailsHelper | ||
# include Sprockets::Helpers::IsolatedHelper | ||
|
||
# Choose what kind of storage to use for this uploader: | ||
storage :file | ||
# storage :fog | ||
|
||
# Override the directory where uploaded files will be stored. | ||
# This is a sensible default for uploaders that are meant to be mounted: | ||
def store_dir | ||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" | ||
end | ||
|
||
# Provide a default URL as a default if there hasn't been a file uploaded: | ||
# def default_url | ||
# # For Rails 3.1+ asset pipeline compatibility: | ||
# # asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) | ||
# | ||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_') | ||
# end | ||
|
||
# Process files as they are uploaded: | ||
# process :scale => [200, 300] | ||
# | ||
# def scale(width, height) | ||
# # do something | ||
# end | ||
|
||
# Add a white list of extensions which are allowed to be uploaded. | ||
# For images you might use something like this: | ||
def extension_white_list | ||
%w(doc docx xlsx odt pdf) | ||
end | ||
|
||
# Override the filename of the uploaded files: | ||
# Avoid using model.id or version_name here, see uploader/store.rb for details. | ||
# def filename | ||
# "something.jpg" if original_filename | ||
# end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
%h1 | ||
Velkommen til | ||
= @setting.name | ||
%section | ||
%article | ||
= raw @setting.info | ||
|
||
- if current_user.admin? | ||
.row | ||
.col-xs-4 | ||
= link_to 'Redigér', edit_setting_path(1), class: 'btn btn-primary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,42 @@ | ||
= form_for @setting do |f| | ||
= simple_form_for @setting do |f| | ||
- if @setting.errors.any? | ||
#error_explanation | ||
%h2= "#{pluralize(@setting.errors.count, "error")} prohibited this setting from being saved:" | ||
%ul | ||
- @setting.errors.full_messages.each do |msg| | ||
%li= msg | ||
|
||
.field | ||
= f.label :domain | ||
= f.text_field :domain | ||
.field | ||
= f.label :name | ||
= f.text_field :name | ||
.field | ||
= f.label :login | ||
= f.number_field :login | ||
.field | ||
= f.label :footer | ||
= f.number_field :footer | ||
.field | ||
= f.label :info | ||
= f.text_area :info | ||
.field | ||
= f.label :analytics_api | ||
= f.text_field :analytics_api | ||
.field | ||
= f.label :facebook | ||
= f.text_field :facebook | ||
.field | ||
= f.label :googleplus | ||
= f.text_field :googleplus | ||
.field | ||
= f.label :linkedin | ||
= f.text_field :linkedin | ||
.actions | ||
= f.submit 'Save' | ||
.row | ||
.form-group | ||
.col-xs-6 | ||
= f.input :domain, label: 'Domæne', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.col-xs-6 | ||
= f.input :name, label: 'Navn', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.row | ||
.form-group | ||
.col-xs-6 | ||
= f.input :login, label: 'Aktivér login', as: :boolean, input_html: {class: 'form-control'} | ||
.col-xs-6 | ||
= f.input :footer, label: 'Aktivér footer', as: :boolean, input_html: {class: 'form-control'} | ||
.row | ||
.form-group | ||
.col-xs-12 | ||
= f.input :info, label: 'Forside', as: :text, input_html: {size: 40, class: 'form-control'} | ||
.row | ||
.form-group | ||
.col-xs-3 | ||
= f.input :analytics_api, label: 'Google Analytics API', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.col-xs-3 | ||
= f.input :googleplus, label: 'Google+ API', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.col-xs-3 | ||
= f.input :facebook, label: 'Facebook API', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.col-xs-3 | ||
= f.input :linkedin, label: 'LinkedIn API', as: :string, input_html: {size: 40, class: 'form-control'} | ||
.row | ||
%hr | ||
.row | ||
.form-group | ||
.col-xs-12 | ||
.btn-group | ||
= submit_tag 'Gem', :class => 'btn btn-primary' | ||
= link_to 'Annuller', root_path, class: 'btn btn-default' |
Oops, something went wrong.