base_html.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. " <title>", 43);
  50. #line 4
  51. {
  52. #line 4
  53. const char *tmp;
  54. #line 4
  55. tmp=onion_dict_get(context, "title");
  56. #line 4
  57. if (tmp)
  58. #line 4
  59. onion_response_write_html_safe(res, tmp);
  60. #line 4
  61. }
  62. onion_response_write(res, "</title>\n"
  63. " </head>\n"
  64. " <body>\n"
  65. "", 28);
  66. #line 7
  67. {
  68. #line 7
  69. void (*f)(onion_dict *context, onion_response *res);
  70. #line 7
  71. f=(void*)onion_dict_get(context, "__block_content__");
  72. #line 7
  73. if (f)
  74. #line 7
  75. f(context, res);
  76. #line 7
  77. }
  78. onion_response_write(res, " \n"
  79. " </body>\n"
  80. "</html>\n"
  81. "", 21);
  82. #line 10
  83. if (!has_context)
  84. #line 10
  85. onion_dict_free(context);
  86. #line 1
  87. }
  88. #line 1
  89. void base_html__block_content(onion_dict *context, onion_response *res){
  90. #line 1
  91. onion_response_write(res, "No content", 10);
  92. #line 1
  93. }