]> git.plutz.net Git - confetti/blobdiff - templates/categories.html.sh
cleanup of category handling
[confetti] / templates / categories.html.sh
index 5375965027dd10b91f8d10db4494c614c978a0a3..e266e1f24e18b704208433cc843619b0614e8bc0 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright 2015 Paul Hänsch
+# Copyright 2015, 2017 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 
 cat_listing(){
   list_categories | while read cat; do
-    cat <<-END
-       <li>${cat}<button type="submit" name="remove" value="${cat}">$(l10n cat_remove)</button></li>
-       END
+    printf '<li>%s<button type="submit" name="remove" value="%s">%s</button></li>\n' \
+           "$(htmlsafe "$cat")" "$(attribsafe "$cat")" "$(l10n cat_remove)"
   done
 }
 
 list_catsel(){
   card="$1"
-  cats="$(get_categories $card)"
+  cats="$(get_categories "$card")"
 
   list_categories |while read cat; do
-  cat <<-END
-       <li><label><input type="checkbox" name="$card" value="$cat"
-       $(printf %s "$cats" |grep -qF "$cat" && printf %s 'checked="checked"')>${cat}</label></li>
-       END
+    printf '<li><label><input %s type="checkbox" name="%s" value="%s">%s</label></li>' \
+          "$(printf %s "$cats" |grep -qF "$cat" && printf 'checked="checked"')" \
+           "$(attribsafe "$card")" "$(attribsafe "$cat")" "$(htmlsafe "$cat")" 
   done
 }
 
 display_catsel(){
   card="$1"
-  cat <<-END
-       <li><h2>$(get_name "$card")</h2><ul>$(list_catsel "$card")</ul></li>
-       END
+  printf '<li><h2>%s</h2><ul>' "$(htmlsafe "$(get_name "$card")")"
+  list_catsel "$card"
+  printf '</ul></li>'
 }
 
 cat <<EOF
@@ -60,12 +58,16 @@ cat <<EOF
     <button type="submit" name="submit" value="submit">$(l10n cat_update)</button>
   </fieldset>
   <ul class="namelist">
-    $(listcards |while read card; do display_catsel "$card"; done )
+EOF
+listcards \
+| while read card; do
+  display_catsel "$card"
+done
+cat <<EOF
   </ul>
   <fieldset>
     <button type="submit" name="submit" value="submit">$(l10n cat_update)</button>
   </fieldset>
 </form>
-
 EOF