close to prerelase
This commit is contained in:
parent
e55fbb5b67
commit
31022358ed
181 changed files with 2118 additions and 141 deletions
144
werc/apps/ico/app.rc
Normal file
144
werc/apps/ico/app.rc
Normal file
|
@ -0,0 +1,144 @@
|
|||
fn conf_enable_ico {
|
||||
ico_uri=$conf_wd
|
||||
ico_dirs=$*
|
||||
if(~ $#ico_dirs 0)
|
||||
ico_dirs=( . )
|
||||
conf_enable_app ico
|
||||
|
||||
if(~ $"conf_ico_editors '')
|
||||
conf_ico_editors=ico-editors
|
||||
|
||||
if(~ $"conf_max_posts_per_page '')
|
||||
conf_max_posts_per_page=32
|
||||
|
||||
if(~ $"conf_ico_categories '')
|
||||
conf_ico_categories=(general)
|
||||
|
||||
if(~ $"conf_ico_max_image_size '')
|
||||
conf_ico_max_image_size=5242880
|
||||
}
|
||||
|
||||
fn ico_init {
|
||||
if(~ $#ico_dirs 0 && ~ $req_path */[iI]co/*) {
|
||||
ico_uri=`{echo $req_path | sed 's,(/[iI]co/).*,\1,'}
|
||||
ico_dirs=( . )
|
||||
}
|
||||
|
||||
if(! ~ $#ico_dirs 0) {
|
||||
ico_url=$base_url^$ico_uri
|
||||
ico_root=$sitedir^$ico_uri
|
||||
if(check_user $conf_ico_editors) {
|
||||
editor_mode=on
|
||||
if(~ $"post_arg_date '')
|
||||
post_date=`{/bin/date -I|sed 's,-,/,g'}
|
||||
if not
|
||||
post_date=$post_arg_date
|
||||
ll_add handlers_foot_body template `{get_lib_file ico/foot.tpl apps/ico/foot.tpl}
|
||||
}
|
||||
|
||||
if(~ $req_path $ico_uri) {
|
||||
handler_body_main=ico_body
|
||||
u=$ico_uri'index'
|
||||
extraHeaders=$"extraHeaders ^ \
|
||||
'<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />
|
||||
<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />'
|
||||
}
|
||||
if not if(~ $req_path $ico_uri^category/*) {
|
||||
category=`{echo $req_path | sed 's!.*/!!; s/_/ /g'}
|
||||
handler_body_main=ico_category_body
|
||||
}
|
||||
if not if(~ $req_path $ico_uri^index.atom)
|
||||
ico_setup_feed_handlers atom.tpl 'application/atom+xml'
|
||||
if not if(~ $req_path $ico_uri^index.rss)
|
||||
ico_setup_feed_handlers rss20.tpl 'application/rss+xml'
|
||||
if not if(~ $req_path $ico_uri^new_post && ! ~ $#editor_mode 0) {
|
||||
handler_body_main=( tpl_handler `{get_lib_file ico/new_post.tpl apps/ico/new_post.tpl} )
|
||||
if(~ $REQUEST_METHOD POST) {
|
||||
if(mkicopost $"post_arg_body $"post_date $"post_arg_title $"post_arg_categories $"post_arg_loc $"post_arg_loc_link $"post_arg_link $"post_arg_short_desc $"post_arg_poster $"post_arg_edate)
|
||||
post_redirect $ico_uri
|
||||
if not
|
||||
notify_errors=$status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn ico_category_body {
|
||||
template apps/ico/event_list_cat.tpl
|
||||
}
|
||||
|
||||
fn ico_body {
|
||||
template apps/ico/event_list_all.tpl
|
||||
}
|
||||
|
||||
fn get_post_list {
|
||||
ls -F $*^/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ >[2]/dev/null |
|
||||
sed -n '/'^$forbidden_uri_chars^'/d; /\/$/p' |
|
||||
sort -r |
|
||||
sed -e $conf_max_posts_per_page^'q'
|
||||
}
|
||||
|
||||
fn mkicopost {
|
||||
icotext=$1
|
||||
icodate=$2
|
||||
icotitle=$3
|
||||
icocategories=$4
|
||||
icolocation=$5
|
||||
icolocationlink=$6
|
||||
icoeventlink=$7
|
||||
icoshortdesc=$8
|
||||
icoposterpath=$9
|
||||
icoexpireddate=$10
|
||||
_status=()
|
||||
postdate=`{/bin/date -I|sed 's,-,/,g'}
|
||||
if(~ $"icotext '')
|
||||
_status=($_status 'You need to provide a post body.')
|
||||
if(! ~ $"postdate [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])
|
||||
_status=($_status 'Invalid date: '''^$"postdate^'''')
|
||||
|
||||
if(~ $#_status 0) {
|
||||
umask 022
|
||||
ddir=$ico_root^$postdate^'/'
|
||||
n=`{ls $ddir >[2]/dev/null | wc -l}
|
||||
mkdir -p $ddir^$n
|
||||
|
||||
post_link='/'$postdate^'/'$n
|
||||
|
||||
category_links=''
|
||||
for(cat in `{echo $icocategories}) {
|
||||
if(! ~ $cat '') {
|
||||
cat_link=`{echo -n $cat | sed 's/ /_/g'}
|
||||
category_links=$category_links'<div>[<a href='$ico_uri'category/'$cat_link'>'$cat'</a>]</div> '
|
||||
}
|
||||
}
|
||||
|
||||
icopostlink='/'^$postdate^'/'^$n^'/'
|
||||
|
||||
template apps/ico/post.tpl > $ddir^$n^'/index.html'
|
||||
|
||||
# Create the main categories directory
|
||||
categories_dir=$ico_root^'categories'
|
||||
mkdir -p $categories_dir
|
||||
|
||||
# Update category files
|
||||
for(cat in `{echo $icocategories}) {
|
||||
if(! ~ $cat '') {
|
||||
cat_file=$categories_dir^'/'^`{echo -n $cat | sed 's/ /_/g'}^'.txt'
|
||||
echo $post_link >> $cat_file
|
||||
}
|
||||
}
|
||||
}
|
||||
status=$_status
|
||||
}
|
||||
|
||||
fn get_post_by_category {
|
||||
cat_dir=$ico_root^'categories'
|
||||
cat_file=$cat_dir^'/'^`{echo -n $1 | sed 's/ /_/g'}^'.txt'
|
||||
if(test -f $cat_file) {
|
||||
cat $cat_file | sort -r | sed $conf_max_posts_per_page^'q'
|
||||
}
|
||||
}
|
||||
|
||||
fn list_categories {
|
||||
ls $ico_root^'categories/'*.txt | sed 's!.*/!!; s!\.txt$!!; s!_! !g'
|
||||
}
|
25
werc/apps/ico/event_list_all.tpl
Normal file
25
werc/apps/ico/event_list_all.tpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
% if (! ~ $"icoTitle '')
|
||||
<h1>%($"icoTitle%)</h1>
|
||||
% if (! ~ $"icoDesc '')
|
||||
<p class="ico_desc">%($"icoDesc%)</p>
|
||||
<fieldset class="categories_box">
|
||||
<legend>Catagories</legend>
|
||||
<div class="categories">
|
||||
%{
|
||||
for(cat in `{list_categories}) {
|
||||
echo '<a href="'$ico_uri'category/'^`{echo -n $cat | sed 's/ /_/g'}^'">'$cat'</a> '
|
||||
}
|
||||
%}
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="icofeed">
|
||||
|
||||
%{
|
||||
for(p in `{get_post_list $ico_root^$ico_dirs}) {
|
||||
echo '<div class="post">'
|
||||
cat $p/index.html
|
||||
echo '</div>'
|
||||
}
|
||||
%}
|
||||
</div>
|
||||
<p>Check out the <a href="/archive">archive</a> to see past events.</p>
|
23
werc/apps/ico/event_list_cat.tpl
Normal file
23
werc/apps/ico/event_list_cat.tpl
Normal file
|
@ -0,0 +1,23 @@
|
|||
<h1>Posts in category: %($category%)</h1>
|
||||
<p class="ico_desc">You are seeing events in the <strong>%($category%)</strong> category. Click <a href="/">here</a> to go home!</p>
|
||||
<fieldset class="categories_box">
|
||||
<legend>Catagories</legend>
|
||||
<div class="categories">
|
||||
<a href="/">all</a>
|
||||
%{
|
||||
for(cat in `{list_categories}) {
|
||||
echo '<a href="'$ico_uri'category/'^`{echo -n $cat | sed 's/ /_/g'}^'">'$cat'</a> '
|
||||
}
|
||||
%}
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="icofeed">
|
||||
%{
|
||||
for(p in `{get_post_by_category $category}) {
|
||||
echo '<div class="post">'
|
||||
cat $sitedir$p/index.html
|
||||
echo '</div>'
|
||||
}
|
||||
%}
|
||||
</div>
|
||||
<p>Check out the <a href="/archive">archive</a> to see past events.</p>
|
1
werc/apps/ico/foot.tpl
Normal file
1
werc/apps/ico/foot.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
<div><p>[ <a href="/new_post">Make a new post</a> ]</p></div>
|
17
werc/apps/ico/new_post.tpl
Normal file
17
werc/apps/ico/new_post.tpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
<div>
|
||||
% notices_handler
|
||||
<form method="POST"><fieldset>
|
||||
<legend>Submit a new ico post</legend>
|
||||
<label>Title: <input size="64" type="text" name="title" value="%($"post_arg_title%)" required /></label>
|
||||
<label>Event Date (Displayed): <input size="10" type="text" name="date" value="%($"post_date%)" /></label>
|
||||
<label for="dateInput">Expire Date [YYYY-MM-DD] <small>(usually the date of the show)</small>: <input type="text" name="edate" id="dateInput" placeholder="YYYY-MM-DD" pattern="\d{4}-\d{2}-\d{2}" required value="%($"post_arg_edate%)"/></label>
|
||||
<label>Categories <small>(space-separated)</small>: <input size="64" type="text" name="categories" value="%($"post_arg_categories%)" /></label>
|
||||
<label>Location: <input size="64" type="text" name="loc" value="%($"post_arg_loc%)" /></label>
|
||||
<label>Location Link: <input size="64" type="text" name="loc_link" value="%($"post_arg_loc_link%)" /></label>
|
||||
<label>Event Link/Website: <input size="64" type="text" name="link" value="%($"post_arg_link%)" /></label>
|
||||
<label>Short Description: <textarea cols="94" rows="1" name="short_desc">%($"post_arg_short_desc%)</textarea></label>
|
||||
<label>Description: <textarea cols="94" rows="16" name="body">%($"post_arg_body%)</textarea></label>
|
||||
<label>Event Poster Image Link: <input size="64" type="text" name="poster" value="%($"post_arg_poster%)" /></label><br />
|
||||
<input type="submit" value="Post" />
|
||||
</fieldset></form>
|
||||
</div>
|
20
werc/apps/ico/post.tpl
Normal file
20
werc/apps/ico/post.tpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!-- EXPIRES: "%($icoexpireddate%)" -->
|
||||
<div class="event_box">
|
||||
<a href="%($icopostlink%)" class="event_box_link"><span class="link_span"></span></a>
|
||||
<a href="%($icopostlink%)"><h2>%($icotitle%)</h2></a>
|
||||
<div class="event_info">
|
||||
<div class="date">%($icodate%)</div>
|
||||
<div class="location"><a href="%($icolocationlink%)">%($icolocation%)</a></div>
|
||||
<div class="event_link"><a href="%($icoeventlink%)">Event Link</a></div>
|
||||
<div class="cat_list">%($category_links%)</div>
|
||||
<div class="short_desc">%($icoshortdesc%)</div>
|
||||
</div>
|
||||
% if(! ~ $"icoposterpath '') {
|
||||
<div class="event_poster">
|
||||
<a href="%($icoeventlink%)" class="event_img_link"><img src="%($icoposterpath%)" alt="Event Poster" /></a>
|
||||
</div>
|
||||
% }
|
||||
<div class="event_body">
|
||||
%($icotext%)
|
||||
</div>
|
||||
</div>
|
25
werc/apps/ico/rss20.tpl
Normal file
25
werc/apps/ico/rss20.tpl
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<atom:link href="%($base_url^$req_path%)" rel="self" type="application/rss+xml" />
|
||||
<title><![CDATA[%($siteTitle%)]]></title>
|
||||
<link>%($base_url^$req_path%)</link>
|
||||
<description><![CDATA[%($icoDesc%)]]></description>
|
||||
<language>en-us</language>
|
||||
<generator>werc ico app</generator>
|
||||
<lastBuildDate>%($lastBuildDate%)</lastBuildDate>
|
||||
%{
|
||||
for(f in `{get_post_list $ico_root$ico_dirs}){
|
||||
statpost $f
|
||||
%}
|
||||
<item>
|
||||
<title><![CDATA[%($title%)]]></title>
|
||||
<link>%($post_uri%)</link>
|
||||
<guid isPermaLink="true">%($post_uri%)</guid>
|
||||
<pubDate>%($pubdate%)</pubDate>
|
||||
<description><![CDATA[%($summary%)]]></description>
|
||||
<category>%($categories%)</category>
|
||||
</item>
|
||||
% }
|
||||
</channel>
|
||||
</rss>
|
Loading…
Add table
Add a link
Reference in a new issue