mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Introduce the server functionality in the kiwix-lib.
This code is mainly copied from kiwix-tools. But : - Move all the response thing in a new class Response. - This Response class is responsible to handle all the MHD_response configuration. This way the server handle a global object and do no call to MHD_response* - Server uses a lot more the templating system with mustache. There are still few regex operations (because we need to change a content already existing). - By default, the server serves the content using the id as name. - Server creates a new Searcher per request. This way, we don't have to protect the search for multi-thread and we can do several search in the same time. - search results are not cached, this will allow future improvement in the search algorithm. - the home page is not cached. - Few more verbose information (number of request served, time spend to respond to a request). TOOD: - Readd interface selection. - Do Android wrapper. - Remove KiwixServer (who use a external process). -
This commit is contained in:
13
static/templates/404.html
Normal file
13
static/templates/404.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
||||
<title>Content not found</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Not Found</h1>
|
||||
<p>
|
||||
The requested URL "{{url}}" was not found on this server.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
28
static/templates/head_part.html
Normal file
28
static/templates/head_part.html
Normal file
@ -0,0 +1,28 @@
|
||||
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="{{root}}/skin/taskbar.css" rel="Stylesheet" />
|
||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/external/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
var jk = jQuery.noConflict();
|
||||
jk(function() {
|
||||
jk( "#kiwixsearchbox" ).autocomplete({
|
||||
|
||||
source: "{{root}}/suggest?content={{#urlencoded}}{{{content}}}{{/urlencoded}}",
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
|
||||
select: function(event, ui) {
|
||||
jk( "#kiwixsearchbox" ).val(ui.item.value);
|
||||
jk( "#kiwixsearchform" ).submit();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/* cybook hack */
|
||||
if (navigator.userAgent.indexOf("bookeen/cybook") != -1) {
|
||||
jk("html").addClass("cybook");
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="{{root}}/skin/taskbar.js" async></script>
|
68
static/templates/index.html
Normal file
68
static/templates/index.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Welcome to Kiwix Server</title>
|
||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/external/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
|
||||
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
background:
|
||||
radial-gradient(#EEEEEE 15%, transparent 16%) 0 0,
|
||||
radial-gradient(#EEEEEE 15%, transparent 16%) 8px 8px,
|
||||
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px,
|
||||
radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;
|
||||
background-color:#E8E8E8;
|
||||
background-size:16px 16px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 1100px;
|
||||
}
|
||||
.book__list { text-align: center; }
|
||||
.book {
|
||||
display: inline-block; vertical-align: bottom; margin: 8px; padding: 12px 15px; width: 300px;
|
||||
border: 1px solid #ccc; border-radius: 8px;
|
||||
text-align: left; color: #000; font-family: sans-serif; font-size: 13px;
|
||||
background-color:#F1F1F1;
|
||||
box-shadow: 2px 2px 5px 0px #ccc;
|
||||
}
|
||||
.book:hover { background-color: #F9F9F9; box-shadow: none;}
|
||||
.book__background { background-repeat: no-repeat; background-size: auto; background-position: top right; }
|
||||
.book__title {
|
||||
padding: 0 55px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: 18px; color: #0645ad;
|
||||
}
|
||||
.book__description {
|
||||
padding: 5px 55px 5px 0px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
font-size: 15px;
|
||||
}
|
||||
.book__info { line-height: 18px; color: #777; font-weight: bold; font-size: 13px; }
|
||||
</style>
|
||||
<script type="text/javascript" src="{{root}}/skin/taskbar.js" async></script>
|
||||
</head>
|
||||
<body class="kiwix">
|
||||
|
||||
<div class="kiwix">
|
||||
<div class='book__list'>
|
||||
{{#books}}
|
||||
<a href="{{root}}/{{name}}">
|
||||
<div class='book'>
|
||||
<div class='book__background' style="background-image: url('{{root}}/meta?content={{#urlencoded}}{{{name}}}{{/urlencoded}}&name=favicon');">
|
||||
<div class='book__title' title='{{title}}'>{{title}}</div>
|
||||
<div class='book__description' title='{{description}}'>{{description}}</div>
|
||||
<div class='book__info'>{{articleCount}} articles, {{mediaCount}} medias</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{{/books}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="kiwixfooter">
|
||||
Powered by <a href="https://kiwix.org">Kiwix</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
7
static/templates/suggestion.json
Normal file
7
static/templates/suggestion.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{{#suggestions}}{{^first}},{{/first}}
|
||||
{
|
||||
"value" : "{{value}}",
|
||||
"label" : "{{& label}}"
|
||||
}{{/suggestions}}
|
||||
]
|
26
static/templates/taskbar_part.html
Normal file
26
static/templates/taskbar_part.html
Normal file
@ -0,0 +1,26 @@
|
||||
<span class="kiwix">
|
||||
<span id="kiwixtoolbar" class="ui-widget-header">
|
||||
<div class="kiwix_centered">
|
||||
<div class="kiwix_searchform">
|
||||
<form class="kiwixsearch" method="GET" action="{{root}}/search" id="kiwixsearchform">
|
||||
{{#hascontent}}<input type="hidden" name="content" value="{{content}}" />{{/hascontent}}
|
||||
<label for="kiwixsearchbox">🔍</label>
|
||||
<input autocomplete="off" class="ui-autocomplete-input" id="kiwixsearchbox" name="pattern" type="text">
|
||||
</form>
|
||||
</div>
|
||||
{{#hascontent}}
|
||||
<input type="checkbox" id="kiwix_button_show_toggle">
|
||||
<label for="kiwix_button_show_toggle"><img src="{{root}}/skin/caret.png" alt=""></label>
|
||||
<div class="kiwix_button_cont">
|
||||
{{#withlibrarybutton}}
|
||||
<a id="kiwix_serve_taskbar_library_button" href="{{root}}/"><button>🏠</button></a>
|
||||
{{/withlibrarybutton}}
|
||||
<a id="kiwix_serve_taskbar_home_button" href="{{root}}/{{content}}/"><button>{{title}}</button></a>
|
||||
<a id="kiwix_serve_taskbar_random_button"
|
||||
href="{{root}}/random?content={{#urlencoded}}{{{content}}}{{/urlencoded}}"><button>🎲</button></a>
|
||||
</div>
|
||||
{{/hascontent}}
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
<div style="display: block; height: 5em;"></div>
|
Reference in New Issue
Block a user