diff --git a/meson.build b/meson.build index 3ca19a3..5c55f48 100644 --- a/meson.build +++ b/meson.build @@ -37,4 +37,5 @@ endif all_deps = [thread_dep, kiwixlib_dep, microhttpd_dep, ctpp2_dep] #subdir('include') +subdir('static') subdir('src') diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 760b617..ad0435e 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -66,7 +66,7 @@ extern "C" { #include #include #include -#include +#include "server-resources.h" #ifndef _WIN32 #include @@ -91,7 +91,6 @@ static pthread_mutex_t mapLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t welcomeLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t searcherLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t compressorLock = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t resourceLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t verboseFlagLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mimeTypeLock = PTHREAD_MUTEX_INITIALIZER; @@ -116,18 +115,16 @@ static std::string getMimeTypeForFile(const std::string& filename) { } void introduceTaskbar(string &content, const string &humanReadableBookId) { - pthread_mutex_lock(&resourceLock); if (!nosearchbarFlag) { content = appendToFirstOccurence(content, "", - replaceRegex(getResourceAsString("server/include.html.part"), + replaceRegex(RESOURCE::include_html_part, humanReadableBookId, "__CONTENT__")); content = appendToFirstOccurence(content, "", ""); + RESOURCE::taskbar_css + ""); content = appendToFirstOccurence(content, "]*>", - replaceRegex(getResourceAsString("server/taskbar.html.part"), + replaceRegex(RESOURCE::taskbar_html_part, humanReadableBookId, "__CONTENT__")); } - pthread_mutex_unlock(&resourceLock); } /* Should display debug information? */ @@ -342,7 +339,7 @@ struct MHD_Response* handle_skin(struct MHD_Connection * connection, const std::string& humanReadableBookId, bool acceptEncodingDeflate) { - std::string content = getResourceAsString(urlStr.substr(6)); + std::string content = getResource(urlStr.substr(6)); std::string mimeType = getMimeTypeForFile(urlStr); bool deflated = acceptEncodingDeflate && compress_content(content, mimeType); return build_response(content.data(), content.size(), "", mimeType, deflated, true); @@ -894,7 +891,7 @@ int main(int argc, char **argv) { \n\n"; } } - welcomeHTML = replaceRegex(getResourceAsString("server/home.html.tmpl"), welcomeBooksHtml, "__BOOKS__"); + welcomeHTML = replaceRegex(RESOURCE::home_html_tmpl, welcomeBooksHtml, "__BOOKS__"); #ifndef _WIN32 /* Fork if necessary */ @@ -921,7 +918,6 @@ int main(int argc, char **argv) { pthread_mutex_init(&welcomeLock, NULL); pthread_mutex_init(&searcherLock, NULL); pthread_mutex_init(&compressorLock, NULL); - pthread_mutex_init(&resourceLock, NULL); pthread_mutex_init(&verboseFlagLock, NULL); pthread_mutex_init(&mimeTypeLock, NULL); @@ -1064,7 +1060,6 @@ int main(int argc, char **argv) { pthread_mutex_destroy(&readerLock); pthread_mutex_destroy(&searcherLock); pthread_mutex_destroy(&compressorLock); - pthread_mutex_destroy(&resourceLock); pthread_mutex_destroy(&mapLock); pthread_mutex_destroy(&welcomeLock); pthread_mutex_destroy(&verboseFlagLock); diff --git a/src/server/meson.build b/src/server/meson.build index 61621f6..78bfa97 100644 --- a/src/server/meson.build +++ b/src/server/meson.build @@ -1,3 +1,7 @@ -executable('kiwix-serve', ['kiwix-serve.cpp'], + +sources = ['kiwix-serve.cpp'] +sources += server_resources + +executable('kiwix-serve', sources, dependencies:all_deps, - install:true) \ No newline at end of file + install:true) diff --git a/static/buildResourceCode.sh b/static/buildResourceCode.sh deleted file mode 100755 index e90363d..0000000 --- a/static/buildResourceCode.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -SCRIPT_DIR=$(dirname $0) -RESOURCE_FILE=$SCRIPT_DIR/../src/common/resourceTools.h -MAP="static std::map > createResourceMap() { \n" -MAP=$MAP"\tstd::map > m; \n" - -# Delete old version of the file -rm -f "$RESOURCE_FILE" - -# Create header of resourceTools.h -cat << EOF > "$RESOURCE_FILE" -#ifndef KIWIX_RESOURCETOOLS_H -#define KIWIX_RESOURCETOOLS_H - -#include -#include -#include - -std::string getResourceAsString(const std::string &name); - -EOF - -# Goes through all files in /static/ -for FILE in `find . -type f | sed 's/\.\///' | grep -v .svn | grep -v Makefile | grep -v .sh | grep -v "~" | grep -v "#"` -do - FILE_ID=`echo "$FILE" | sed "s/\//_/g" | sed "s/\./_/g" | sed "s/\-/_/g"` - echo "Inserting $FILE... [$FILE_ID]" - reswrap -s -x -oa $RESOURCE_FILE -r $FILE_ID $FILE - MAP=$MAP"\tm[\""$FILE"\"] = std::pair ("$FILE_ID", sizeof "$FILE_ID"); \n"; -done; -MAP=$MAP"\treturn m; \n"; -MAP=$MAP"} \n\n" -MAP=$MAP"static std::map > resourceMap = createResourceMap(); \n\n" - -# Create the map table -# map m = map_list_of (1,2) (3,4) (5,6) (7,8); -echo $MAP >> "$RESOURCE_FILE" - -# Create the footer -cat << EOF >> "$RESOURCE_FILE" -#endif - -EOF diff --git a/static/meson.build b/static/meson.build new file mode 100644 index 0000000..0682110 --- /dev/null +++ b/static/meson.build @@ -0,0 +1,4 @@ + +res_compiler = find_program('compile_resources.py') + +subdir('server') diff --git a/static/results.ct2 b/static/results.ct2 deleted file mode 100644 index 81e59ba..0000000 Binary files a/static/results.ct2 and /dev/null differ diff --git a/static/results.tmpl b/static/results.tmpl deleted file mode 100644 index 1d95b80..0000000 --- a/static/results.tmpl +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - Search: <TMPL_var searchPattern> - - -
- Results - of for No result were found for -
- -
-
    - -
  • - ... -
    words
    -
  • -
    -
-
- - - - - diff --git a/static/jquery-ui/external/jquery/jquery.js b/static/server/jquery-ui/external/jquery/jquery.js similarity index 100% rename from static/jquery-ui/external/jquery/jquery.js rename to static/server/jquery-ui/external/jquery/jquery.js diff --git a/static/jquery-ui/images/animated-overlay.gif b/static/server/jquery-ui/images/animated-overlay.gif similarity index 100% rename from static/jquery-ui/images/animated-overlay.gif rename to static/server/jquery-ui/images/animated-overlay.gif diff --git a/static/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png b/static/server/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png rename to static/server/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png diff --git a/static/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png b/static/server/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png rename to static/server/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png diff --git a/static/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png b/static/server/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png rename to static/server/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png b/static/server/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png rename to static/server/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png b/static/server/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png rename to static/server/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png b/static/server/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png rename to static/server/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/static/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png b/static/server/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from static/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png rename to static/server/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/static/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/static/server/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from static/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to static/server/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/static/jquery-ui/images/ui-icons_222222_256x240.png b/static/server/jquery-ui/images/ui-icons_222222_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_222222_256x240.png rename to static/server/jquery-ui/images/ui-icons_222222_256x240.png diff --git a/static/jquery-ui/images/ui-icons_2e83ff_256x240.png b/static/server/jquery-ui/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_2e83ff_256x240.png rename to static/server/jquery-ui/images/ui-icons_2e83ff_256x240.png diff --git a/static/jquery-ui/images/ui-icons_454545_256x240.png b/static/server/jquery-ui/images/ui-icons_454545_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_454545_256x240.png rename to static/server/jquery-ui/images/ui-icons_454545_256x240.png diff --git a/static/jquery-ui/images/ui-icons_888888_256x240.png b/static/server/jquery-ui/images/ui-icons_888888_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_888888_256x240.png rename to static/server/jquery-ui/images/ui-icons_888888_256x240.png diff --git a/static/jquery-ui/images/ui-icons_cd0a0a_256x240.png b/static/server/jquery-ui/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from static/jquery-ui/images/ui-icons_cd0a0a_256x240.png rename to static/server/jquery-ui/images/ui-icons_cd0a0a_256x240.png diff --git a/static/jquery-ui/jquery-ui.min.css b/static/server/jquery-ui/jquery-ui.min.css similarity index 100% rename from static/jquery-ui/jquery-ui.min.css rename to static/server/jquery-ui/jquery-ui.min.css diff --git a/static/jquery-ui/jquery-ui.min.js b/static/server/jquery-ui/jquery-ui.min.js similarity index 100% rename from static/jquery-ui/jquery-ui.min.js rename to static/server/jquery-ui/jquery-ui.min.js diff --git a/static/jquery-ui/jquery-ui.structure.min.css b/static/server/jquery-ui/jquery-ui.structure.min.css similarity index 100% rename from static/jquery-ui/jquery-ui.structure.min.css rename to static/server/jquery-ui/jquery-ui.structure.min.css diff --git a/static/jquery-ui/jquery-ui.theme.min.css b/static/server/jquery-ui/jquery-ui.theme.min.css similarity index 100% rename from static/jquery-ui/jquery-ui.theme.min.css rename to static/server/jquery-ui/jquery-ui.theme.min.css diff --git a/static/server/meson.build b/static/server/meson.build new file mode 100644 index 0000000..112bfac --- /dev/null +++ b/static/server/meson.build @@ -0,0 +1,7 @@ + +server_resources = custom_target('resources', + input: 'resources_list.txt', + output: ['server-resources.cpp', 'server-resources.h'], + command:[res_compiler, '--cxxfile', '@OUTPUT0@', '--hfile', '@OUTPUT1@', '@INPUT@'] +) + diff --git a/static/server/resources_list.txt b/static/server/resources_list.txt new file mode 100644 index 0000000..7bdb0e2 --- /dev/null +++ b/static/server/resources_list.txt @@ -0,0 +1,4 @@ +home.html.tmpl +include.html.part +taskbar.css +taskbar.html.part diff --git a/static/stopwords/en b/static/stopwords/en deleted file mode 100644 index d6dd643..0000000 --- a/static/stopwords/en +++ /dev/null @@ -1,671 +0,0 @@ -a -able -about -above -abst -accordance -according -accordingly -across -act -actually -added -adj -adopted -affected -affecting -affects -after -afterwards -again -against -ah -all -almost -alone -along -already -also -although -always -am -among -amongst -an -and -announce -another -any -anybody -anyhow -anymore -anyone -anything -anyway -anyways -anywhere -apparently -approximately -are -aren -arent -arise -around -as -aside -ask -asking -at -auth -available -away -awfully -b -back -be -became -because -become -becomes -becoming -been -before -beforehand -begin -beginning -beginnings -begins -behind -being -believe -below -beside -besides -between -beyond -biol -both -brief -briefly -but -by -c -ca -came -can -cannot -can't -cause -causes -certain -certainly -co -com -come -comes -contain -containing -contains -could -couldnt -d -date -did -didn't -different -do -does -doesn't -doing -done -don't -down -downwards -due -during -e -each -ed -edu -effect -eg -eight -eighty -either -else -elsewhere -end -ending -enough -especially -et -et-al -etc -even -ever -every -everybody -everyone -everything -everywhere -ex -except -f -far -few -ff -fifth -first -five -fix -followed -following -follows -for -former -formerly -forth -found -four -from -further -furthermore -g -gave -get -gets -getting -give -given -gives -giving -go -goes -gone -got -gotten -h -had -happens -hardly -has -hasn't -have -haven't -having -he -hed -hence -her -here -hereafter -hereby -herein -heres -hereupon -hers -herself -hes -hi -hid -him -himself -his -hither -home -how -howbeit -however -hundred -i -id -ie -if -i'll -im -immediate -immediately -importance -important -in -inc -indeed -index -information -instead -into -invention -inward -is -isn't -it -itd -it'll -its -itself -i've -j -just -k -keep -keeps -kept -keys -kg -km -know -known -knows -l -largely -last -lately -later -latter -latterly -least -less -lest -let -lets -like -liked -likely -line -little -'ll -look -looking -looks -ltd -m -made -mainly -make -makes -many -may -maybe -me -mean -means -meantime -meanwhile -merely -mg -might -million -miss -ml -more -moreover -most -mostly -mr -mrs -much -mug -must -my -myself -n -na -name -namely -nay -nd -near -nearly -necessarily -necessary -need -needs -neither -never -nevertheless -new -next -nine -ninety -no -nobody -non -none -nonetheless -noone -nor -normally -nos -not -noted -nothing -now -nowhere -o -obtain -obtained -obviously -of -off -often -oh -ok -okay -old -omitted -on -once -one -ones -only -onto -or -ord -other -others -otherwise -ought -our -ours -ourselves -out -outside -over -overall -owing -own -p -page -pages -part -particular -particularly -past -per -perhaps -placed -please -plus -poorly -possible -possibly -potentially -pp -predominantly -present -previously -primarily -probably -promptly -proud -provides -put -q -que -quickly -quite -qv -r -ran -rather -rd -re -readily -really -recent -recently -ref -refs -regarding -regardless -regards -related -relatively -research -respectively -resulted -resulting -results -right -run -s -said -same -saw -say -saying -says -sec -section -see -seeing -seem -seemed -seeming -seems -seen -self -selves -sent -seven -several -shall -she -shed -she'll -shes -should -shouldn't -show -showed -shown -showns -shows -significant -significantly -similar -similarly -since -six -slightly -so -some -somebody -somehow -someone -somethan -something -sometime -sometimes -somewhat -somewhere -soon -sorry -specifically -specified -specify -specifying -state -states -still -stop -strongly -sub -substantially -successfully -such -sufficiently -suggest -sup -sure - t -take -taken -taking -tell -tends -th -than -thank -thanks -thanx -that -that'll -thats -that've -the -their -theirs -them -themselves -then -thence -there -thereafter -thereby -thered -therefore -therein -there'll -thereof -therere -theres -thereto -thereupon -there've -these -they -theyd -they'll -theyre -they've -think -this -those -thou -though -thoughh -thousand -throug -through -throughout -thru -thus -til -tip -to -together -too -took -toward -towards -tried -tries -truly -try -trying -ts -twice -two -u -un -under -unfortunately -unless -unlike -unlikely -until -unto -up -upon -ups -us -use -used -useful -usefully -usefulness -uses -using -usually -v -value -various -'ve -very -via -viz -vol -vols -vs -w -want -wants -was -wasn't -way -we -wed -welcome -we'll -went -were -weren't -we've -what -whatever -what'll -whats -when -whence -whenever -where -whereafter -whereas -whereby -wherein -wheres -whereupon -wherever -whether -which -while -whim -whither -who -whod -whoever -whole -who'll -whom -whomever -whos -whose -why -widely -willing -wish -with -within -without -won't -words -world -would -wouldn't -www -x -y -yes -yet -you -youd -you'll -your -youre -yours -yourself -yourselves -you've -z -zero diff --git a/static/stopwords/fra b/static/stopwords/fra deleted file mode 100644 index 1c1522b..0000000 --- a/static/stopwords/fra +++ /dev/null @@ -1,124 +0,0 @@ -alors -au -aucuns -aussi -autre -avant -avec -avoir -bon -car -ce -cela -ces -ceux -chaque -ci -comme -comment -dans -des -du -dedans -dehors -depuis -deux -devrait -doit -donc -dos -droite -début -elle -elles -en -encore -essai -est -et -eu -fait -faites -fois -font -force -haut -hors -ici -il -ils -je -la -le -les -leur -là -ma -maintenant -mais -mes -mine -moins -mon -mot -même -ni -nommés -notre -nous -nouveaux -ou -où -par -parce -parole -pas -personnes -peut -peu -pièce -plupart -pour -pourquoi -quand -que -quel -quelle -quelles -quels -qui -sa -sans -ses -seulement -si -sien -son -sont -sous -soyez -sur -ta -tandis -tellement -tels -tes -ton -tous -tout -trop -très -tu -valeur -voie -voient -vont -votre -vous -vu -ça -étaient -état -étions -été -être diff --git a/static/stopwords/he b/static/stopwords/he deleted file mode 100644 index a213f55..0000000 --- a/static/stopwords/he +++ /dev/null @@ -1,87 +0,0 @@ -של -את -על -לא -כי -עם -הוא -גם -ב -זה -היא -כל -יותר -או -אבל -בין -היה -אם -מיליון -יש -כך -אני -הם -דולר -אמר -עד -לאחר -ישראל -רק -שקל -כדי -מה -לפני -אחד -החברה -כמו -זאת -היום -אך -ל -ה -כ -אין -אתמול -שלא -כבר -עוד -לו -זו -אל -בן -אותו -שני -בית -ידי -כמה -ביותר -ולא -הממשלה -אחרי -חברת -היתה -שלו -היו -נגד -בכל -אביב -ראש -בישראל -לי -שנים -פי -בו -מ -מאוד -להיות -שהוא -מי -אלף -אלא -אף -אחר -הזה -אחת -בבית -אלה -אנחנו