added a new plugin: "gallery"

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@716 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2011-01-31 15:51:53 +00:00
parent 18492e5d61
commit 5049961e17
13 changed files with 639 additions and 0 deletions

View File

@ -28,6 +28,7 @@ winix: FORCE
@cd plugins/stats ; $(MAKE) -e
@cd plugins/thread ; $(MAKE) -e
@cd plugins/ticket ; $(MAKE) -e
@cd plugins/gallery ; $(MAKE) -e
@cd ../ezc/src ; $(MAKE) -e
$(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread -lfetch
@cd main ; $(MAKE) -e
@ -45,6 +46,7 @@ clean:
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@cd plugins/gallery ; $(MAKE) -e clean
@cd ../ezc/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
@ -63,6 +65,7 @@ depend:
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd ../ezc/src ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend

16
html/fun_gallery.html Executable file
View File

@ -0,0 +1,16 @@
<h1>[dir_last_subject]</h1>
[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>
[end]
</ul>
<script type="text/javascript">$('.images').galleria();</script>
[end]
[include "item_options.html"]

View File

@ -38,3 +38,12 @@
<script src="[doc_base_url_common]/lightbox/js/lightbox.js" type="text/javascript"></script>
[end]
[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>
[end]

27
plugins/gallery/Makefile Executable file
View File

@ -0,0 +1,27 @@
include Makefile.o.dep
name = gallery.so
all: $(o)
$(CXX) -shared -Wl,-soname,$(name).so -o $(name) $(CXXFLAGS) *.o
.SUFFIXES: .cpp .o
.cpp.o:
$(CXX) -c $(CXXFLAGS) $<
depend:
makedepend -Y. -I../.. -I../../../ezc/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
clean:
rm -f *.o
rm -f $(name)
include Makefile.dep

135
plugins/gallery/Makefile.dep Executable file
View File

@ -0,0 +1,135 @@
# DO NOT DELETE
gallery.o: gallery.h ../../functions/functionbase.h ../../core/item.h
gallery.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
gallery.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/misc.h
gallery.o: ../../core/item.h ../../core/error.h ../../core/log.h
gallery.o: ../../core/textstream.h ../../db/dbitemquery.h
gallery.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
gallery.o: ../../core/dircontainer.h ../../core/ugcontainer.h
gallery.o: ../../core/request.h ../../core/requesttypes.h ../../core/error.h
gallery.o: ../../core/config.h ../../core/confparser.h
gallery.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
gallery.o: ../../core/config.h ../../core/system.h ../../core/dirs.h
gallery.o: ../../core/dircontainer.h ../../core/request.h
gallery.o: ../../notify/notify.h ../../notify/notifypool.h
gallery.o: ../../templates/locale.h ../../core/confparser.h
gallery.o: ../../templates/misc.h ../../templates/localefilter.h
gallery.o: ../../templates/locale.h ../../../ezc/src/ezc.h
gallery.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
gallery.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
gallery.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
gallery.o: ../../templates/htmltextstream.h ../../notify/notifythread.h
gallery.o: ../../core/basethread.h ../../core/synchro.h
gallery.o: ../../notify/templatesnotify.h ../../core/users.h
gallery.o: ../../core/user.h ../../core/ugcontainer.h
gallery.o: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
gallery.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mounts.h
gallery.o: ../../core/mount.h ../../core/mountparser.h ../../core/users.h
gallery.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
gallery.o: ../../core/thumb.h ../../core/basethread.h ../../core/synchro.h
gallery.o: galleryinfo.h
galleryinfo.o: galleryinfo.h ../../core/item.h
init.o: gallery.h ../../functions/functionbase.h ../../core/item.h
init.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
init.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/misc.h
init.o: ../../core/item.h ../../core/error.h ../../core/log.h
init.o: ../../core/textstream.h ../../db/dbitemquery.h
init.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
init.o: ../../core/dircontainer.h ../../core/ugcontainer.h
init.o: ../../core/request.h ../../core/requesttypes.h ../../core/error.h
init.o: ../../core/config.h ../../core/confparser.h ../../core/htmlfilter.h
init.o: ../../templates/htmltextstream.h ../../core/config.h
init.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
init.o: ../../core/request.h ../../notify/notify.h ../../notify/notifypool.h
init.o: ../../templates/locale.h ../../core/confparser.h
init.o: ../../templates/misc.h ../../templates/localefilter.h
init.o: ../../templates/locale.h ../../../ezc/src/ezc.h
init.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
init.o: ../../templates/htmltextstream.h ../../notify/notifythread.h
init.o: ../../core/basethread.h ../../core/synchro.h
init.o: ../../notify/templatesnotify.h ../../core/users.h ../../core/user.h
init.o: ../../core/ugcontainer.h ../../core/lastcontainer.h ../../core/cur.h
init.o: ../../core/session.h ../../core/plugindata.h ../../core/rebus.h
init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
init.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
init.o: ../../core/synchro.h galleryinfo.h ../../core/log.h
init.o: ../../core/plugin.h ../../core/pluginmsg.h ../../core/system.h
init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
init.o: ../../functions/functions.h ../../functions/functionbase.h
init.o: ../../functions/functionparser.h ../../core/cur.h
init.o: ../../functions/adduser.h ../../functions/cat.h
init.o: ../../functions/chmod.h ../../functions/privchanger.h
init.o: ../../functions/chown.h ../../functions/ckeditor.h
init.o: ../../functions/cp.h ../../functions/default.h
init.o: ../../functions/download.h ../../functions/emacs.h
init.o: ../../functions/last.h ../../functions/login.h
init.o: ../../functions/logout.h ../../functions/ln.h ../../functions/ls.h
init.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h
init.o: ../../functions/run.h ../../functions/specialdefault.h
init.o: ../../functions/stat.h ../../functions/subject.h
init.o: ../../functions/template.h ../../functions/tinymce.h
init.o: ../../functions/uname.h ../../functions/upload.h
init.o: ../../functions/uptime.h ../../functions/who.h ../../functions/vim.h
init.o: ../../core/htmlfilter.h ../../templates/templates.h
init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h
init.o: ../../core/httpsimpleparser.h ../../core/log.h
init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
templates.o: gallery.h ../../functions/functionbase.h ../../core/item.h
templates.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
templates.o: ../../db/dbtextstream.h ../../core/textstream.h
templates.o: ../../core/misc.h ../../core/item.h ../../core/error.h
templates.o: ../../core/log.h ../../core/textstream.h ../../db/dbitemquery.h
templates.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
templates.o: ../../core/dircontainer.h ../../core/ugcontainer.h
templates.o: ../../core/request.h ../../core/requesttypes.h
templates.o: ../../core/error.h ../../core/config.h ../../core/confparser.h
templates.o: ../../core/htmlfilter.h ../../templates/htmltextstream.h
templates.o: ../../core/config.h ../../core/system.h ../../core/dirs.h
templates.o: ../../core/dircontainer.h ../../core/request.h
templates.o: ../../notify/notify.h ../../notify/notifypool.h
templates.o: ../../templates/locale.h ../../core/confparser.h
templates.o: ../../templates/misc.h ../../templates/localefilter.h
templates.o: ../../templates/locale.h ../../../ezc/src/ezc.h
templates.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
templates.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
templates.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
templates.o: ../../templates/htmltextstream.h ../../notify/notifythread.h
templates.o: ../../core/basethread.h ../../core/synchro.h
templates.o: ../../notify/templatesnotify.h ../../core/users.h
templates.o: ../../core/user.h ../../core/ugcontainer.h
templates.o: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
templates.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mounts.h
templates.o: ../../core/mount.h ../../core/mountparser.h ../../core/users.h
templates.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h
templates.o: ../../core/thumb.h ../../core/basethread.h ../../core/synchro.h
templates.o: galleryinfo.h ../../core/misc.h ../../core/plugin.h
templates.o: ../../core/pluginmsg.h ../../core/system.h
templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
templates.o: ../../functions/functions.h ../../functions/functionbase.h
templates.o: ../../functions/functionparser.h ../../core/cur.h
templates.o: ../../functions/adduser.h ../../functions/cat.h
templates.o: ../../functions/chmod.h ../../functions/privchanger.h
templates.o: ../../functions/chown.h ../../functions/ckeditor.h
templates.o: ../../functions/cp.h ../../functions/default.h
templates.o: ../../functions/download.h ../../functions/emacs.h
templates.o: ../../functions/last.h ../../functions/login.h
templates.o: ../../functions/logout.h ../../functions/ln.h
templates.o: ../../functions/ls.h ../../functions/mkdir.h
templates.o: ../../functions/mv.h ../../functions/node.h
templates.o: ../../functions/priv.h ../../functions/reload.h
templates.o: ../../functions/rm.h ../../functions/run.h
templates.o: ../../functions/specialdefault.h ../../functions/stat.h
templates.o: ../../functions/subject.h ../../functions/template.h
templates.o: ../../functions/tinymce.h ../../functions/uname.h
templates.o: ../../functions/upload.h ../../functions/uptime.h
templates.o: ../../functions/who.h ../../functions/vim.h
templates.o: ../../core/htmlfilter.h ../../templates/templates.h
templates.o: ../../templates/patterncacher.h
templates.o: ../../templates/ckeditorgetparser.h
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h

1
plugins/gallery/Makefile.o.dep Executable file
View File

@ -0,0 +1 @@
o = gallery.o galleryinfo.o init.o templates.o

90
plugins/gallery/gallery.cpp Executable file
View File

@ -0,0 +1,90 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "gallery.h"
namespace Gallery
{
Gallery::Gallery()
{
fun.url = L"gallery";
}
void Gallery::SetGalleryInfo(GalleryInfo * pinfo)
{
gallery_info = pinfo;
}
bool Gallery::HasAccess()
{
return true;
}
void Gallery::CreatePointers()
{
gallery_info->item_sort_tab.resize(gallery_info->item_tab.size());
for(size_t i=0 ; i<gallery_info->item_tab.size() ; ++i)
gallery_info->item_sort_tab[i] = &gallery_info->item_tab[i];
}
void Gallery::SortPointers()
{
}
void Gallery::MakeGetDir()
{
iq.SetAll(false, false);
iq.sel_parent_id = true;
iq.sel_subject = true;
iq.sel_url = true;
iq.sel_type = true;
iq.sel_file = true;
iq.WhereParentId(cur->request->dir_tab.back()->id);
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
db->GetItems(gallery_info->item_tab, iq);
CreatePointers();
}
void Gallery::MakeGetFile()
{
gallery_info->item_sort_tab.resize(1);
gallery_info->item_sort_tab[0] = &cur->request->item;
}
void Gallery::MakeGet()
{
if( cur->request->is_item )
MakeGetFile();
else
MakeGetDir();
SortPointers();
}
} // namespace

46
plugins/gallery/gallery.h Executable file
View File

@ -0,0 +1,46 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_plugins_gallery_gallery
#define headerfile_winix_plugins_gallery_gallery
#include "functions/functionbase.h"
#include "galleryinfo.h"
namespace Gallery
{
class Gallery : public FunctionBase
{
public:
Gallery();
bool HasAccess();
void MakeGet();
void SetGalleryInfo(GalleryInfo * pinfo);
private:
GalleryInfo * gallery_info;
DbItemQuery iq;
void CreatePointers();
void SortPointers();
void MakeGetDir();
void MakeGetFile();
};
} // namespace
#endif

34
plugins/gallery/galleryinfo.cpp Executable file
View File

@ -0,0 +1,34 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "galleryinfo.h"
namespace Gallery
{
void GalleryInfo::Clear()
{
item_tab.clear();
item_sort_tab.clear();
}
} // namespace

52
plugins/gallery/galleryinfo.h Executable file
View File

@ -0,0 +1,52 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_plugins_gallery_galleryinfo
#define headerfile_winix_plugins_gallery_galleryinfo
#include <vector>
#include "core/item.h"
namespace Gallery
{
class GalleryInfo
{
public:
// id of a mount type
int mount_type_gallery;
// enable a thread in a specific directory
// and set sort type (asc, desc)
int mount_par_gallery;
int mount_par_gallery_size;
// id of the current plugin
int plugin_id;
void Clear();
std::vector<Item> item_tab;
std::vector<Item*> item_sort_tab;
private:
};
} // namespace
#endif

87
plugins/gallery/init.cpp Executable file
View File

@ -0,0 +1,87 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "gallery.h"
#include "core/log.h"
#include "core/plugin.h"
extern "C" void Init(PluginInfo &);
namespace Gallery
{
Gallery fun_gallery;
GalleryInfo gallery_info;
const wchar_t plugin_name[] = L"gallery";
void AddFunctions(PluginInfo & info)
{
info.functions->Add(fun_gallery);
}
void SelectDefaultFunction(PluginInfo & info)
{
if( info.system->mounts.pmount->type == gallery_info.mount_type_gallery )
info.cur->request->function = &fun_gallery;
}
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_par_gallery_size = m.AddMountPar(L"gallery_size");
}
void EndRequest(PluginInfo & info)
{
gallery_info.Clear();
}
void AddEzcFunctions(PluginInfo & info);
} // namespace
void Init(PluginInfo & info)
{
using namespace Gallery;
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
plugin.Assign(WINIX_END_REQUEST, EndRequest);
gallery_info.plugin_id = info.plugin_id;
fun_gallery.SetGalleryInfo(&gallery_info);
info.p1 = (void*)(plugin_name);
}

138
plugins/gallery/templates.cpp Executable file
View File

@ -0,0 +1,138 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "gallery.h"
#include "core/request.h"
#include "core/misc.h"
#include "core/plugin.h"
#include "templates/templates.h"
#include "functions/functions.h"
namespace Gallery
{
using namespace TemplatesFunctions;
using TemplatesFunctions::system;
extern GalleryInfo gallery_info;
extern Gallery fun_gallery;
static size_t gallery_index;
static std::wstring item_dir;
void gallery_tab(Info & i)
{
gallery_index = i.iter;
i.res = gallery_index < gallery_info.item_sort_tab.size();
}
void gallery_tab_dir(Info & i)
{
if( gallery_index < gallery_info.item_sort_tab.size() )
{
Item & item = *gallery_info.item_sort_tab[gallery_index];
system->dirs.MakePath(item.parent_id, item_dir);
i.out << item_dir;
}
}
void gallery_tab_url(Info & i)
{
if( gallery_index < gallery_info.item_sort_tab.size() )
{
Item & item = *gallery_info.item_sort_tab[gallery_index];
i.out << item.url;
}
}
void gallery_tab_subject(Info & i)
{
if( gallery_index < gallery_info.item_sort_tab.size() )
{
Item & item = *gallery_info.item_sort_tab[gallery_index];
i.out << item.subject;
}
}
void gallery_tab_link(Info & i)
{
i.out << config->base_url;
gallery_tab_dir(i);
gallery_tab_url(i);
}
void gallery_width(Info & i)
{
if( !system->mounts.pmount )
return;
Mount & m = *system->mounts.pmount;
if( !m.param[gallery_info.mount_par_gallery_size].defined || m.param[gallery_info.mount_par_gallery_size].arg.size() != 2 )
{
i.out << "800px";
}
else
{
i.out << m.param[gallery_info.mount_par_gallery_size].arg[0];
}
}
void gallery_height(Info & i)
{
if( !system->mounts.pmount )
return;
Mount & m = *system->mounts.pmount;
if( !m.param[gallery_info.mount_par_gallery_size].defined || m.param[gallery_info.mount_par_gallery_size].arg.size() != 2 )
{
i.out << "500px";
}
else
{
i.out << m.param[gallery_info.mount_par_gallery_size].arg[1];
}
}
void AddEzcFunctions(PluginInfo & info)
{
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
fun->Insert("gallery_tab", gallery_tab);
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);
}
} // namespace

View File

@ -804,3 +804,4 @@ color: black;