(* This file is part of gikia-common.
*
* gikia-common is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gikia-common is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gikia-common. If not, see .
*
* Copyright 2010 Alexander Markov *)
open Lwt
open Eliom_common
open Eliom_service
open Eliom_parameter
open Eliom_registration
open Eliom_duce
open Eliom_duce.Xhtml
open Xhtml_types_duce
open ExtLib
open Printf
open Utils
let head (links: ( {{ [Xhtml_types_duce.link*] }} ) ) title : Xhtml_types_duce.head =
{{
[
[]
[]
!links
(utf title)] }}
let htmltext_page prefix (links:{{ [Xhtml_types_duce.link*] }}) title content =
let head = head links title in
let read p =
catch
(fun () -> Io.read p)
(fun _ -> return "") in
read (prefix ^/ "header.html") >>= fun header ->
read (prefix ^/ "footer.html") >>= fun footer ->
return (sprintf
"%s%s%s%s"
(Duce_printer.string_of_xhtml head)
header
content
footer)
let duce_page prefix (links:{{ [Xhtml_types_duce.link*] }}) title (content: {{ Xhtml_types_duce.blocks }} ) =
htmltext_page prefix links title (Duce_printer.string_of_xhtmls content)
let cache_wrap get prefix _a =
Cache.from get prefix _a
let send = Html_text.send
let cache_wrap_send get prefix _a =
cache_wrap get prefix _a >>= fun page ->
send page