Commit 1a81252e authored by Martin Markech's avatar Martin Markech
Browse files

add ability to join album with page

parent 5dc1730d
## 0.0.4.dev [unreleased]
## 0.1.0.dev [21 September 2012]
* added tab to pages, enable join page with photo album
* added fragment caching for photos on frontend
* added ajaxified pagination with history.pushState for photos on frontend
* change the way how albums menu render. Now render whole menu with caching like sitemap. Do hide/show menu branch on your own with javascript.
......
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
ENGINE_PATH = File.dirname(__FILE__)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
if File.exists?(APP_RAKEFILE)
load 'rails/tasks/engine.rake'
end
require "refinerycms-testing"
Refinery::Testing::Railtie.load_tasks
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
load File.expand_path('../tasks/testing.rake', __FILE__)
load File.expand_path('../tasks/rspec.rake', __FILE__)
<%# encoding: utf-8 %>
$(function() {
$('form#form_edit_photos').on("click", ".form-photo-field .form-actions-right .confirm-delete", function() {
if ( confirm( $(this).attr('data-confirm') ) ) {
......@@ -23,6 +25,29 @@ $(function() {
}, 250);
});
$(".chzn-select").chosen();
$(".chzn-select").chosen(
{
no_results_text: "<%= I18n.t('chosen.no_results') %>"
}
);
$(".chzn-select-deselect").chosen({
no_results_text: "<%= I18n.t('chosen.no_results') %>",
allow_single_deselect:true}
);
$('#photo_gallery_wym_editation').on("click", ".form-actions .button", function() {
$.ajax({
type: "POST",
dataType: 'script',
data: { '_method': $(this).attr('data-method') },
url: this.href
});
return false;
});
});
\ No newline at end of file
......@@ -17,6 +17,7 @@ module Refinery
end
end
end
end
end
......
module Refinery
class AlbumPage < Refinery::Core::BaseModel
belongs_to Refinery::PhotoGallery::Album.table_name
belongs_to :page, :polymorphic => true
attr_accessible :page_id, :page_type, :album_id
end
end
......@@ -5,6 +5,7 @@ module Refinery
has_many :collection_albums , :dependent => :destroy
has_many :collections, :through => :collection_albums
before_validation :set_path
validates :title, :presence => true
validates :path, :presence => true, :uniqueness => true
......
<%= f.fields_for @page.album_page do |album_page_form| %>
<%= album_page_form.label :album_id, t('.join_page_with_album') %>
<%= album_page_form.grouped_collection_select( :album_id, Refinery::PhotoGallery::Collection.includes(:albums).all, :albums, :title, :id, :title,
{ :include_blank => true},
{ :data => {
:placeholder=> t('.choose_album')},
:multiple=> false,
:class=> "chzn-select-deselect",
:style=>"min-width: 300px;"
}) %>
<% end %>
<div class='wym_skin_refinery page_part'>
<%= render '/refinery/admin/pages/tabs/photo_pages_bar' %>
<div id="photo_gallery_wym_editation" class='wym_box field ' style="height: 300px;">
<% if @page.album_page.nil?
@page.build_album_page
end %>
<%= render "/refinery/admin/pages/tabs/form", :f => f %>
</div>
</div>
\ No newline at end of file
<div >
<span class='clearfix label_inline_with_link'></span>
</div>
<div class='wym_skin_refinery page_part'>
</div>
\ No newline at end of file
en:
chosen:
no_results: "No results matched"
refinery:
admin:
pages:
tabs:
form:
join_page_with_album: "Join page with album:"
choose_album: "Click to choose photo album"
flash:
connection_destroyed: "Connection between album and page was successfully deleted."
plugins:
refinerycms_photo_gallery:
title: Photo Gallery
description: Provides advanced photo gallery
tab_name: Photo Gallery
photo_gallery:
albums:
show:
no_photos: There are no photos in this album yet
photos:
image: Image
collections:
show:
no_albums: There are no albums in this collection yet
index:
no_collections: There are no collections yet
admin:
submenu:
collections:
......@@ -28,24 +28,26 @@ en:
new: Create new album
collections:
collection:
view_live_html: 'View this collection live <br/><em>(opens in a new window)</em>'
view_live_html: View this collection live <br/><em>(opens in a new window)</em>
delete: Remove this collection forever
edit: Edit this collection
index:
no_items_yet: 'There are no collections yet. Click "%{create}" to add your first collection.'
no_items_yet: There are no collections yet. Click "%{create}" to add your
first collection.
new:
title: Create new collection
edit:
title: Edit collection
albums:
album:
view_live_html: 'View this album live <br/><em>(opens in a new window)</em>'
view_live_html: View this album live <br/><em>(opens in a new window)</em>
delete: Remove this album forever
edit: Edit this album
upload_photos: Upload new photos to album
edit_photos: Edit photos in album
index:
no_items_yet: 'There are no albums yet. Click "%{create}" to add your first album.'
no_items_yet: There are no albums yet. Click "%{create}" to add your first
album.
new:
title: Create new album
edit:
......@@ -53,7 +55,8 @@ en:
form:
album_belongs_to_collection: Album belongs to collection(s)
more_options: More options
more_options_tooltip: Enable edit more fields like adress, latitude, longitude, note
more_options_tooltip: Enable edit more fields like adress, latitude, longitude,
note
choose_collection: Choose collection(s)
path_prefix: Path prefix
number_of_photos: Contains %{number} photos
......@@ -63,19 +66,30 @@ en:
manage: Manage
new: Upload new photos
edit_multiple:
no_photos_yet: There are no photos in album yet. Click "%{create} to add your first photos to album.'
no_photos_yet: There are no photos in album yet. Click "%{create} to add
your first photos to album.'
photo:
delete: Remove this photo forever
deleted: Deleted photo "%{title}"
form_fields:
use_decimal_format: Use decimal format
photo_pages:
show:
other: Other Photo Pages
albums:
show:
no_photos: There are no photos in this album yet
photos:
image: Image
collections:
show:
no_albums: There are no albums in this collection yet
index:
no_collections: There are no collections yet
activerecord:
models:
refinery/photo_gallery/collection: Collection
refinery/photo_gallery/collection: Album
attributes:
refinery/photo_gallery/photo_page:
page_id: Page
refinery/photo_gallery/collection:
title: Title
description: Description
......@@ -83,15 +97,17 @@ en:
title: Title
description: Description
longitude: Longitude
latitude: Latitude
latitude: Latitude
path: Path
adress: Adress
note: Note
tags: Tags
refinery/photo_gallery/photo:
title: Title
description: Description
longitude: Longitude
latitude: Latitude
path: Path
file: File
title: Title
description: Description
longitude: Longitude
latitude: Latitude
path: Path
file: File
models:
refinery/photo_gallery/collection: Album
sk:
chosen:
no_results: "Žiadne výsledky pre zadané kritériá"
refinery:
admin:
pages:
tabs:
form:
join_page_with_album: "K stránke pripojiť fotoalbum"
choose_album: "Kliknite pre výber fotoalbumu"
flash:
connection_destroyed: "Prepojenie albumu so stránkou bolo zmazané"
plugins:
refinerycms_photo_gallery:
title: Fotogaléria
description: Poskytuje fotogalériu
tab_name: Fotogaléria
photo_gallery:
albums:
show:
no_photos: V albume sa zatiaľ nenachádzajú žiadne fotografie
photos:
image: Obrázok
collections:
show:
no_albums: V tejto skupine albumov sa zatiať nenachádza žiadny album
index:
no_collections: Zatiaľ neboli vytvorené žiadne skupiny albumov
admin:
submenu:
collections:
......@@ -28,24 +28,27 @@ sk:
new: Vytvoriť nový albun
collections:
collection:
view_live_html: 'Pozrieť náhľad skupiny albumov<br/><em>(otvorí sa v novom okne)</em>'
view_live_html: Pozrieť náhľad skupiny albumov<br/><em>(otvorí sa v novom
okne)</em>
delete: Zmazať skupinu albumov
edit: Upraviť skupinu albumov
index:
no_items_yet: 'Zatiaľ neboli vytvorené žiadne skupiny albumov. Klikni "%{create}" pre vytvorenie prvej.'
no_items_yet: Zatiaľ neboli vytvorené žiadne skupiny albumov. Klikni "%{create}"
pre vytvorenie prvej.
new:
title: Vytvoriť novú skupinu albumov
edit:
title: Upraviť skupinu albumov
albums:
album:
view_live_html: 'Zobraziť náhľad albumu <br/><em>(otvorí sa v novom okne)</em>'
view_live_html: Zobraziť náhľad albumu <br/><em>(otvorí sa v novom okne)</em>
delete: Zmazať album
edit: Upraviť album
upload_photos: Nahrať fotografie do albumu
edit_photos: Upraviť fotografie v albume
index:
no_items_yet: 'Zatiaľ neboli vytvorené žiadne albumy. Klikni "%{create}" pre vytvorenie prvého.'
no_items_yet: Zatiaľ neboli vytvorené žiadne albumy. Klikni "%{create}"
pre vytvorenie prvého.
new:
title: Vytvoriť nový album
edit:
......@@ -53,28 +56,41 @@ sk:
form:
album_belongs_to_collection: Album patrí do skupiny albumov
more_options: Rozšírené nastavenia
more_options_tooltip: Umožní upraviť ďalšie polia ako adresa, zemepisná dĺžka/šírka, poznámka
more_options_tooltip: Umožní upraviť ďalšie polia ako adresa, zemepisná
dĺžka/šírka, poznámka
choose_collection: Vyber skupiny albumov
path_prefix: Prefix priečinka
number_of_photos: 'Obsahuje fotografií: %{number}'
number_of_photos: ! 'Obsahuje fotografií: %{number}'
photos:
updated: Fotografie upravené
title: Fotografie
manage: Spravovať
new: Nahrať nové fotografie
edit_multiple:
no_photos_yet: Zatiaľ neboli nahrané žiadne fotografie. Klikni "%{create}" pre pridanie prvých.
no_photos_yet: Zatiaľ neboli nahrané žiadne fotografie. Klikni "%{create}"
pre pridanie prvých.
photo:
delete: Zmazať fotografiu
deleted: Fotografia "%{title}" zmazaná
form_fields:
use_decimal_format: Použi decimálny zápis
photo_pages:
show:
other: Daľšie Photo Pages
albums:
show:
no_photos: V albume sa zatiaľ nenachádzajú žiadne fotografie
photos:
image: Obrázok
collections:
show:
no_albums: V tejto skupine albumov sa zatiať nenachádza žiadny album
index:
no_collections: Zatiaľ neboli vytvorené žiadne skupiny albumov
activerecord:
models:
refinery/photo_gallery/collection: Skupina albumov
refinery/photo_gallery/collection: Album
attributes:
refinery/photo_gallery/photo_page:
page_id: Page
refinery/photo_gallery/collection:
title: Názov
description: Popis
......@@ -82,15 +98,17 @@ sk:
title: Názov
description: Popis
longitude: Zemepisná dĺžka
latitude: Zemepisná šírka
latitude: Zemepisná šírka
path: Názov priečinku
adress: Adresa
note: Poznámka
tags: Tagy
refinery/photo_gallery/photo:
title: Názov
description: Popis
longitude: Zemepisná dĺžka
latitude: Zemepisná šírka
path: Názov priečinku
file: Súbor
title: Názov
description: Popis
longitude: Zemepisná dĺžka
latitude: Zemepisná šírka
path: Názov priečinku
file: Súbor
models:
refinery/photo_gallery/collection: Album
......@@ -36,4 +36,21 @@ Refinery::Core::Engine.routes.draw do
end
end
end
# Frontend routes
namespace :photo_gallery do
resources :photo_pages, :only => [:index, :show]
end
# Admin routes
namespace :photo_gallery, :path => '' do
namespace :admin, :path => 'refinery/photo_gallery' do
resources :photo_pages, :except => :show do
collection do
post :update_positions
end
end
end
end
end
class CreateAlbumPages < ActiveRecord::Migration
def up
create_table :refinery_album_pages do |t|
t.integer :album_id
t.integer :page_id
t.string :page_type, :default => "Refinery::Page"
end
add_index :refinery_album_pages, :album_id
add_index :refinery_album_pages, :page_id
end
def down
drop_table :refinery_album_pages
end
end
......@@ -6,9 +6,6 @@ module Refinery
autoload :PhotoGalleryGenerator, 'generators/refinery/photo_gallery_generator'
module PhotoGallery
require 'refinery/photo_gallery/engine'
require 'refinery/photo_gallery/configuration'
autoload :Version, 'refinery/photo_gallery/version'
class << self
......@@ -26,5 +23,10 @@ module Refinery
@factory_paths ||= [ root.join("spec/factories").to_s ]
end
end
require 'refinery/photo_gallery/engine'
require 'refinery/photo_gallery/configuration'
require 'refinery/photo_gallery/extensions/pages_extension'
require 'refinery/photo_gallery/extensions/pages_helper_extension'
end
end
\ No newline at end of file
......@@ -4,6 +4,7 @@ module Refinery
include Refinery::Engine
isolate_namespace Refinery::PhotoGallery
engine_name :refinery_photo_gallery
def self.register(tab)
tab.name = tab.name = ::I18n.t(:'refinery.plugins.refinerycms_photo_gallery.tab_name')
......@@ -20,6 +21,11 @@ module Refinery
end
end
config.to_prepare do
require 'refinerycms-pages'
Refinery::Page.send :has_one_page_album
end
config.before_initialize do
require 'carrierwave'
require 'carrierwave/orm/activerecord'
......@@ -28,6 +34,7 @@ module Refinery
require 'mini_exiftool'
end
config.after_initialize do
Refinery::Pages::Tab.register do |tab|
register tab
......@@ -35,8 +42,6 @@ module Refinery
Refinery.register_engine(Refinery::PhotoGallery)
end
end
end
end
module Refinery
module PhotoGallery
module Extensions
module Pages
def has_one_page_album
has_one :album_page, :as => :page
accepts_nested_attributes_for :album_page
module_eval do
def album_page=(album_page_params)
# new
if self.album_page.nil?
self.build_album_page
end
# destroy
if album_page_params[:album_id].blank?
self.album_page.destroy
# create or update if changed
elsif self.album_page.album_id.to_s != album_page_params[:album_id]
self.album_page.update_attributes( album_page_params)
self.album_page.save
end
end
end
attr_accessible :album_page
end
end
end
end
end
ActiveRecord::Base.send(:extend, Refinery::PhotoGallery::Extensions::Pages)
\ No newline at end of file
module Refinery
module PhotoGallery
module Extensions
module PagesHelper
def self.included(base)
base.class_eval do
# TODO put here code from view.
# Before, fix this helper to work
end
end
end
end
end
end
\ No newline at end of file
......@@ -2,8 +2,8 @@ module Refinery
module PhotoGallery
class Version
@major = 0
@minor = 0
@tiny = '3.dev'
@minor = 1
@tiny = '0'
class << self
attr_reader :major, :minor, :tiny
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment