From 583df13139bd742209532572263937b0760627b2 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 11 Feb 2011 21:37:28 +0000 Subject: [PATCH] added: mount options: thumb_size(cx, cy) size of a generated thumbnail (size in pixels) added: plugin gallery: mount option gallery_type it can be: "lightbox" "galleria" "galleriathumb" git-svn-id: svn://ttmath.org/publicrep/winix/trunk@717 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/mounts.cpp | 2 + core/mounts.h | 4 ++ core/request.cpp | 5 +++ core/request.h | 3 +- functions/upload.cpp | 36 ++++++++++++++++- functions/upload.h | 1 + html/fun_gallery.html | 64 ++++++++++++++++++++++++++---- html/index_head_functions_add.html | 15 +++++-- plugins/gallery/galleryinfo.h | 7 ++++ plugins/gallery/init.cpp | 8 ++-- plugins/gallery/templates.cpp | 21 ++++++++++ static/layout1/winix.css | 19 ++++++++- templates/templates.cpp | 1 + templates/templates.h | 1 + templates/winix.cpp | 5 +++ 15 files changed, 175 insertions(+), 17 deletions(-) diff --git a/core/mounts.cpp b/core/mounts.cpp index 9036f94..761a864 100755 --- a/core/mounts.cpp +++ b/core/mounts.cpp @@ -38,6 +38,8 @@ void Mounts::CreateMountFs() void Mounts::CreateMountPar() { mount_par_page = AddMountPar(L"page"); + mount_par_thumb_size = AddMountPar(L"thumb_size"); + mount_par_thumb_mode = AddMountPar(L"thumb_mode"); //mount_par_thread = AddMountPar(L"thread"); //mount_par_createthread_on = AddMountPar(L"createthread_on"); mount_par_only_root_remove = AddMountPar(L"only_root_remove"); diff --git a/core/mounts.h b/core/mounts.h index 172fcc5..98395ae 100755 --- a/core/mounts.h +++ b/core/mounts.h @@ -63,6 +63,8 @@ public: const std::wstring & GetMountPar(int id); int MountParPage() { return mount_par_page; } + int MountParThumbSize() { return mount_par_thumb_size; } + int MountParThumbMode() { return mount_par_thumb_mode; } //int MountParThread() { return mount_par_thread; } //int MountParCreatethreadOn() { return mount_par_createthread_on; } int MountParOnlyRootRemove() { return mount_par_only_root_remove; } @@ -120,6 +122,8 @@ private: std::vector mount_par_tab; int mount_par_page; + int mount_par_thumb_size; + int mount_par_thumb_mode; //int mount_par_thread; //int mount_par_createthread_on; int mount_par_only_root_remove; diff --git a/core/request.cpp b/core/request.cpp index 48bf88a..40f8a01 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -261,6 +261,11 @@ return str_empty; } +const std::wstring & Request::ParamValue(const std::wstring & param_name) +{ + return ParamValue(param_name.c_str()); +} + diff --git a/core/request.h b/core/request.h index c70d62c..cbe21d8 100755 --- a/core/request.h +++ b/core/request.h @@ -115,7 +115,8 @@ struct Request bool IsParam(const wchar_t * param_name); bool IsParam(const std::wstring & param_name); - const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter + const std::wstring & ParamValue(const wchar_t * param_name); // returns empty string if there is no such a parameter + const std::wstring & ParamValue(const std::wstring & param_name); // returns empty string if there is no such a parameter void SetCookie(const char * name, const char * value, tm * expires = 0); void SetCookie(const char * name, long value, tm * expires = 0); diff --git a/functions/upload.cpp b/functions/upload.cpp index 46e9e08..390e7e7 100755 --- a/functions/upload.cpp +++ b/functions/upload.cpp @@ -89,6 +89,40 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi } +void Upload::CreateThumb(Item & item) +{ + Mount & m = *system->mounts.pmount; + size_t cx = config->thumb_cx; + size_t cy = config->thumb_cy; + int mode = config->thumb_mode; + int index; + + // reading width and height from then mount point (if exists) + index = system->mounts.MountParThumbSize(); + + if( m.param[index].defined && m.param[index].arg.size() == 2 ) + { + cx = Tol(m.param[index].arg[0]); + cy = Tol(m.param[index].arg[1]); + } + + if( cx > 2000 ) + cx = 2000; + + if( cy > 2000 ) + cy = 2000; + + // reading thumb mode from then mount point (if exists) + index = system->mounts.MountParThumbMode(); + + if( m.param[index].defined && m.param[index].arg.size() == 1 ) + mode = Toi(m.param[index].arg[0]); + + system->thumb.CreateThumb(item, cx, cy, mode); +} + + + void Upload::UploadFile(Item & item, const std::wstring & tmp_filename) { // we should add the file beforehand to get the proper item.id @@ -103,7 +137,7 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename) cur->request->status = db->EditFileById(item, item.id); if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE && config->create_thumb ) - system->thumb.CreateThumb(item, config->thumb_cx, config->thumb_cy, config->thumb_mode); + CreateThumb(item); } else { diff --git a/functions/upload.h b/functions/upload.h index 778c18f..0ac1c1a 100755 --- a/functions/upload.h +++ b/functions/upload.h @@ -37,6 +37,7 @@ private: bool FunUploadCheckAbuse(); void UploadMulti(); void UploadSingle(); + void CreateThumb(Item & item); }; diff --git a/html/fun_gallery.html b/html/fun_gallery.html index 5e07ea6..2011b06 100755 --- a/html/fun_gallery.html +++ b/html/fun_gallery.html @@ -1,14 +1,62 @@ -

[dir_last_subject]

+[if mount_page_arg_is "subject"][if mount_page_arg_is "info"]

[else]

[end][dir_last_subject]

[end] +[if mount_page_arg_is "info"][include "dir_last_info.html"][end] -[if gallery_tab] - - - + +[end] + + +[if gallery_mount_type_arg_is "galleria"] + + [if gallery_tab] + + + [if-no winix_function_param_is "image"] + + [else] + + [end] + [end] + +[end] + + + +[if gallery_mount_type_arg_is "galleriathumb"] + + [if-no winix_function_param_is "image"] + [if gallery_tab] + + [end] + [else] + [if gallery_tab] + + + + [end] + [end] + [end] diff --git a/html/index_head_functions_add.html b/html/index_head_functions_add.html index 1d65cd9..13e61fe 100755 --- a/html/index_head_functions_add.html +++ b/html/index_head_functions_add.html @@ -42,8 +42,17 @@ [if winix_function_is "gallery"] - - - + [if-one gallery_has_not_mount_type gallery_mount_type_arg_is "lightbox"] + + + + + [end] + + [if-one gallery_mount_type_arg_is "galleria" gallery_mount_type_arg_is "galleriathumb"] + + + + [end] [end] diff --git a/plugins/gallery/galleryinfo.h b/plugins/gallery/galleryinfo.h index 89ae202..e6f444d 100755 --- a/plugins/gallery/galleryinfo.h +++ b/plugins/gallery/galleryinfo.h @@ -31,6 +31,13 @@ public: int mount_par_gallery_size; + + + // "lightbox" (default) + // "galleria" (http://galleria.aino.se/) + // "galleriathumb" (http://galleria.aino.se/) + int mount_par_gallery_type; + // id of the current plugin int plugin_id; diff --git a/plugins/gallery/init.cpp b/plugins/gallery/init.cpp index 2209829..a42956c 100755 --- a/plugins/gallery/init.cpp +++ b/plugins/gallery/init.cpp @@ -37,7 +37,7 @@ void AddFunctions(PluginInfo & info) void SelectDefaultFunction(PluginInfo & info) { - if( info.system->mounts.pmount->type == gallery_info.mount_type_gallery ) + if( !info.cur->request->is_item && info.system->mounts.pmount->type == gallery_info.mount_type_gallery ) info.cur->request->function = &fun_gallery; } @@ -46,9 +46,11 @@ void AddMounts(PluginInfo & info) { Mounts & m = info.system->mounts; - gallery_info.mount_type_gallery = m.AddMountType(L"gallery"); - gallery_info.mount_par_gallery = m.AddMountPar(L"gallery"); + gallery_info.mount_type_gallery = m.AddMountType(L"gallery"); + + gallery_info.mount_par_gallery = m.AddMountPar(L"gallery"); gallery_info.mount_par_gallery_size = m.AddMountPar(L"gallery_size"); + gallery_info.mount_par_gallery_type = m.AddMountPar(L"gallery_type"); } diff --git a/plugins/gallery/templates.cpp b/plugins/gallery/templates.cpp index 7551c5e..ed08832 100755 --- a/plugins/gallery/templates.cpp +++ b/plugins/gallery/templates.cpp @@ -37,6 +37,12 @@ void gallery_tab(Info & i) } +void gallery_tab_index(Info & i) +{ + i.out << gallery_index; +} + + void gallery_tab_dir(Info & i) { if( gallery_index < gallery_info.item_sort_tab.size() ) @@ -115,6 +121,18 @@ void gallery_height(Info & i) } +void gallery_has_not_mount_type(Info & i) +{ + i.res = !system->mounts.pmount->IsPar(gallery_info.mount_par_gallery_type); +} + + +void gallery_mount_type_arg_is(Info & i) +{ + i.res = system->mounts.pmount->IsArg(gallery_info.mount_par_gallery_type, i.par); +} + + void AddEzcFunctions(PluginInfo & info) { @@ -122,12 +140,15 @@ void AddEzcFunctions(PluginInfo & info) EzcFun * fun = reinterpret_cast(info.p1); fun->Insert("gallery_tab", gallery_tab); + fun->Insert("gallery_tab_index", gallery_tab_index); fun->Insert("gallery_tab_dir", gallery_tab_dir); fun->Insert("gallery_tab_url", gallery_tab_url); fun->Insert("gallery_tab_subject", gallery_tab_subject); fun->Insert("gallery_tab_link", gallery_tab_link); fun->Insert("gallery_width", gallery_width); fun->Insert("gallery_height", gallery_height); + fun->Insert("gallery_has_not_mount_type", gallery_has_not_mount_type); + fun->Insert("gallery_mount_type_arg_is", gallery_mount_type_arg_is); } diff --git a/static/layout1/winix.css b/static/layout1/winix.css index 0b239ae..67e2e3d 100755 --- a/static/layout1/winix.css +++ b/static/layout1/winix.css @@ -803,5 +803,22 @@ color: black; } +ul.gallerylightbox { +} + +ul.gallerylightbox li { +display: block; +float: left; +margin: 0 0 6px 10px; +} + +ul.gallerylightbox a, ul.gallerylightbox a:hover, ul.gallerylightbox a:focus, ul.gallerylightbox a:active { +background: none; +} + +ul.gallerylightbox img { +display: inline; +background: none; +} + - \ No newline at end of file diff --git a/templates/templates.cpp b/templates/templates.cpp index 47b3d37..011266b 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -398,6 +398,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("winix_function", winix_function); ezc_functions.Insert("winix_function_is", winix_function_is); ezc_functions.Insert("winix_function_param_is", winix_function_param_is); + ezc_functions.Insert("winix_function_param_value",winix_function_param_value); ezc_functions.Insert("winix_has_plugin", winix_has_plugin); ezc_functions.Insert("winix_loadavg_now", winix_loadavg_now); ezc_functions.Insert("winix_loadavg_1", winix_loadavg_1); diff --git a/templates/templates.h b/templates/templates.h index 1c70138..86a9918 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -330,6 +330,7 @@ namespace TemplatesFunctions void winix_function(Info & i); void winix_function_is(Info & i); void winix_function_param_is(Info & i); + void winix_function_param_value(Info & i); void winix_has_plugin(Info & i); void winix_loadavg_now(Info & i); void winix_loadavg_1(Info & i); diff --git a/templates/winix.cpp b/templates/winix.cpp index da53508..2d0b829 100755 --- a/templates/winix.cpp +++ b/templates/winix.cpp @@ -65,6 +65,11 @@ void winix_function_param_is(Info & i) } +void winix_function_param_value(Info & i) +{ + i.out << cur->request->ParamValue(i.par); +} + void winix_has_plugin(Info & i) { size_t exist = 0;