cookutils rev 605

cooker.cgi: add more_button function
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 07 13:52:25 2013 +0000 (2013-08-07)
parents 579cd983c244
children 2bc594a71616
files web/cooker.cgi
line diff
     1.1 --- a/web/cooker.cgi	Fri Jul 26 17:55:18 2013 +0000
     1.2 +++ b/web/cooker.cgi	Wed Aug 07 13:52:25 2013 +0000
     1.3 @@ -108,6 +108,12 @@
     1.4  	done
     1.5  }
     1.6  
     1.7 +# Optional full list button
     1.8 +more_button() {
     1.9 +	[ $(wc -l ${3:-$CACHE/$1}) -gt ${4:-12} ] &&
    1.10 +	echo "<a class=\"button\" href=\"cooker.cgi?file=$1\">$2</a>"
    1.11 +}
    1.12 +
    1.13  # xHTML header. Pages can be customized with a separated html.header file.
    1.14  if [ -f "header.html" ]; then
    1.15  	cat header.html
    1.16 @@ -345,14 +351,14 @@
    1.17  <pre>
    1.18  $(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
    1.19  </pre>
    1.20 -<a class="button" href="cooker.cgi?file=activity">More activity</a>
    1.21 +$(more_button activity "More activity" $CACHE/activity 12)
    1.22  
    1.23  <a name="cooknotes"></a>
    1.24  <h2>Cooknotes</h2>
    1.25  <pre>
    1.26  $(tac $cooknotes | head -n 12 | syntax_highlighter activity)
    1.27  </pre>
    1.28 -<a class="button" href="cooker.cgi?file=cooknotes">More notes</a>
    1.29 +$(more_button cooknotes "More notes" $cooknotes 12)
    1.30  
    1.31  <a name="commits"></a>
    1.32  <h2>Commits</h2>
    1.33 @@ -365,14 +371,14 @@
    1.34  <pre>
    1.35  $(cat $cooklist | head -n 20)
    1.36  </pre>
    1.37 -<a class="button" href="cooker.cgi?file=cooklist">Full cooklist</a>
    1.38 +$(more_button cooklist "Full cooklist" $cooklist 20)
    1.39  
    1.40  <a name="broken"></a>
    1.41  <h2>Broken</h2>
    1.42  <pre>
    1.43  $(cat $broken | head -n 20 | sed s"#^[^']*#<a href='cooker.cgi?pkg=\0'>\0</a>#"g)
    1.44  </pre>
    1.45 -<a class="button" href="cooker.cgi?file=broken">All broken packages</a>
    1.46 +$(more_button broken "All broken packages" $broken 20)
    1.47  
    1.48  <a name="blocked"></a>
    1.49  <h2>Blocked</h2>