Dark theme, pdf meta, de-serialize bugfix

This commit is contained in:
simon 2019-10-30 21:48:58 -04:00
parent 130fb78787
commit c762d0de08
18 changed files with 542 additions and 251 deletions

2
.gitignore vendored
View File

@ -11,7 +11,7 @@ Makefile
LOG LOG
sist2* sist2*
index.sist2/ index.sist2/
bundle.css bundle*.css
bundle.js bundle.js
*.a *.a
vgcore.* vgcore.*

View File

@ -91,7 +91,7 @@ application/x-esrehber, es
application/x-excel, xla|xld|xlk|xlt|xlv application/x-excel, xla|xld|xlk|xlt|xlv
application/x-executable, exe application/x-executable, exe
application/x-font-sfn, application/x-font-sfn,
application/x-font-ttf, ttf application/x-font-ttf, ttf|ttc
application/x-freelance, pre application/x-freelance, pre
application/x-git, application/x-git,
application/x-gsp, gsp application/x-gsp, gsp
@ -359,3 +359,4 @@ image/x-tga,
application/x-wine-extension-ini, application/x-wine-extension-ini,
application/x-cbz, cbz application/x-cbz, cbz
application/x-cbr, cbr application/x-cbr, cbr
application/x-ms-compress-szdd, fon

1 application/arj arj
91 application/x-excel xla|xld|xlk|xlt|xlv
92 application/x-executable exe
93 application/x-font-sfn
94 application/x-font-ttf ttf ttf|ttc
95 application/x-freelance pre
96 application/x-git
97 application/x-gsp gsp
359 application/x-wine-extension-ini
360 application/x-cbz cbz
361 application/x-cbr cbr
362 application/x-ms-compress-szdd fon

View File

@ -6,9 +6,11 @@ rm web/js/bundle.js 2> /dev/null
cat `ls web/js/*.min.js` > web/js/bundle.js cat `ls web/js/*.min.js` > web/js/bundle.js
cat web/js/{util,dom,search}.js >> web/js/bundle.js cat web/js/{util,dom,search}.js >> web/js/bundle.js
rm web/css/bundle.css 2> /dev/null rm web/css/bundle*.css 2> /dev/null
cat web/css/*.min.css > web/css/bundle.css cat web/css/*.min.css > web/css/bundle.css
cat web/css/main.css >> web/css/bundle.css cat web/css/light.css >> web/css/bundle.css
cat web/css/*.min.css > web/css/bundle_dark.css
cat web/css/dark.css >> web/css/bundle_dark.css
python3 scripts/mime.py > src/parsing/mime_generated.c python3 scripts/mime.py > src/parsing/mime_generated.c
python3 scripts/serve_static.py > src/web/static_generated.c python3 scripts/serve_static.py > src/web/static_generated.c

View File

@ -24,6 +24,7 @@ pdf = (
font = ( font = (
"application/vnd.ms-opentype", "application/vnd.ms-opentype",
"application/x-ms-compress-szdd"
"application/x-font-sfn", "application/x-font-sfn",
"application/x-font-ttf", "application/x-font-ttf",
"font/otf", "font/otf",

View File

@ -1,8 +1,9 @@
files = [ files = [
"web/css/bundle.css", "web/css/bundle.css",
"web/css/bundle_dark.css",
"web/js/bundle.js", "web/js/bundle.js",
"web/img/bg-bars.png",
"web/img/sprite-skin-flat.png", "web/img/sprite-skin-flat.png",
"web/img/sprite-skin-flat-dark.png",
"web/search.html", "web/search.html",
] ]

View File

@ -197,8 +197,12 @@ void read_index(const char *path, const char index_id[UUID_STR_LEN], index_func
*(buf.buf + line.ext) = '\0'; *(buf.buf + line.ext) = '\0';
} }
cJSON_AddStringToObject(document, "name", buf.buf + line.base); cJSON_AddStringToObject(document, "name", buf.buf + line.base);
if (line.base > 0) {
*(buf.buf + line.base - 1) = '\0'; *(buf.buf + line.base - 1) = '\0';
cJSON_AddStringToObject(document, "path", buf.buf); cJSON_AddStringToObject(document, "path", buf.buf);
} else {
cJSON_AddStringToObject(document, "path", "");
}
enum metakey key = getc(file); enum metakey key = getc(file);
while (key != '\n') { while (key != '\n') {

View File

@ -10,7 +10,7 @@
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0" #define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
static const char *const Version = "1.0.10"; static const char *const Version = "1.0.11";
static const char *const usage[] = { static const char *const usage[] = {
"sist2 scan [OPTION]... PATH", "sist2 scan [OPTION]... PATH",
"sist2 index [OPTION]... INDEX", "sist2 index [OPTION]... INDEX",

View File

@ -112,7 +112,7 @@ enum mime {
application_x_esrehber=655464, application_x_esrehber=655464,
application_x_excel=655465, application_x_excel=655465,
application_x_executable=655466, application_x_executable=655466,
application_x_font_sfn=655467 | 0x20000000, application_x_font_sfn=655467,
application_x_font_ttf=655468 | 0x20000000, application_x_font_ttf=655468 | 0x20000000,
application_x_freelance=655469, application_x_freelance=655469,
application_x_git=655470, application_x_git=655470,
@ -148,224 +148,225 @@ enum mime {
application_x_mif=655500, application_x_mif=655500,
application_x_mix_transfer=655501, application_x_mix_transfer=655501,
application_x_mobipocket_ebook=655502, application_x_mobipocket_ebook=655502,
application_x_ms_pdb=655503, application_x_ms_compress_szdd=655503,
application_x_ms_reader=655504, application_x_ms_pdb=655504,
application_x_navi_animation=655505, application_x_ms_reader=655505,
application_x_navidoc=655506, application_x_navi_animation=655506,
application_x_navimap=655507, application_x_navidoc=655507,
application_x_navistyle=655508, application_x_navimap=655508,
application_x_netcdf=655509, application_x_navistyle=655509,
application_x_newton_compatible_pkg=655510, application_x_netcdf=655510,
application_x_object=655511, application_x_newton_compatible_pkg=655511,
application_x_omc=655512, application_x_object=655512,
application_x_omcdatamaker=655513, application_x_omc=655513,
application_x_omcregerator=655514, application_x_omcdatamaker=655514,
application_x_pagemaker=655515, application_x_omcregerator=655515,
application_x_pcl=655516, application_x_pagemaker=655516,
application_x_pixclscript=655517, application_x_pcl=655517,
application_x_pkcs7_certreqresp=655518, application_x_pixclscript=655518,
application_x_pkcs7_signature=655519, application_x_pkcs7_certreqresp=655519,
application_x_project=655520, application_x_pkcs7_signature=655520,
application_x_qpro=655521, application_x_project=655521,
application_x_rar=655522, application_x_qpro=655522,
application_x_rpm=655523, application_x_rar=655523,
application_x_sdp=655524, application_x_rpm=655524,
application_x_sea=655525, application_x_sdp=655525,
application_x_seelogo=655526, application_x_sea=655526,
application_x_setupscript=655527, application_x_seelogo=655527,
application_x_shar=655528, application_x_setupscript=655528,
application_x_sharedlib=655529, application_x_shar=655529,
application_x_shockwave_flash=655530, application_x_sharedlib=655530,
application_x_sprite=655531, application_x_shockwave_flash=655531,
application_x_sqlite3=655532, application_x_sprite=655532,
application_x_sv4cpio=655533, application_x_sqlite3=655533,
application_x_sv4crc=655534, application_x_sv4cpio=655534,
application_x_tar=655535, application_x_sv4crc=655535,
application_x_tbook=655536, application_x_tar=655536,
application_x_tex_tfm=655537, application_x_tbook=655537,
application_x_texinfo=655538, application_x_tex_tfm=655538,
application_x_ustar=655539, application_x_texinfo=655539,
application_x_visio=655540, application_x_ustar=655540,
application_x_vnd_audioexplosion_mzz=655541, application_x_visio=655541,
application_x_vnd_ls_xpix=655542, application_x_vnd_audioexplosion_mzz=655542,
application_x_vrml=655543, application_x_vnd_ls_xpix=655543,
application_x_wais_source=655544, application_x_vrml=655544,
application_x_wine_extension_ini=655545, application_x_wais_source=655545,
application_x_wintalk=655546, application_x_wine_extension_ini=655546,
application_x_world=655547, application_x_wintalk=655547,
application_x_wri=655548, application_x_world=655548,
application_x_x509_ca_cert=655549, application_x_wri=655549,
application_x_xz=655550, application_x_x509_ca_cert=655550,
application_xml=655551, application_x_xz=655551,
application_zip=655552, application_xml=655552,
audio_it=458945, application_zip=655553,
audio_make=458946, audio_it=458946,
audio_mid=458947, audio_make=458947,
audio_midi=458948, audio_mid=458948,
audio_mp4=458949, audio_midi=458949,
audio_mpeg=458950, audio_mp4=458950,
audio_ogg=458951, audio_mpeg=458951,
audio_s3m=458952, audio_ogg=458952,
audio_tsp_audio=458953, audio_s3m=458953,
audio_tsplayer=458954, audio_tsp_audio=458954,
audio_vnd_qcelp=458955, audio_tsplayer=458955,
audio_voxware=458956, audio_vnd_qcelp=458956,
audio_x_flac=458957, audio_voxware=458957,
audio_x_gsm=458958, audio_x_flac=458958,
audio_x_jam=458959, audio_x_gsm=458959,
audio_x_liveaudio=458960, audio_x_jam=458960,
audio_x_m4a=458961, audio_x_liveaudio=458961,
audio_x_midi=458962, audio_x_m4a=458962,
audio_x_mod=458963, audio_x_midi=458963,
audio_x_mp4a_latm=458964, audio_x_mod=458964,
audio_x_mpeg_3=458965, audio_x_mp4a_latm=458965,
audio_x_mpequrl=458966, audio_x_mpeg_3=458966,
audio_x_nspaudio=458967, audio_x_mpequrl=458967,
audio_x_pn_realaudio=458968, audio_x_nspaudio=458968,
audio_x_psid=458969, audio_x_pn_realaudio=458969,
audio_x_realaudio=458970, audio_x_psid=458970,
audio_x_twinvq=458971, audio_x_realaudio=458971,
audio_x_twinvq_plugin=458972, audio_x_twinvq=458972,
audio_x_voc=458973, audio_x_twinvq_plugin=458973,
audio_x_wav=458974, audio_x_voc=458974,
audio_xm=458975, audio_x_wav=458975,
font_otf=327904 | 0x20000000, audio_xm=458976,
font_sfnt=327905 | 0x20000000, font_otf=327905 | 0x20000000,
font_woff=327906 | 0x20000000, font_sfnt=327906 | 0x20000000,
font_woff2=327907 | 0x20000000, font_woff=327907 | 0x20000000,
image_cmu_raster=524516, font_woff2=327908 | 0x20000000,
image_fif=524517, image_cmu_raster=524517,
image_florian=524518, image_fif=524518,
image_g3fax=524519, image_florian=524519,
image_gif=524520, image_g3fax=524520,
image_ief=524521, image_gif=524521,
image_jpeg=524522, image_ief=524522,
image_jutvision=524523, image_jpeg=524523,
image_naplps=524524, image_jutvision=524524,
image_pict=524525, image_naplps=524525,
image_png=524526, image_pict=524526,
image_svg=524527 | 0x80000000, image_png=524527,
image_svg_xml=524528 | 0x80000000, image_svg=524528 | 0x80000000,
image_tiff=524529, image_svg_xml=524529 | 0x80000000,
image_vnd_adobe_photoshop=524530 | 0x80000000, image_tiff=524530,
image_vnd_djvu=524531 | 0x80000000, image_vnd_adobe_photoshop=524531 | 0x80000000,
image_vnd_fpx=524532, image_vnd_djvu=524532 | 0x80000000,
image_vnd_microsoft_icon=524533, image_vnd_fpx=524533,
image_vnd_rn_realflash=524534, image_vnd_microsoft_icon=524534,
image_vnd_rn_realpix=524535, image_vnd_rn_realflash=524535,
image_vnd_wap_wbmp=524536, image_vnd_rn_realpix=524536,
image_vnd_xiff=524537, image_vnd_wap_wbmp=524537,
image_webp=524538, image_vnd_xiff=524538,
image_x_cmu_raster=524539, image_webp=524539,
image_x_cur=524540, image_x_cmu_raster=524540,
image_x_dwg=524541, image_x_cur=524541,
image_x_eps=524542, image_x_dwg=524542,
image_x_exr=524543, image_x_eps=524543,
image_x_icns=524544, image_x_exr=524544,
image_x_icon=524545 | 0x80000000, image_x_icns=524545,
image_x_jg=524546, image_x_icon=524546 | 0x80000000,
image_x_jps=524547, image_x_jg=524547,
image_x_ms_bmp=524548, image_x_jps=524548,
image_x_niff=524549, image_x_ms_bmp=524549,
image_x_pcx=524550, image_x_niff=524550,
image_x_pict=524551, image_x_pcx=524551,
image_x_portable_bitmap=524552, image_x_pict=524552,
image_x_portable_graymap=524553, image_x_portable_bitmap=524553,
image_x_portable_pixmap=524554, image_x_portable_graymap=524554,
image_x_quicktime=524555, image_x_portable_pixmap=524555,
image_x_rgb=524556, image_x_quicktime=524556,
image_x_tga=524557, image_x_rgb=524557,
image_x_tiff=524558, image_x_tga=524558,
image_x_xcf=524559 | 0x80000000, image_x_tiff=524559,
image_x_xpixmap=524560 | 0x80000000, image_x_xcf=524560 | 0x80000000,
image_x_xwindowdump=524561, image_x_xpixmap=524561 | 0x80000000,
message_rfc822=196882, image_x_xwindowdump=524562,
model_vnd_dwf=65811, message_rfc822=196883,
model_vnd_gdl=65812, model_vnd_dwf=65812,
model_vnd_gs_gdl=65813, model_vnd_gdl=65813,
model_vrml=65814, model_vnd_gs_gdl=65814,
model_x_pov=65815, model_vrml=65815,
text_asp=590104, model_x_pov=65816,
text_css=590105, text_asp=590105,
text_html=590106, text_css=590106,
text_javascript=590107, text_html=590107,
text_mcf=590108, text_javascript=590108,
text_pascal=590109, text_mcf=590109,
text_plain=590110, text_pascal=590110,
text_richtext=590111, text_plain=590111,
text_scriplet=590112, text_richtext=590112,
text_tab_separated_values=590113, text_scriplet=590113,
text_troff=590114, text_tab_separated_values=590114,
text_uri_list=590115, text_troff=590115,
text_vnd_abc=590116, text_uri_list=590116,
text_vnd_fmi_flexstor=590117, text_vnd_abc=590117,
text_vnd_wap_wml=590118, text_vnd_fmi_flexstor=590118,
text_vnd_wap_wmlscript=590119, text_vnd_wap_wml=590119,
text_webviewhtml=590120, text_vnd_wap_wmlscript=590120,
text_x_Algol68=590121, text_webviewhtml=590121,
text_x_asm=590122, text_x_Algol68=590122,
text_x_audiosoft_intra=590123, text_x_asm=590123,
text_x_awk=590124, text_x_audiosoft_intra=590124,
text_x_bcpl=590125, text_x_awk=590125,
text_x_c=590126, text_x_bcpl=590126,
text_x_c__=590127, text_x_c=590127,
text_x_component=590128, text_x_c__=590128,
text_x_diff=590129, text_x_component=590129,
text_x_fortran=590130, text_x_diff=590130,
text_x_java=590131, text_x_fortran=590131,
text_x_la_asf=590132, text_x_java=590132,
text_x_lisp=590133, text_x_la_asf=590133,
text_x_m=590134, text_x_lisp=590134,
text_x_m4=590135, text_x_m=590135,
text_x_makefile=590136, text_x_m4=590136,
text_x_msdos_batch=590137, text_x_makefile=590137,
text_x_pascal=590138, text_x_msdos_batch=590138,
text_x_perl=590139, text_x_pascal=590139,
text_x_php=590140, text_x_perl=590140,
text_x_po=590141, text_x_php=590141,
text_x_python=590142, text_x_po=590142,
text_x_ruby=590143, text_x_python=590143,
text_x_sass=590144, text_x_ruby=590144,
text_x_scss=590145, text_x_sass=590145,
text_x_server_parsed_html=590146, text_x_scss=590146,
text_x_setext=590147, text_x_server_parsed_html=590147,
text_x_sgml=590148, text_x_setext=590148,
text_x_shellscript=590149, text_x_sgml=590149,
text_x_speech=590150, text_x_shellscript=590150,
text_x_tcl=590151, text_x_speech=590151,
text_x_tex=590152, text_x_tcl=590152,
text_x_uil=590153, text_x_tex=590153,
text_x_uuencode=590154, text_x_uil=590154,
text_x_vcalendar=590155, text_x_uuencode=590155,
text_x_vcard=590156, text_x_vcalendar=590156,
text_xml=590157, text_x_vcard=590157,
video_animaflex=393550, text_xml=590158,
video_avi=393551, video_animaflex=393551,
video_avs_video=393552, video_avi=393552,
video_mp4=393553, video_avs_video=393553,
video_mpeg=393554, video_mp4=393554,
video_quicktime=393555, video_mpeg=393555,
video_vdo=393556, video_quicktime=393556,
video_vivo=393557, video_vdo=393557,
video_vnd_rn_realvideo=393558, video_vivo=393558,
video_vosaic=393559, video_vnd_rn_realvideo=393559,
video_webm=393560, video_vosaic=393560,
video_x_amt_demorun=393561, video_webm=393561,
video_x_amt_showrun=393562, video_x_amt_demorun=393562,
video_x_atomic3d_feature=393563, video_x_amt_showrun=393563,
video_x_dl=393564, video_x_atomic3d_feature=393564,
video_x_dv=393565, video_x_dl=393565,
video_x_fli=393566, video_x_dv=393566,
video_x_flv=393567, video_x_fli=393567,
video_x_isvideo=393568, video_x_flv=393568,
video_x_jng=393569 | 0x80000000, video_x_isvideo=393569,
video_x_matroska=393570, video_x_jng=393570 | 0x80000000,
video_x_mng=393571, video_x_matroska=393571,
video_x_motion_jpeg=393572, video_x_mng=393572,
video_x_ms_asf=393573, video_x_motion_jpeg=393573,
video_x_msvideo=393574, video_x_ms_asf=393574,
video_x_qtc=393575, video_x_msvideo=393575,
video_x_sgi_movie=393576, video_x_qtc=393576,
video_x_sgi_movie=393577,
}; };
char *mime_get_mime_text(unsigned int mime_id) {switch (mime_id) { char *mime_get_mime_text(unsigned int mime_id) {switch (mime_id) {
case application_arj: return "application/arj"; case application_arj: return "application/arj";
@ -728,6 +729,7 @@ case image_x_tga: return "image/x-tga";
case application_x_wine_extension_ini: return "application/x-wine-extension-ini"; case application_x_wine_extension_ini: return "application/x-wine-extension-ini";
case application_x_cbz: return "application/x-cbz"; case application_x_cbz: return "application/x-cbz";
case application_x_cbr: return "application/x-cbr"; case application_x_cbr: return "application/x-cbr";
case application_x_ms_compress_szdd: return "application/x-ms-compress-szdd";
default: return NULL;}} default: return NULL;}}
GHashTable *mime_get_ext_table() {GHashTable *ext_table = g_hash_table_new(g_str_hash, g_str_equal); GHashTable *mime_get_ext_table() {GHashTable *ext_table = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(ext_table, "arj", (gpointer)application_arj); g_hash_table_insert(ext_table, "arj", (gpointer)application_arj);
@ -857,6 +859,7 @@ g_hash_table_insert(ext_table, "xlt", (gpointer)application_x_excel);
g_hash_table_insert(ext_table, "xlv", (gpointer)application_x_excel); g_hash_table_insert(ext_table, "xlv", (gpointer)application_x_excel);
g_hash_table_insert(ext_table, "exe", (gpointer)application_x_executable); g_hash_table_insert(ext_table, "exe", (gpointer)application_x_executable);
g_hash_table_insert(ext_table, "ttf", (gpointer)application_x_font_ttf); g_hash_table_insert(ext_table, "ttf", (gpointer)application_x_font_ttf);
g_hash_table_insert(ext_table, "ttc", (gpointer)application_x_font_ttf);
g_hash_table_insert(ext_table, "pre", (gpointer)application_x_freelance); g_hash_table_insert(ext_table, "pre", (gpointer)application_x_freelance);
g_hash_table_insert(ext_table, "gsp", (gpointer)application_x_gsp); g_hash_table_insert(ext_table, "gsp", (gpointer)application_x_gsp);
g_hash_table_insert(ext_table, "gss", (gpointer)application_x_gss); g_hash_table_insert(ext_table, "gss", (gpointer)application_x_gss);
@ -1207,6 +1210,7 @@ g_hash_table_insert(ext_table, "vcf", (gpointer)text_x_vcard);
g_hash_table_insert(ext_table, "hlp", (gpointer)application_winhelp); g_hash_table_insert(ext_table, "hlp", (gpointer)application_winhelp);
g_hash_table_insert(ext_table, "cbz", (gpointer)application_x_cbz); g_hash_table_insert(ext_table, "cbz", (gpointer)application_x_cbz);
g_hash_table_insert(ext_table, "cbr", (gpointer)application_x_cbr); g_hash_table_insert(ext_table, "cbr", (gpointer)application_x_cbr);
g_hash_table_insert(ext_table, "fon", (gpointer)application_x_ms_compress_szdd);
return ext_table;} return ext_table;}
GHashTable *mime_get_mime_table() {GHashTable *mime_table = g_hash_table_new(g_str_hash, g_str_equal); GHashTable *mime_get_mime_table() {GHashTable *mime_table = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(mime_table, "application/arj", (gpointer)application_arj); g_hash_table_insert(mime_table, "application/arj", (gpointer)application_arj);
@ -1569,5 +1573,6 @@ g_hash_table_insert(mime_table, "image/x-tga", (gpointer)image_x_tga);
g_hash_table_insert(mime_table, "application/x-wine-extension-ini", (gpointer)application_x_wine_extension_ini); g_hash_table_insert(mime_table, "application/x-wine-extension-ini", (gpointer)application_x_wine_extension_ini);
g_hash_table_insert(mime_table, "application/x-cbz", (gpointer)application_x_cbz); g_hash_table_insert(mime_table, "application/x-cbz", (gpointer)application_x_cbz);
g_hash_table_insert(mime_table, "application/x-cbr", (gpointer)application_x_cbr); g_hash_table_insert(mime_table, "application/x-cbr", (gpointer)application_x_cbr);
g_hash_table_insert(mime_table, "application/x-ms-compress-szdd", (gpointer)application_x_ms_compress_szdd);
return mime_table;} return mime_table;}
#endif #endif

View File

@ -75,6 +75,17 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
stream = fz_open_memory(ctx, buf, buf_len); stream = fz_open_memory(ctx, buf, buf_len);
fzdoc = fz_open_document_with_stream(ctx, mime_get_mime_text(doc->mime), stream); fzdoc = fz_open_document_with_stream(ctx, mime_get_mime_text(doc->mime), stream);
char title[4096] = {'\0',};
fz_lookup_metadata(ctx, fzdoc, FZ_META_INFO_TITLE, title, sizeof(title));
printf("Title: %s\n", title); //todo rmv
if (strlen(title) > 0) {
meta_line_t *meta_content = malloc(sizeof(meta_line_t) + strlen(title) + 1);
meta_content->key = MetaTitle;
strcpy(meta_content->strval, title);
APPEND_META(doc, meta_content)
}
int page_count = fz_count_pages(ctx, fzdoc); int page_count = fz_count_pages(ctx, fzdoc);
fz_page *cover = render_cover(ctx, doc, fzdoc); fz_page *cover = render_cover(ctx, doc, fzdoc);
@ -84,8 +95,7 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
text_buffer_t text_buf = text_buffer_create(ScanCtx.content_size); text_buffer_t text_buf = text_buffer_create(ScanCtx.content_size);
for (int current_page = 0; current_page < page_count; current_page++) { for (int current_page = 0; current_page < page_count; current_page++) {
fz_page *page; fz_page *page; if (current_page == 0) {
if (current_page == 0) {
page = cover; page = cover;
} else { } else {
page = fz_load_page(ctx, fzdoc, current_page); page = fz_load_page(ctx, fzdoc, current_page);

View File

@ -43,27 +43,40 @@ int javascript(void *p, onion_request *req, onion_response *res) {
return OCS_PROCESSED; return OCS_PROCESSED;
} }
int style(void *p, onion_request *req, onion_response *res) { int client_requested_dark_theme(onion_request *req) {
set_default_headers(res); const char *cookie = onion_request_get_cookie(req, "sist");
onion_response_set_header(res, "Content-Type", "text/css"); if (cookie == NULL) {
onion_response_set_length(res, sizeof(bundle_css)); return FALSE;
onion_response_write(res, bundle_css, sizeof(bundle_css));
return OCS_PROCESSED;
} }
int bg_bars(void *p, onion_request *req, onion_response *res) { return strcmp(cookie, "dark") == 0;
}
int style(void *p, onion_request *req, onion_response *res) {
set_default_headers(res); set_default_headers(res);
onion_response_set_header(res, "Content-Type", "image/png");
onion_response_set_length(res, sizeof(bg_bars_png)); onion_response_set_header(res, "Content-Type", "text/css");
onion_response_write(res, bg_bars_png, sizeof(bg_bars_png));
if (client_requested_dark_theme(req)) {
onion_response_set_length(res, sizeof(bundle_dark_css));
onion_response_write(res, bundle_dark_css, sizeof(bundle_dark_css));
} else {
onion_response_set_length(res, sizeof(bundle_css));
onion_response_write(res, bundle_css, sizeof(bundle_css));
}
return OCS_PROCESSED; return OCS_PROCESSED;
} }
int img_sprite_skin_flag(void *p, onion_request *req, onion_response *res) { int img_sprite_skin_flag(void *p, onion_request *req, onion_response *res) {
set_default_headers(res); set_default_headers(res);
onion_response_set_header(res, "Content-Type", "image/png"); onion_response_set_header(res, "Content-Type", "image/png");
if (client_requested_dark_theme(req)) {
onion_response_set_length(res, sizeof(sprite_skin_flat_dark_png));
onion_response_write(res, sprite_skin_flat_dark_png, sizeof(sprite_skin_flat_dark_png));
} else {
onion_response_set_length(res, sizeof(sprite_skin_flat_png)); onion_response_set_length(res, sizeof(sprite_skin_flat_png));
onion_response_write(res, sprite_skin_flat_png, sizeof(sprite_skin_flat_png)); onion_response_write(res, sprite_skin_flat_png, sizeof(sprite_skin_flat_png));
}
return OCS_PROCESSED; return OCS_PROCESSED;
} }
@ -384,7 +397,6 @@ void serve(const char *hostname, const char *port) {
onion_url_add(urls, "", search_index); onion_url_add(urls, "", search_index);
onion_url_add(urls, "css", style); onion_url_add(urls, "css", style);
onion_url_add(urls, "js", javascript); onion_url_add(urls, "js", javascript);
onion_url_add(urls, "img/bg-bars.png", bg_bars);
onion_url_add(urls, "img/sprite-skin-flat.png", img_sprite_skin_flag); onion_url_add(urls, "img/sprite-skin-flat.png", img_sprite_skin_flag);
onion_url_add(urls, "es", search); onion_url_add(urls, "es", search);

File diff suppressed because one or more lines are too long

240
web/css/dark.css Normal file
View File

@ -0,0 +1,240 @@
a {
color: #00BCD4;
}
body {
overflow-y: scroll;
background: black;
}
.progress {
margin-top: 1em;
}
.card {
margin-top: 1em;
background: #212121;
color: #e0e0e0;
}
.navbar-brand {
font-size: 1.75rem;
padding: 0;
color: #f5f5f5;
}
.navbar {
background: #546b7a;
}
.navbar a:hover {
color: #fff;
}
.navbar span {
color: #eee;
}
.document {
padding: 0.5rem;
}
.document p {
margin-bottom: 0;
}
.document:hover p {
text-decoration: underline;
}
.badge-video {
color: #FFFFFF;
background-color: #F27761;
}
.badge-image {
color: #FFFFFF;
background-color: #AA99C9;
}
.badge-audio {
color: #FFFFFF;
background-color: #00ADEF;
}
.badge-resolution {
color: #212529;
background-color: #B0BEC5;
}
.badge-text {
color: #FFFFFF;
background-color: #FAAB3C;
}
.card-img-overlay {
pointer-events: none;
padding: 0.75rem;
bottom: unset;
top: 0;
left: unset;
right: unset;
}
.file-title {
font-size: 10pt;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.badge {
margin-right: 3px;
}
.fit {
display: block;
min-width: 64px;
max-width: 100%;
max-height: 175px;
margin: 0 auto 0;
padding: 3px 3px 0 3px;
width: auto;
height: auto;
}
.audio-fit {
height: 39px;
vertical-align: bottom;
display: inline;
width: 100%;
}
@media (min-width: 1200px) {
.card-columns {
column-count: 4;
}
}
@media (min-width: 1500px) {
.container {
max-width: 1440px;
}
.card-columns {
column-count: 5;
}
}
@media (min-width: 1800px) {
.container {
max-width: 1550px;
}
}
mark {
background: #fff217;
border-radius: 0;
padding: 1px 0;
}
.content-div {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 13px;
padding: 1em;
background-color: #37474F;
border: 1px solid #616161;
border-radius: 4px;
margin: 3px;
}
.irs-single, .irs-from, .irs-to {
font-size: 13px;
background-color: #00BCD4;
}
.irs-slider {
cursor: col-resize;
}
.irs {
margin-top: 1em;
margin-bottom: 1em;
}
.custom-select {
overflow: auto;
background-color: #37474F;
border: 1px solid #616161;
color: #bdbdbd;
}
.custom-select:focus {
border-color: #757575;
outline: 0;
box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25);
}
option {
outline: none;
}
.form-control {
background-color: #37474F;
border: 1px solid #616161;
color: #fff;
}
.form-control:focus {
background-color: #546E7A;
color: #fff;
}
.input-group-text {
background: #263238;
border: 1px solid #616161;
color: #dbdbdb;
}
::placeholder {
color: #BDBDBD !important;
opacity: 1;
}
.inspire-tree .selected > .wholerow, .inspire-tree .selected > .title-wrap:hover + .wholerow {
background: none;
}
.inspire-tree .icon-expand::before, .inspire-tree .icon-collapse::before {
background-color: black;
}
.inspire-tree .title {
color: #eee;
}
.inspire-tree {
font-weight: 400;
font-size: 14px;
font-family: Helvetica, Nueue, Verdana, sans-serif;
max-height: 350px;
overflow: auto;
}
.page-indicator {
line-height: 1rem;
padding: 0.5rem;
background: #212121;
color: #eee;
}
.btn-xs {
padding: .1rem .3rem;
font-size: .875rem;
border-radius: .2rem;
}
.btn {
color: #eee;
}

View File

@ -87,6 +87,7 @@ body {overflow-y:scroll;}
height: 39px; height: 39px;
vertical-align: bottom; vertical-align: bottom;
display: inline; display: inline;
width: 100%;
} }
@media (min-width: 1200px) { @media (min-width: 1200px) {
@ -159,6 +160,7 @@ mark {
.page-indicator { .page-indicator {
line-height: 1rem; line-height: 1rem;
padding: 0.5rem; padding: 0.5rem;
background: #212121;
} }
.btn-xs { .btn-xs {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

View File

@ -197,7 +197,7 @@ function createDocCard(hit) {
let contentHl = getContentHighlight(hit); let contentHl = getContentHighlight(hit);
if (contentHl !== undefined) { if (contentHl !== undefined) {
let contentDiv = document.createElement("div"); let contentDiv = document.createElement("div");
contentDiv.setAttribute("class", "content-div bg-light"); contentDiv.setAttribute("class", "content-div");
contentDiv.insertAdjacentHTML('afterbegin', contentHl); contentDiv.insertAdjacentHTML('afterbegin', contentHl);
docCard.appendChild(contentDiv); docCard.appendChild(contentDiv);
} }
@ -257,7 +257,7 @@ function makePreloader() {
function makePageIndicator(searchResult) { function makePageIndicator(searchResult) {
let pageIndicator = document.createElement("div"); let pageIndicator = document.createElement("div");
pageIndicator.setAttribute("class", "page-indicator shadow-sm bg-light font-weight-light"); pageIndicator.setAttribute("class", "page-indicator shadow-sm font-weight-light");
const totalHits = searchResult["hits"]["total"].hasOwnProperty("value") const totalHits = searchResult["hits"]["total"].hasOwnProperty("value")
? searchResult["hits"]["total"]["value"] : searchResult["hits"]["total"]; ? searchResult["hits"]["total"]["value"] : searchResult["hits"]["total"];
pageIndicator.appendChild(document.createTextNode(docCount + " / " + totalHits)); pageIndicator.appendChild(document.createTextNode(docCount + " / " + totalHits));

View File

@ -21,6 +21,17 @@ jQuery["jsonPost"] = function (url, data) {
}); });
}; };
window.onload = () => {
$("#theme").on("click", () => {
if (document.cookie.length === 0) {
document.cookie = "sist=dark";
} else {
document.cookie = "sist=; Max-Age=-99999999;";
}
window.location.reload();
})
};
function toggleSearchBar() { function toggleSearchBar() {
searchDebounced(); searchDebounced();
} }

View File

@ -9,9 +9,10 @@
</head> </head>
<body> <body>
<nav class="navbar navbar-expand-lg navbar-light"> <nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="/">sist2</a> <a class="navbar-brand" href="/">sist2</a>
<span class="tagline">Lightning-fast file system indexer and search tool </span> <span class="tagline">Lightning-fast file system indexer and search tool </span>
<a style="margin-left: auto" id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
</nav> </nav>
<div class="container"> <div class="container">