base_html.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 base_html_blocks_init(onion_dict *context);
  11. void base_html(onion_dict *context, onion_response *res);
  12. void base_html__block_content(onion_dict *context, onion_response *res);
  13. onion_connection_status base_html_handler_page(onion_dict *context, onion_request *req, onion_response *res){
  14. base_html(context, res);
  15. return OCS_PROCESSED;
  16. }
  17. onion_handler *base_html_handler(onion_dict *context){
  18. return onion_handler_new((onion_handler_handler)base_html_handler_page, context, (onion_handler_private_data_free)onion_dict_free);
  19. }
  20. onion_connection_status base_html_template(onion_dict *context, onion_request *req, onion_response *res){
  21. if (context) onion_dict_add(context, "LANG", onion_request_get_language_code(req), OD_FREE_VALUE);
  22. base_html(context, res);
  23. if (context) onion_dict_free(context);
  24. return OCS_PROCESSED;
  25. }
  26. #line 1 "base.html"
  27. #line 1
  28. void base_html_blocks_init(onion_dict *context){
  29. #line 1
  30. if (!onion_dict_get(context, "__block_content__"))
  31. onion_dict_add(context, "__block_content__", base_html__block_content, 0);
  32. #line 1
  33. }
  34. #line 1
  35. void base_html(onion_dict *context, onion_response *res){
  36. #line 1
  37. #line 1
  38. int has_context=(context!=NULL);
  39. #line 1
  40. if (!has_context)
  41. #line 1
  42. context=onion_dict_new();
  43. #line 1
  44. #line 1
  45. base_html_blocks_init(context);
  46. onion_response_write(res, "<!DOCTYPE html>\n"
  47. "<html>\n"
  48. " <head>\n"
  49. " <meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\"/>\n"
  50. " <title>", 116);
  51. #line 5
  52. {
  53. #line 5
  54. const char *tmp;
  55. #line 5
  56. tmp=onion_dict_get(context, "title");
  57. #line 5
  58. if (tmp)
  59. #line 5
  60. onion_response_write_html_safe(res, tmp);
  61. #line 5
  62. }
  63. onion_response_write(res, "</title>\n"
  64. " </head>\n"
  65. " <body>\n"
  66. "", 28);
  67. #line 8
  68. {
  69. #line 8
  70. void (*f)(onion_dict *context, onion_response *res);
  71. #line 8
  72. f=(void*)onion_dict_get(context, "__block_content__");
  73. #line 8
  74. if (f)
  75. #line 8
  76. f(context, res);
  77. #line 8
  78. }
  79. onion_response_write(res, " \n"
  80. " </body>\n"
  81. "</html>\n"
  82. "", 21);
  83. #line 11
  84. if (!has_context)
  85. #line 11
  86. onion_dict_free(context);
  87. #line 1
  88. }
  89. #line 1
  90. void base_html__block_content(onion_dict *context, onion_response *res){
  91. #line 1
  92. onion_response_write(res, "No content", 10);
  93. #line 1
  94. }