/
RenderBlogEntries.txt
156 lines (144 loc) · 5.8 KB
/
RenderBlogEntries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%META:TOPICINFO{author="micha" comment="reprev" date="1330677805" format="1.1" reprev="15" version="19"}%
%META:TOPICPARENT{name="TopicFunction"}%
%TOC{depth="2"}%
---++ Documentation
%STARTSECTION{name="documentation" type="section"}%
This TopicFunction displays a collection of BlogEntries within the given CATegory and/or TAG.
---+++++ Parameters
* SKIP: offset into the archive
* LIMIT: number of postings to show at max
* CAT: categories to extract (optional)
* TAG: tagged entries to be extracted (optional)
* STICKY: a pattern the Sticky field must match to list the posting see the "Sticky" definition in BlogEntry (optional)
* NOSTICKY: same as STICKY but with inverse logic
%ENDSECTION{name="documentation" type="section"}%
---++ Implementation
<verbatim class="tml">
%STARTINCLUDE%<!-- -->
<noautolink>
%DBQUERY{
"TopicType=~'\bBlogEntry\b'
AND State != 'unpublished'
AND topic != 'WebTopicEditTemplate'
%IF{"defined CAT and '%CAT%' != ''" then="AND topic ISA '%CAT%'"}%
%IF{"defined TAG and '%TAG%' != ''" then="AND Tag=~'\b%TAG%\b'"}%
%IF{"defined STICKY and '%STICKY%' != ''" then="AND Sticky=~'\b%STICKY%\b'"}%
%IF{"defined NOSTICKY and '%NOSTICKY%' != ''" then="AND ! Sticky=~'\b%NOSTICKY%\b'"}%
"
limit="%IF{"defined LIMIT" then="%LIMIT%" else="5"}%"
skip="%IF{"defined SKIP" then="%SKIP%" else="0"}%"
order="created"
reverse="on"
hidenull="on"
web="%BASEWEB%"
header="%IF{"'%SKIP%'!='0'"
then="$dollarpercntDBCALL{
\\"%WEB%.%TOPIC%\\"
section=\\"pagination%IF{"defined STICKY and '%STICKY%'!=''" then="DISABLED"}%\\"
warn=\\"off\\"
LIMIT=\\"%IF{"defined LIMIT" then="%LIMIT%" else="5"}%\\"
SKIP=\\"%IF{"defined SKIP" then="%SKIP%" else="0"}%\\"
COUNT=\\"$count\\"
CLASS=\\"blogTopPagination\\"
PARAMS=\\"%IF{
"defined STICKY and '%STICKY%'!=''" then=";sticky=%STICKY%"
}%%IF{
"defined CAT and '%CAT%'!=''" then=";catname=%CAT%"
}%\\"
}$dollarpercnt<!-- -->"
}%<!-- -->
<div class='blogEntries%IF{"defined STICKY and '%STICKY%' != ''" then=" blogEntriesSticky"}%'>"
format="<div class='blogEntry'>
<div class='foswikiTopicInfo'>
<h2>
$percntMETACOMMENTS{
topic=\"$web.$topic\"
approval=\"on\"
format=\"<div class='blogCommentCount foswikiRight'>$dollarcount</div>\"
limit=\"1\"
singular=\"1\"
plural=\"$dollarcount\"
}$percnt<!-- -->
[[$web.$topic]]
$percntIF{\"'$expand(State)' = 'unpublished'\"
then=\"<span class='foswikiAlert foswikiSmall'>(%MAKETEXT{"unpublished"}%)</span>\"
}$percnt<!-- -->
$percntREDDOT{\"$web.$topic\"}$percnt<!-- -->
<div class='foswikiTopicSummary'>$expand(Summary')</div>
</h2>
<$nopdirtyarea>
$percntTIMESINCE{
\"$expand(createdate)\"
format=\"<nop>$time ago\"
null=\"about now\"
}$percnt </$nopdirtyarea>
| [[%USERSWEB%.$expand(createauthor)][$expand(createauthor)]]
$percntCATINFO{
topic=\"$web.$topic\"
header=\"| \"
}$percnt<!-- -->
$percntTAGINFO{
topic=\"$web.$topic\"
header=\"| \"
}$percnt<!-- -->
</div>
<div class='blogText hyphenate'>
$expand(text) <span class='blogMore'>… [[$web.$topic][%MAKETEXT{"more"}%]]</span>
%CLEAR%
</div>
</div>"
footer="</div>
$percntDBCALL{\"%WEB%.%TOPIC%\"
section=\"pagination%IF{"defined STICKY and '%STICKY%'!=''" then="DISABLED"}%\"
warn=\"off\"
LIMIT=\"%IF{"defined LIMIT" then="%LIMIT%" else="5"}%\"
SKIP=\"%IF{"defined SKIP" then="%SKIP%" else="0"}%\"
COUNT=\"$count\"
CLASS=\"blogBottomPagination\"
PARAMS=\"%IF{
"defined STICKY and '%STICKY%'!=''" then=";sticky=%STICKY%"
}%%IF{
"defined CAT and '%CAT%'!=''" then=";catname=%CAT%"
}%\"
}$percnt<!-- -->"
}%<!-- -->
</noautolink>
<!-- -->%STOPINCLUDE%
</verbatim>
---++ Pagination
<verbatim class="tml">
%STARTSECTION{"pagination"}%<!-- -->
<div class='blogPagination %CLASS% foswikiSmallish'>
%CALC{"$SET(theNextSkip,$EVAL(%SKIP%+%LIMIT%))$SET(thePrevSkip,$EVAL(%SKIP%-%LIMIT%))$IF($GET(thePrevSkip) < 0,$SET(thePrevSkip,0))"}%<!-- -->
<table class='foswikiNullTable' width='100%'>
<tr>
<td class='blogPrev'>
<a %IF{"%SKIP% = 0" then="style='display:none'"}%' href='%SCRIPTURL{"view"}%/%BASEWEB%/%BASETOPIC%?skip=%CALC{"$GET(thePrevSkip)"}%;limit=%LIMIT%%IF{"defined PARAMS" then="%PARAMS%"}%'>« %MAKETEXT{"previous page"}%</a>
</td>
<td class='blogNext' align='right'>
<a %IF{"%CALC{"$GET(theNextSkip)"}% >= %COUNT%" then="style='display:none'"}% href='%SCRIPTURL{"view"}%/%BASEWEB%/%BASETOPIC%?skip=%CALC{"$GET(theNextSkip)"}%;limit=%LIMIT%%IF{"defined PARAMS" then="%PARAMS%"}%'>%MAKETEXT{"next page"}% »</a>
</td>
</tr>
</table>
</div><!-- -->%ENDSECTION{"pagination"}%
</verbatim>
---++ Test
---+++ no stickiness
%TWISTY%
%DBCALL{"%TOPIC%"}%
%ENDTWISTY%
---+++ stickiness
%TWISTY%
%DBCALL{"%TOPIC%" STICKY="frontpage"}%
%ENDTWISTY%
%DBCALL{"Applications.RenderFunctionCallers"}%
---++ Copyright
© 2005-2011 http://michaeldaumconsulting.com
%DBCALL{"Applications.GnuGeneralPublicLicense" section="notice"}%
</verbatim>
%META:FORM{name="Applications.ApplicationTopic"}%
%META:FIELD{name="TopicType" title="TopicType" value="DocuTopic, TopicFunction"}%
%META:FIELD{name="TopicTitle" attributes="" title="<nop>TopicTitle" value=""}%
%META:FIELD{name="Summary" attributes="c" title="Summary" value="Render a set of postings to leaf through"}%
%META:FIELD{name="WikiApplication" attributes="" title="WikiApplication" value="BlogApp"}%
%META:PREFERENCE{name="EDIT_TEMPLATE" title="EDIT_TEMPLATE" type="Set" value="Applications.WikiTopicEdit"}%