From 2c0058e8c924224a70883206576538738709290c Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Sat, 11 Aug 2012 17:28:49 +0800 Subject: [PATCH] authorization --- app/assets/javascripts/rss.js | 3 + app/views/layouts/_side_bar.html.erb | 2 +- .../app/assets/javascripts/galleryAPI.js.erb | 46 +++++-- .../back_end/orbit_galleries_controller.rb | 58 ++++++-- .../back_end/gallery_categories_helper.rb | 16 +++ .../gallery/app/models/gallery_category.rb | 9 ++ .../orbit_galleries/categorylist.html.erb | 128 ++++++++++++------ .../back_end/orbit_galleries/index.html.erb | 26 ++-- .../gallery/config/locales/en.yml | 3 + 9 files changed, 217 insertions(+), 74 deletions(-) create mode 100644 vendor/built_in_modules/gallery/app/helpers/panel/gallery/back_end/gallery_categories_helper.rb diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index a82d86fab..b7e67fcb7 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -346,6 +346,9 @@ getUrlVars : function(){ vars.push(hash[0]); vars[hash[0]] = hash[1]; } + if(vars[0] == window.location.href){ + vars =[]; + } return vars; }, /*function to open a modalwindow on a page.. self reliant no images, no css needed. diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index a3a008d3c..c6b5cf5c0 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -67,7 +67,7 @@ <% end -%> <% end -%> -<%= content_tag :li, :class => active_for_controllers('orbit_galleries','tags') do -%> +<%= content_tag :li, :class => active_for_controllers('orbit_galleries','/panel/gallery/back_end/tags') || active_for_app_auth("orbit_gallery") do -%> <%= link_to content_tag(:i, nil, :class => 'icons-picture') + t('admin.orbit_gallery'), panel_gallery_back_end_orbit_gallery_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('orbit_galleries') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb index 06c8069a4..2d96ad4e9 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb @@ -4,6 +4,7 @@ var galleryAPI = function(){ this.urlVars = rcom.getUrlVars(); this.albumArea = $("#orbit_gallery"); this.loadArea = ""; + // this.authenticated = false; this.initialize = function(){ $(document).ready(function(){ bindHandlers(); @@ -19,6 +20,9 @@ var galleryAPI = function(){ }else if(typeof g.urlVars['edit']!= "undefined"){ g.editAlbum(g.urlVars['edit']); g.loadArea = "edit"; + }else if(typeof g.urlVars['tag']!= "undefined"){ + g.loadAlbums(g.urlVars['tag']); + g.loadArea = "albums"; }else{ g.loadAlbums("all"); g.loadArea = "albums"; @@ -28,7 +32,7 @@ var galleryAPI = function(){ $("#filter .filter_btns a").click(function(){ if(!$(this).hasClass("active")){ $(this).addClass("active"); - if(typeof g.urlVars['cat'] == "undefined") + if(g.urlVars.length == 0) window.location = "orbit_gallery?" + $(this).attr("href"); else window.location = window.location.href +"&"+ $(this).attr("href"); @@ -45,6 +49,22 @@ var galleryAPI = function(){ } }) } + $("#filter .filter-clear a").click(function(){ + var loc = window.location.href; + var url = null; + var forwhat = $(this).attr("for"); + $("#filter ."+forwhat+" a.active").each(function(){ + $(this).removeClass("active"); + url = loc.replace($(this).attr("href")+"&",""); + if(url == loc) + url = loc.replace($(this).attr("href"),""); + + if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") + url = url.substr(0,url.length-1); + loc = url; + }) + window.location = url; + }) } this.makeNewAlbum = function(){ $.get("add_album",function(html){ @@ -91,19 +111,29 @@ var galleryAPI = function(){ g.albumArea.find("#imgholder").empty(); var $addsign = $('
Add Album
'); $addsign.find("a").click(function(){g.makeNewAlbum();}) + if(id!="all"){ - var ids = []; + var cids = []; + var tids = []; + var href = null; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++){ hash = hashes[i].split('='); - ids.push(hash[1]); - var href = "cat="+hash[1]; + if(hash[0]=="cat"){ + cids.push(hash[1]); + href = "cat="+hash[1]; + }else if(hash[0]=="tag"){ + tids.push(hash[1]); + href = "tag="+hash[1]; + } $("#filter .filter_btns a[href='"+href+"']").addClass("active"); } + if(cids.length == 0) + cids = "all"; }else{ - var ids = "all"; + var cids = "all"; } - $.getJSON("get_albums",{cid:ids},function(categories){ + $.getJSON("get_albums",{cid:cids,tid:tids},function(categories){ $.each(categories,function(x,category){ $.each(category,function(i,album){ if(album.cover == "default") @@ -117,7 +147,6 @@ var galleryAPI = function(){ }) } this.loadImages = function(id){ - //