fortunes_html.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /** Autogenerated by otemplate v. 0.2.0 */
  2. #include <libintl.h>
  3. #include <string.h>
  4. #include <onion/onion.h>
  5. #include <onion/dict.h>
  6. typedef struct dict_res_t{
  7. onion_dict *dict;
  8. onion_response *res;
  9. }dict_res;
  10. void fortunes_html_blocks_init(onion_dict *context);
  11. void fortunes_html(onion_dict *context, onion_response *res);
  12. void base_html(onion_dict *context, onion_response *res);
  13. void fortunes_html__block_content(onion_dict *context, onion_response *res);
  14. static void otemplate_f_0000(dict_res *dr, const char *key, const void *value, int flags);
  15. static void otemplate_f_0001(onion_dict *context, onion_response *res);
  16. onion_connection_status fortunes_html_handler_page(onion_dict *context, onion_request *req, onion_response *res){
  17. fortunes_html(context, res);
  18. return OCS_PROCESSED;
  19. }
  20. onion_handler *fortunes_html_handler(onion_dict *context){
  21. return onion_handler_new((onion_handler_handler)fortunes_html_handler_page, context, (onion_handler_private_data_free)onion_dict_free);
  22. }
  23. onion_connection_status fortunes_html_template(onion_dict *context, onion_request *req, onion_response *res){
  24. if (context) onion_dict_add(context, "LANG", onion_request_get_language_code(req), OD_FREE_VALUE);
  25. fortunes_html(context, res);
  26. if (context) onion_dict_free(context);
  27. return OCS_PROCESSED;
  28. }
  29. #line 1 "fortunes.html"
  30. #line 1
  31. void fortunes_html_blocks_init(onion_dict *context){
  32. #line 1
  33. if (!onion_dict_get(context, "__block_content__"))
  34. onion_dict_add(context, "__block_content__", fortunes_html__block_content, 0);
  35. #line 1
  36. }
  37. #line 1
  38. void fortunes_html(onion_dict *context, onion_response *res){
  39. #line 1
  40. #line 1
  41. int has_context=(context!=NULL);
  42. #line 1
  43. if (!has_context)
  44. #line 1
  45. context=onion_dict_new();
  46. #line 1
  47. #line 1
  48. fortunes_html_blocks_init(context);
  49. #line 1
  50. base_html(context, res);
  51. #line 17
  52. if (!has_context)
  53. #line 17
  54. onion_dict_free(context);
  55. #line 1
  56. }
  57. #line 1
  58. void fortunes_html__block_content(onion_dict *context, onion_response *res){
  59. #line 1
  60. onion_response_write(res, "\n"
  61. "<table>\n"
  62. "<tr>\n"
  63. "<th>id</th>\n"
  64. "<th>message</th>\n"
  65. "</tr>\n"
  66. "", 49);
  67. #line 8
  68. {
  69. #line 8
  70. onion_dict *loopdict=onion_dict_get_dict(context, "fortunes");
  71. #line 8
  72. onion_dict *tmpcontext=onion_dict_hard_dup(context);
  73. #line 8
  74. if (loopdict){
  75. #line 8
  76. dict_res dr={ .dict = tmpcontext, .res=res };
  77. #line 8
  78. onion_dict_preorder(loopdict,
  79. #line 13
  80. otemplate_f_0000, &dr);
  81. #line 13
  82. }
  83. #line 13
  84. onion_dict_free(tmpcontext);
  85. #line 13
  86. }
  87. onion_response_write(res, "\n"
  88. "</table>\n"
  89. "", 10);
  90. #line 1
  91. }
  92. #line 1
  93. static void otemplate_f_0000(dict_res *dr, const char *key, const void *value, int flags){
  94. #line 1
  95. #line 8
  96. onion_dict_add(dr->dict, "f", value, OD_DUP_VALUE|OD_REPLACE|(flags&OD_TYPE_MASK));
  97. #line 13
  98. otemplate_f_0001(dr->dict, dr->res);
  99. #line 1
  100. }
  101. #line 1
  102. static void otemplate_f_0001(onion_dict *context, onion_response *res){
  103. #line 1
  104. onion_response_write(res, "\n"
  105. "<tr>\n"
  106. "<td>", 10);
  107. #line 10
  108. {
  109. #line 10
  110. const char *tmp;
  111. #line 10
  112. tmp=onion_dict_rget(context
  113. #line 10
  114. , "f"
  115. #line 10
  116. , "id"
  117. #line 10
  118. , NULL);
  119. #line 10
  120. if (tmp)
  121. #line 10
  122. onion_response_write_html_safe(res, tmp);
  123. #line 10
  124. }
  125. onion_response_write(res, "</td>\n"
  126. "<td>", 10);
  127. #line 11
  128. {
  129. #line 11
  130. const char *tmp;
  131. #line 11
  132. tmp=onion_dict_rget(context
  133. #line 11
  134. , "f"
  135. #line 11
  136. , "message"
  137. #line 11
  138. , NULL);
  139. #line 11
  140. if (tmp)
  141. #line 11
  142. onion_response_write_html_safe(res, tmp);
  143. #line 11
  144. }
  145. onion_response_write(res, "</td>\n"
  146. "</tr>\n"
  147. "", 12);
  148. #line 1
  149. }