initial commit

This commit is contained in:
Quentin W 2024-07-18 14:09:32 -04:00
commit 5b839e0543
174 changed files with 12261 additions and 0 deletions

45
werc/apps/xibit/README Normal file
View file

@ -0,0 +1,45 @@
Xibit (tibix) - the image gallery generator for werc
Xibit can:
- generate thumbnails from almost any picture format
- generate preview images with captions
- display them (rather brokenly for now)
Dependencies:
- Plan9port
- Imagemagick
- werc
To make it work:
1, clone the git repo at git://home.9souldier.org/xibit into $werc_root/apps
2, pick a directory to serve the gallery from
3, create an _werc and _werc/xibit directory in there, the xibit directory needs to be writable by the webserver to generate the thumbnails (at one point i'll probably make a cronjob, and then this will be optional)
4, create an _werc/config file (readable by the webserver), that contains the options for xibit
5, add xibit to the enabled_apps in initrc.local (or the local per-directory config file)
That should get you going.
to use captions just create a directory in GALLERY/_werc/xibit called captions, make it readable by the weberver and add the captions as files, using the following naming convention:
image.imageextension.md
the caption handler accepts markdown formatting
to enable comments add the comments handler (bridge) to the enabled apps, it'll (should) automatically work with xibit
Config options:
- fmts:
file extensions recognised
ex. fmts=(jpg gif png svg)
- thumbsize:
size of thumbnails to generate, accepts
ex. thumbsize='140x'
- previewsize:
size of the previews to generate
ex. previewsize='x460'
check_user:
Enforce authentication
This has been ripped out of the xibit code, if you want to enable perms enforcing, you should add the following to your config:
if ( ! check_user) { #if fyou want to enforce per-group permissions, do "if( ! check_user $group) {"
enabled_apps=() #maybe you want to leave some apps on, i just do this on a per-directory besis
handler_body_main=(echo '<a href="/_users/login">please log in</a>')
}

5
werc/apps/xibit/TODO Normal file
View file

@ -0,0 +1,5 @@
features:
- details list index - filenames with creation, etc..
- if format is image format but not one recognised by browsers, convert it to png for preview and thumbnail viewing
nice css @ http://www.area17.com/03_work/nove/photography/ and http://www.sergiojuncos.com/usa2008/large-2.html and http://jmcpherson.org/photoblog/index.php

91
werc/apps/xibit/app.rc Executable file
View file

@ -0,0 +1,91 @@
#xibit is an app that generates image galeries for werc.
#the license the mit license, see the license file in the distribution's root directory
#until the time i change my mind
#comments and suggestions can come to http://redmine.9souldier.org/projects/xibit0/issues/new or johnny@9souldier.org
fn conf_enable_xibit {
xibit_uri=$conf_wd
conf_enable_app xibit
}
fn xibit_init {
xibit_root=$sitedir$"xibit_uri
#SOMEONE PLEASE FIXME if(! ~ $#xibit_uri 0 && test '( -d '^$"xibit_root^'/_werc/xibit ) -a ( -w '^$"xibit_root^'/_werc/xibit )' && convert -help > /dev/null) {
if(! ~ $#xibit_uri 0 && test -d $"xibit_root/_werc/xibit && test -w $"xibit_root/_werc/xibit && which convert > /dev/null) {
xibitdir=$xibit_root^/_werc/xibit
xibit_uri_file=`{echo $req_path |sed 's,^.*/([^/]+)$,\1,g'}
mkdir -p $"xibitdir/previews
mkdir -p $"xibitdir/thumbs
extraHeaders=($extraHeaders '<style>' `{cat apps/xibit/xibit.css} '</style>')
if( ~ $"req_path */index */)
handler_body_main=xibit_thumb_handler
if not {
xibit_img=`{echo $req_path |sed 's,^.*/([^/]+)(\.[^\.]+)?$,\1,g'}
for(pic in $xibit_img.^$fmts){
if(test -f $xibit_root/^$pic)
handler_body_main=xibit_img_handler
}
if ( ~ $#handler_body_main 0 )
status='xibit cant to anything here'
}
}
}
fn xibit_thumb_handler {
cd $xibit_root
xibitdir=_werc/xibit
rm $"xibitdir/dirstat.md5.tmp > /dev/null >[2] /dev/null
if( ! ~ `{ls -l |md5sum |tee $xibitdir/dirstat.md5.tmp} `{cat $xibitdir/dirstat.md5}) {
mv $xibitdir/dirstat.md5.tmp $xibitdir/dirstat.md5
for(pic in `{ls *.^$fmts >[2] /dev/null}) {
if( ! test -f $"xibitdir/thumbs/^$"pic )
convert $pic -resize $thumbsize $xibitdir/thumbs/^$pic
if( ! test -f $"xibitdir/previews/^$"pic )
convert $pic -resize $previewsize $xibitdir/previews/^$pic
xibit_pics=($xibit_pics $pic)
}
}
if not
for(pic in `{ls *.^$fmts >[2] /dev/null})
xibit_pics=($xibit_pics $pic)
rm $xibitdir/dirstat.md5.tmp > /dev/null >[2] /dev/null
cd $werc_root
if( ! ~ $req_path */details )
template apps/xibit/thumbs.tpl
if not
template apps/xibit/details.tpl
}
fn xibit_img_handler {
cd $xibit_root
for(file in $xibit_uri_file.^$fmts) {
if( test -f $file) {
xibit_img=`{echo $file |sed 's,^.*/([^/]+),\1,g'}
xibit_preview=_werc/xibit/previews/^$xibit_img
if (test -r _werc/xibit/captions/^$xibit_img^.md)
xibit_caption_file=$xibitdir^/captions/^$xibit_img^.md
xibit_nextpic=`{next_pic $xibit_img}
xibit_prevpic=`{prev_pic $xibit_img}
dprint $xibit_nextpic $xibit_prevpic
cd $werc_root
}
}
cd $werc_root
xibit_thumb_handler
}
fn prev_pic {
findre='/^'^$1^'$/!h; /^'^$1^'$/!d; /^'^$1^'$/g;'
if( ! ls -F |sed 1q |grep -s $1 )
ls -F |grep -v '_werc' | sed 's,\*$,,g; /\$/d; s,'',,g' | sed $"findre^'; s,\.[^\.]+$,,'
}
fn next_pic {
findre='/^'^$1^'$/!d; /^'^$1^'/n; p'
if( ! ls -F |tail -1 |grep -s $1 )
ls -F |grep -v '_werc' | sed 's,\*$,,g; /\/$/d; s,'',,g' | sed -n $"findre |sed 's,\.[^\.]+$,,'
}

View file

@ -0,0 +1,14 @@
<div class="images-details">
<ul>
% for (pic in $xibit_pics) {
<li>
<a href="
% echo $pic |sed 's,(.*)\..+$,\1,g'
" class="thumb" >
<img src="%( $xibit_thumbsdir^/^$pic %)" class="thumb"/>
</a>
% identify $xibit_urlroot/^$pic |awk '{print $4}'
</li>
% }
</ul>
</div>

21
werc/apps/xibit/image.tpl Normal file
View file

@ -0,0 +1,21 @@
<div id="main-img">
% if ( ! ~ $#xibit_prevpic 0) {
<a href="%($xibit_prevpic%)#main-img">Previous</a>
% }
% if ( ! ~ $#xibit_nextpic 0 && ! ~ $#xibit_prevpic 0 ) {
/
% }
% if ( ! ~ $#xibit_nextpic 0) {
<a href="%($xibit_nextpic%)#main-img">Next</a>
% }
<div class="main-img" id="mainpic">
<a href="%($xibit_img%)">
<img src="%($xibit_preview%)" />
</a>
</div>
% if ( ! ~ $#xibit_caption_file 0) {
<div class="caption">
% md_handler $xibit_caption_file
</div>
% }
</div>

19
werc/apps/xibit/license Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2009 John Soros
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,11 @@
% for (pic in $xibit_pics){
% picnoext=`{echo $pic |sed 's,(.*)\..+$,\1,g'}
% if(! ~ $pic $xibit_img) {
<a href="%($picnoext%)#main-img" class="thumb" >
<img src="%( _werc/xibit/thumbs/^$pic %)" class="thumb"/>
</a>
% }
% if not {
% template apps/xibit/image.tpl
% }
% }

17
werc/apps/xibit/xibit.css Normal file
View file

@ -0,0 +1,17 @@
.thumbs-index {
float: right;
clear: none;
white-space: nowrap;
}
.thumb {
clear: none;
width: auto;
height: auto;
padding: 5px;
border: 2px;
display: inline;
}
#main-img {
text-align: center;
clear: none;
}