# HG changeset patch # User cavaliet # Date 1372352315 -7200 # Node ID d7b30914607d44166cdce4931ce4871cf108c1b4 # Parent ebb8b58fc2b860dcf0b31a7c44a6a45eeac0cc02 enhance collection and add slideshow with images and fragments. diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/models.py --- a/src/egonomy/models.py Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/models.py Thu Jun 27 18:58:35 2013 +0200 @@ -176,13 +176,15 @@ class Collection(models.Model): - SLIDESHOW = 1 + LIST = 1 MOSAIC = 2 - GEOGRAPHICAL = 3 + SLIDESHOW = 3 + GEOGRAPHICAL = 4 PUBLICATION_CHOICES = ( + (LIST, 'list'), + (MOSAIC, 'mosaic'), (SLIDESHOW, 'slideshow'), - (MOSAIC, 'mosaic'), (GEOGRAPHICAL, 'geographical') ) @@ -193,7 +195,7 @@ creation = models.DateTimeField(auto_now_add=True) modification = models.DateTimeField(auto_now=True) public = models.BooleanField(null=False, default=True) # Collection is published or not, always published by default - publication_type = models.IntegerField(choices=PUBLICATION_CHOICES, default=1) # slideshow, mosaic ou geographical + publication_type = models.IntegerField(choices=PUBLICATION_CHOICES, default=1) # list, mosaic, slideshow or geographical diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/static/egonomy/css/slideshow.css --- a/src/egonomy/static/egonomy/css/slideshow.css Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/static/egonomy/css/slideshow.css Thu Jun 27 18:58:35 2013 +0200 @@ -10,7 +10,7 @@ position: absolute; opacity: .3; -webkit-filter: blur(5px); filter: blur(5px); } -.main-image { +.image-container { position: absolute; top: 50px; right: 50px; } @@ -24,7 +24,7 @@ padding: 16px 0; margin: 0; } -.main-image, .caption { +.caption { box-shadow: 4px 4px 2px rgba(0,0,0,.5); } diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/static/egonomy/css/style.css --- a/src/egonomy/static/egonomy/css/style.css Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/static/egonomy/css/style.css Thu Jun 27 18:58:35 2013 +0200 @@ -234,11 +234,18 @@ .item-masonry{margin-bottom: 20px;} .filters{padding: 10px 0; text-align: center;} .filters li{ margin-bottom: 10px; position: relative; text-align: left; font-size: 12px; font-family: 'Lato'; display:inline-block; width: 200px; height: 28px; line-height: 28px; background-color: #fff;} -.filters a.display-keyword{ overflow: hidden; color: #7F7F7F; display: block; height: 28px; overflow: hidden; margin: 0 16px 0 6px; } + +.filters a.display-keyword:first-child{ overflow: hidden; color: #7F7F7F; padding-left: 6px; display: block; } +.filters a.display-keyword{padding-left: 6px;} .filters li:hover{-webkit-box-shadow : none; -moz-box-shadow : none; box-shadow : none;} -.filters a.icon-action{float: right; margin: 10px 6px 0 0;width: 10px; height: 10px; display: inline-block; background: url(../img/icon-cross-10.png) 0 0 no-repeat; } -.filters .disabled .icon-action{width: 10px; height: 10px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px; background: #7F7F7F;} -.filters .disabled a.display-keyword{opacity: 0.5;} + +.filters .icon-action{position: absolute; top: 10px; right: 6px;width: 10px; height: 10px; display: inline-block;} + +.filters li.disabled .icon-action{width: 10px; height: 10px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px; background-color: #7F7F7F;} +.filters li.disabled a{opacity: 0.5;} + + +.filters li .icon-action{background: url(../img/icon-cross-10.png) 0 0 no-repeat;} .float-left{float: left;} .filters-wrap{width: 225px; background-color: #EEE; margin-right: 17px;} diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/static/egonomy/js/keyword-mosaic.js --- a/src/egonomy/static/egonomy/js/keyword-mosaic.js Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/static/egonomy/js/keyword-mosaic.js Thu Jun 27 18:58:35 2013 +0200 @@ -106,5 +106,12 @@ } updateMasonry(); }); - + + //filters + $('.filters a').each(function(){ + var text = $.trim($(this).text()); + if(text.length > 26){ + $(this).text(text.substr(0, 26) + '...') + } + }); }); diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/static/egonomy/js/main.js --- a/src/egonomy/static/egonomy/js/main.js Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/static/egonomy/js/main.js Thu Jun 27 18:58:35 2013 +0200 @@ -1,11 +1,5 @@ $(function(){ -//filters - $('.filters a').each(function(){ - var text = $.trim($(this).text()); - if(text.length > 30){ - $(this).text(text.substr(0, 30) + '...') - } - }); + //masonry var masonry465 = $('.masonry-465'); masonry465.masonry({ @@ -53,6 +47,7 @@ }); } + // add item to collection behaviour $('.additemtocollection').bind('click', function(e){ @@ -64,27 +59,27 @@ }); - //map + if($('#map').length){ initmap() } -function initmap() { - // set up the map - map = new L.Map('map'); + function initmap() { + // set up the map + map = new L.Map('map'); - // create the tile layer with correct attribution - var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; - var osm = new L.TileLayer(osmUrl, {minZoom: 3, maxZoom: 20}); + // create the tile layer with correct attribution + var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + var osm = new L.TileLayer(osmUrl, {minZoom: 3, maxZoom: 20}); - // start the map in South-East England - map.setView(new L.LatLng(48.833, 2.333),4); - map.addLayer(osm); + // start the map in South-East England + map.setView(new L.LatLng(48.833, 2.333),4); + map.addLayer(osm); - // markers - var marker1 = L.marker([48.833, 2.333]).addTo(map); - marker1.bindPopup("Beaux-Arts de Paris"); - var marker2 = L.marker([47.233,-1.583]).addTo(map); - marker2.bindPopup("Beaux-Arts de Nantes"); -} + // markers + var marker1 = L.marker([48.833, 2.333]).addTo(map); + marker1.bindPopup("Beaux-Arts de Paris"); + var marker2 = L.marker([47.233,-1.583]).addTo(map); + marker2.bindPopup("Beaux-Arts de Nantes"); + } });//ready \ No newline at end of file diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/static/egonomy/js/slideshow.js --- a/src/egonomy/static/egonomy/js/slideshow.js Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/static/egonomy/js/slideshow.js Thu Jun 27 18:58:35 2013 +0200 @@ -1,7 +1,11 @@ $(function() { var currentSlide = 0, jqwin = $(window), jqcaption = $(".caption"), - margin = 50, jqmainimg = $(".main-image"), jqbackdrop = $(".backdrop"), + margin = 50, + jqimgcontainer = $(".image-container"), + jqmainimg = $(".main-image"), + jqbackdrop = $(".backdrop"), + jqpath = $(".clip-path"), lastSlide = null; function showSlide() { @@ -10,34 +14,53 @@ if (slide !== lastSlide) { jqcaption.find("h2").text(slide.title); jqcaption.find("h3").text(slide.author); - jqcaption.find("p").text(slide.description); - jqmainimg.attr("src", slide.image.src); + var captiondiv = jqcaption.find(".caption-description"); + captiondiv.empty(); + slide.description.split(/\s*[\r\n]\s*/gm).forEach(function(p) { + captiondiv.append($("

").text(p)); + }); + jqmainimg.attr("xlink:href", slide.image.src); jqbackdrop.attr("src", slide.image.src); + jqpath.attr("d", slide.path); } lastSlide = slide; if (slide.image && slide.image.width) { - var ww = jqwin.width(), + var pathcoords = slide.path.match(/[\d\.]+/g), + pathx = pathcoords.filter(function(p,i) { + return !(i%2); + }), + pathy = pathcoords.filter(function(p,i) { + return (i%2); + }), + minpx = Math.min.apply(Math,pathx), + maxpx = Math.max.apply(Math,pathx), + minpy = Math.min.apply(Math,pathy), + maxpy = Math.max.apply(Math,pathy), + ww = jqwin.width(), wh = jqwin.height(), cw = jqcaption.outerWidth(), ch = jqcaption.outerHeight(), wi = slide.image.width, - hi = slide.image.height, + hi = slide.image.height, + wp = wi * (maxpx - minpx), + hp = hi * (maxpy - minpy), w1 = ww - 2 * margin, w2 = w1 - cw h1 = wh - 2 * margin, h2 = h1 - ch, ra = Math.max( - Math.min((h1 / hi), (w2 / wi)), - Math.min((h2 / hi), (w1 / wi)) + Math.min((h1 / hp), (w2 / wp)), + Math.min((h2 / hp), (w1 / wp)) ), - wa = wi * ra, ha = hi * ra, + wa = wp * ra, ha = hp * ra, rb = Math.max(ww / wi, wh / hi), wb = wi * rb, hb = hi * rb, xb = (ww - wb) / 2, yb = (wh - hb) / 2; - jqmainimg.css({ + jqimgcontainer.css({ width: wa, height: ha }); + jqimgcontainer[0].setAttribute("viewBox", [minpx,minpy,(maxpx-minpx),(maxpy-minpy)].join(" ")); jqbackdrop.css({ width: wb, height: hb, @@ -86,13 +109,16 @@ $(".right-arrow").click(nextSlide); slides.forEach(function(slide, k) { + if (!slide.path) { + slide.path = "M0 0L1 0L1 1L0 1Z" + } slide.image = new Image(); slide.image.onload = function() { if (k === currentSlide) { showSlide(); } }; - slide.image.src = imgurlbase + slide.url; + slide.image.src = imgurlbase + slide.src; }); showSlide(); diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/templates/egonomy_embed_slideshow.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/egonomy/templates/egonomy_embed_slideshow.html Thu Jun 27 18:58:35 2013 +0200 @@ -0,0 +1,79 @@ +{% load static %} +{% load i18n %} +{% load egostringfilters %} + + + + + + + + + + eGonomy : Diaporama + + + + + +

+ +
+
+

+

+
+
+
+ + + + + + + + +
+ +
+
+ +
+
+ + + + + + \ No newline at end of file diff -r ebb8b58fc2b8 -r d7b30914607d src/egonomy/templates/egonomy_view_collection.html --- a/src/egonomy/templates/egonomy_view_collection.html Thu Jun 27 18:47:14 2013 +0200 +++ b/src/egonomy/templates/egonomy_view_collection.html Thu Jun 27 18:58:35 2013 +0200 @@ -1,7 +1,6 @@ {% extends "egonomy_newbase.html" %} {% load static %} {% load i18n %} -{% load thumbnail %} {% block title %}{% trans "View a collection" %}{% endblock %} @@ -83,10 +82,12 @@

{{ col.title }} / par {{ col.author }}

{% if items %} - {% ifequal display "slideshow" %} + {% ifequal display "list" %}