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-0013d4bc506epull/3/head
parent
5049961e17
commit
583df13139
|
@ -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");
|
||||
|
|
|
@ -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<std::wstring> 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;
|
||||
|
|
|
@ -261,6 +261,11 @@ return str_empty;
|
|||
}
|
||||
|
||||
|
||||
const std::wstring & Request::ParamValue(const std::wstring & param_name)
|
||||
{
|
||||
return ParamValue(param_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ private:
|
|||
bool FunUploadCheckAbuse();
|
||||
void UploadMulti();
|
||||
void UploadSingle();
|
||||
void CreateThumb(Item & item);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,62 @@
|
|||
<h1>[dir_last_subject]</h1>
|
||||
[if mount_page_arg_is "subject"][if mount_page_arg_is "info"]<h1 class="withinfo">[else]<h1>[end][dir_last_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "dir_last_info.html"][end]
|
||||
|
||||
|
||||
[if gallery_tab]
|
||||
<ul class="images" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]/download"><img src="[gallery_tab_link]/download/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[if-one gallery_has_not_mount_type gallery_mount_type_arg_is "lightbox"]
|
||||
|
||||
[if gallery_tab]
|
||||
<ul class="gallerylightbox">
|
||||
[for gallery_tab]
|
||||
<li><a rel="lightbox\[gallery\]" href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript">$('.images').galleria();</script>
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleria"]
|
||||
|
||||
[if gallery_tab]
|
||||
<ul class="images" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
<script type="text/javascript">$('.images').galleria();</script>
|
||||
[else]
|
||||
<script type="text/javascript">$('.images').galleria(\{show: [winix_function_param_value "image"]\});</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleriathumb"]
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
[if gallery_tab]
|
||||
<ul class="gallerylightbox">
|
||||
[for gallery_tab]
|
||||
<li><a href="[doc_base_url][dir]-/image:[gallery_tab_index]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
[else]
|
||||
[if gallery_tab]
|
||||
<ul class="images" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript">$('.images').galleria(\{show: [winix_function_param_value "image"]\});</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
|
|
@ -42,8 +42,17 @@
|
|||
|
||||
[if winix_function_is "gallery"]
|
||||
|
||||
<script type="text/javascript" src="[doc_base_url_common]/jquery-1.4.2.min.js"></script>
|
||||
<script src="[doc_base_url_common]/aino-galleria/src/galleria.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/src/themes/classic/galleria.classic.js');</script>
|
||||
[if-one gallery_has_not_mount_type gallery_mount_type_arg_is "lightbox"]
|
||||
<link rel="stylesheet" href="[doc_base_url_common]/lightbox/lightbox.css" type="text/css" media="screen">
|
||||
<script src="[doc_base_url_common]/lightbox/js/prototype.js" type="text/javascript"></script>
|
||||
<script src="[doc_base_url_common]/lightbox/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
|
||||
<script src="[doc_base_url_common]/lightbox/js/lightbox.js" type="text/javascript"></script>
|
||||
[end]
|
||||
|
||||
[if-one gallery_mount_type_arg_is "galleria" gallery_mount_type_arg_is "galleriathumb"]
|
||||
<script type="text/javascript" src="[doc_base_url_common]/jquery-1.4.2.min.js"></script>
|
||||
<script src="[doc_base_url_common]/aino-galleria/src/galleria.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/src/themes/classic/galleria.classic.js');</script>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<EzcFun*>(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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue