').insertBefore($pic).append($pic);
+ }
+ if (!$pic.length) return;
+
+ $this.css({width: 'auto', float: 'left', position: 'relative'});
+
+ var item = {
+ pic: $pic,
+ container: $this,
+ original_height: $pic.attr('height') || $pic.height(),
+ original_width: $pic.attr('width') || $pic.width()
+ };
+ item.aspect = item.original_width / item.original_height;
+ item.scale = $settings.row_min_height / item.original_height;
+ item.width = item.original_width * item.scale;
+ item.height = item.original_height * item.scale;
+
+ var new_bucket_width = getWidthForBucket(last_bucket.items, item);
+ if (new_bucket_width > max_bucket_width) {
+ buckets.push(last_bucket);
+ last_bucket = {
+ items: [],
+ width: 0,
+ height: 0
+ };
+ }
+ last_bucket.items.push(item);
+ });
+
+ if (last_bucket.items.length == 1 && buckets[buckets.length-1].items.length > 1){
+ buckets[buckets.length-1].items.push(last_bucket.items[0]);
+ }else{
+ buckets.push(last_bucket);
+ last_bucket.last = true;
+ }
+
+ $.each(buckets, function(idx, bucket) {
+ bucket.scale = (max_bucket_width - (bucket.items.length - 1) * $settings.margin) / getWidthForBucket(bucket.items);
+ var $last_item;
+
+ var n = 0;
+ $.each(bucket.items, function(idx2, item) {
+ if (bucket.scale) {
+ item.width = Math.floor(item.width * bucket.scale);
+ item.height = Math.floor(item.height * bucket.scale);
+ }
+ item.index = n;
+ var pic = item.pic,
+ container = item.container;
+ $last_item = item;
+ n++;
+
+ pic.css({
+ height: parseInt(item.height)+"px",
+ width: parseInt(item.width)+"px"
+ });
+ item.container.css({
+ height: parseInt(item.height)+"px",
+ width: parseInt(item.width)+"px",
+ marginTop: $settings.margin + 'px'
+ });
+ if (idx2 > 0) {
+ item.container.css({
+ marginLeft: $settings.margin + 'px'
+ });
+ } else {
+ item.container.css({
+ clear: 'left'
+ });
+ }
+ });
+ });
+ });
+ }
+ function getWidthForBucket(bucket, extra){
+ var width = 0;
+ if (bucket.length) {
+ $.each(bucket, function(idx, item) {
+ width += item.width;
+ });
+ }
+ if (extra) {
+ width += extra.width;
+ }
+ return width;
+ }
+
+ })
+ },
+ clear: function(){
+ conteiner = this;
+ data = conteiner.data('tjGallery');
+ conteiner.each(function() {
+ $(this).find(data.tjGallery.selector).each(function() {
+ if (!$(this).is('img'))
+ $(this).find('img').css({'width': 'auto', 'height': 'auto'});
+ $(this).removeAttr('style');
+ $(this).appendTo(conteiner);
+ })
+ $(this).find('div:empty').remove();
+ })
+ },
+ destroy : function() {
+ methods.clear.apply(this);
+ $(window).unbind('.tjGallery');
+ }
+ };
+
+
+ $.fn.tjGallery = function( method ) {
+ if ( methods[method] ) {
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
+ } else if ( typeof method === 'object' || ! method ) {
+ var that = this;
+ return methods.init.apply( this, arguments );
+ } else {
+ $.error( 'Method ' + method + ' does not exist for jQuery.tjGallery' );
+ }
+
+ };
+
+})(jQuery);
\ No newline at end of file
diff --git a/cao_blogr/static/js/jquery-tjgallery.min.js b/cao_blogr/static/js/jquery-tjgallery.min.js
new file mode 100644
index 0000000..f06a6ca
--- /dev/null
+++ b/cao_blogr/static/js/jquery-tjgallery.min.js
@@ -0,0 +1,7 @@
+/*!
+ * tjGallery 1.1
+ * http://tj-s.ru
+ * @copyright Tod, tod@tj-s.ru
+ * @license MIT License
+ */
+!function(o){var e={init:function(t){var l=o.extend({selector:"img",row_min_height:180,margin:5},t);return this.each(function(){var t=o(this);return t.data("tjGallery")||t.data("tjGallery",{target:t,tjGallery:l}),o(window).bind("resize.tjGallery",function(){e.clear.apply(t),i(t)}),i(t);function i(t){return t.each(function(){var t=o(this),r=t.width(),a=[],h={items:[],width:0,height:0};t.find(l.selector).each(function(){var t=o(this),i=t;if(t="IMG"!=i[0].nodeName.toUpperCase()?(i=i.find("img"),o('
').insertBefore(t).append(t)):o('
').insertBefore(i).append(i),i.length){t.css({width:"auto",float:"left",position:"relative"});var e={pic:i,container:t,original_height:i.attr("height")||i.height(),original_width:i.attr("width")||i.width()};e.aspect=e.original_width/e.original_height,e.scale=l.row_min_height/e.original_height,e.width=e.original_width*e.scale,e.height=e.original_height*e.scale;var n=s(h.items,e);r
-
-
-
-
-
- L'argent qu'on possède est l'instrument de la liberté; celui qu'on pourchasse est celui de la servitude.
-
-
-
-
-
-
-
-
-
- L'intelligence ce n'est pas ce que l'on sait mais ce que l'on fait quand on ne sait pas.
-
-
-
-
-
-
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/cao_blogr/templates/image_edit.jinja2 b/cao_blogr/templates/image_edit.jinja2
new file mode 100644
index 0000000..2b9edc7
--- /dev/null
+++ b/cao_blogr/templates/image_edit.jinja2
@@ -0,0 +1,25 @@
+{% extends "cao_blogr:templates/layout.jinja2" %}
+
+{% block content %}
+
+
+
+{% endblock %}
diff --git a/cao_blogr/templates/images.jinja2 b/cao_blogr/templates/images.jinja2
new file mode 100644
index 0000000..9648185
--- /dev/null
+++ b/cao_blogr/templates/images.jinja2
@@ -0,0 +1,28 @@
+{% extends "layout.jinja2" %}
+
+{% block content %}
+
+
+
+ {% for item in images_list %}
+
+
{{ item[1] }}
+

+ {% endfor %}
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/cao_blogr/templates/settings.jinja2 b/cao_blogr/templates/settings.jinja2
index 580739c..e2984bc 100644
--- a/cao_blogr/templates/settings.jinja2
+++ b/cao_blogr/templates/settings.jinja2
@@ -15,6 +15,11 @@
TOPICS / TAGS
+
diff --git a/cao_blogr/views/default.py b/cao_blogr/views/default.py
index 0f4ce14..a6e77c5 100644
--- a/cao_blogr/views/default.py
+++ b/cao_blogr/views/default.py
@@ -12,6 +12,7 @@ from ..services.blog_record import BlogRecordService
from ..forms import UserCreateForm, TopicForm, TagForm
from ..models.user import User
from ..models.blog_record import Topics, Tags
+import os
@view_config(route_name='home',
@@ -97,15 +98,6 @@ def settings(request):
}
-@view_config(route_name='apropos',
- renderer='cao_blogr:templates/apropos.jinja2')
-def apropos(request):
-
- return {
- 'page_title': "A propos",
- }
-
-
@view_config(route_name='login',
renderer='cao_blogr:templates/login.jinja2')
@forbidden_view_config(renderer='cao_blogr:templates/login.jinja2')
@@ -298,3 +290,23 @@ def tag_edit(request):
'form': form,
'topic': topic,
}
+
+
+@view_config(route_name='images',
+ renderer='cao_blogr:templates/images.jinja2')
+def images(request):
+
+ folder_path = request.registry.settings['images_dir']
+
+ images_list = []
+ for f in os.scandir(folder_path):
+ image = []
+ image.append(request.static_url('cao_blogr:static/img/') + f.name)
+ image.append(f.name)
+ images_list.append(image)
+
+ return {
+ 'page_title': "Images",
+ 'images_list': images_list,
+ }
+
diff --git a/development.ini b/development.ini
index e761d77..66bdde5 100644
--- a/development.ini
+++ b/development.ini
@@ -15,6 +15,8 @@ pyramid.includes =
pyramid_debugtoolbar
sqlalchemy.url = sqlite:///%(here)s/cao_blogr.sqlite
+# images location
+images_dir = /pyramid10/cao_sunyata/cao_blogr/static/img
cao_blogr.admin_email = cao.thien-phuoc@orange.fr
# Mailer configuration
diff --git a/production.ini b/production.ini
index af3c4f7..7fcc0f3 100644
--- a/production.ini
+++ b/production.ini
@@ -13,6 +13,8 @@ pyramid.debug_routematch = false
pyramid.default_locale_name = en
sqlalchemy.url = sqlite:///%(here)s/cao_blogr.sqlite
+# images location
+images_dir = /pyramid10/cao_sunyata/cao_blogr/static/img
cao_blogr.admin_email = phuoc@caotek.fr
# Mailer configuration