mirror of
https://github.com/simon987/sist2.git
synced 2025-12-11 14:38:54 +00:00
Dark theme, pdf meta, de-serialize bugfix
This commit is contained in:
@@ -197,8 +197,12 @@ void read_index(const char *path, const char index_id[UUID_STR_LEN], index_func
|
||||
*(buf.buf + line.ext) = '\0';
|
||||
}
|
||||
cJSON_AddStringToObject(document, "name", buf.buf + line.base);
|
||||
*(buf.buf + line.base - 1) = '\0';
|
||||
cJSON_AddStringToObject(document, "path", buf.buf);
|
||||
if (line.base > 0) {
|
||||
*(buf.buf + line.base - 1) = '\0';
|
||||
cJSON_AddStringToObject(document, "path", buf.buf);
|
||||
} else {
|
||||
cJSON_AddStringToObject(document, "path", "");
|
||||
}
|
||||
|
||||
enum metakey key = getc(file);
|
||||
while (key != '\n') {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#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[] = {
|
||||
"sist2 scan [OPTION]... PATH",
|
||||
"sist2 index [OPTION]... INDEX",
|
||||
|
||||
@@ -112,7 +112,7 @@ enum mime {
|
||||
application_x_esrehber=655464,
|
||||
application_x_excel=655465,
|
||||
application_x_executable=655466,
|
||||
application_x_font_sfn=655467 | 0x20000000,
|
||||
application_x_font_sfn=655467,
|
||||
application_x_font_ttf=655468 | 0x20000000,
|
||||
application_x_freelance=655469,
|
||||
application_x_git=655470,
|
||||
@@ -148,224 +148,225 @@ enum mime {
|
||||
application_x_mif=655500,
|
||||
application_x_mix_transfer=655501,
|
||||
application_x_mobipocket_ebook=655502,
|
||||
application_x_ms_pdb=655503,
|
||||
application_x_ms_reader=655504,
|
||||
application_x_navi_animation=655505,
|
||||
application_x_navidoc=655506,
|
||||
application_x_navimap=655507,
|
||||
application_x_navistyle=655508,
|
||||
application_x_netcdf=655509,
|
||||
application_x_newton_compatible_pkg=655510,
|
||||
application_x_object=655511,
|
||||
application_x_omc=655512,
|
||||
application_x_omcdatamaker=655513,
|
||||
application_x_omcregerator=655514,
|
||||
application_x_pagemaker=655515,
|
||||
application_x_pcl=655516,
|
||||
application_x_pixclscript=655517,
|
||||
application_x_pkcs7_certreqresp=655518,
|
||||
application_x_pkcs7_signature=655519,
|
||||
application_x_project=655520,
|
||||
application_x_qpro=655521,
|
||||
application_x_rar=655522,
|
||||
application_x_rpm=655523,
|
||||
application_x_sdp=655524,
|
||||
application_x_sea=655525,
|
||||
application_x_seelogo=655526,
|
||||
application_x_setupscript=655527,
|
||||
application_x_shar=655528,
|
||||
application_x_sharedlib=655529,
|
||||
application_x_shockwave_flash=655530,
|
||||
application_x_sprite=655531,
|
||||
application_x_sqlite3=655532,
|
||||
application_x_sv4cpio=655533,
|
||||
application_x_sv4crc=655534,
|
||||
application_x_tar=655535,
|
||||
application_x_tbook=655536,
|
||||
application_x_tex_tfm=655537,
|
||||
application_x_texinfo=655538,
|
||||
application_x_ustar=655539,
|
||||
application_x_visio=655540,
|
||||
application_x_vnd_audioexplosion_mzz=655541,
|
||||
application_x_vnd_ls_xpix=655542,
|
||||
application_x_vrml=655543,
|
||||
application_x_wais_source=655544,
|
||||
application_x_wine_extension_ini=655545,
|
||||
application_x_wintalk=655546,
|
||||
application_x_world=655547,
|
||||
application_x_wri=655548,
|
||||
application_x_x509_ca_cert=655549,
|
||||
application_x_xz=655550,
|
||||
application_xml=655551,
|
||||
application_zip=655552,
|
||||
audio_it=458945,
|
||||
audio_make=458946,
|
||||
audio_mid=458947,
|
||||
audio_midi=458948,
|
||||
audio_mp4=458949,
|
||||
audio_mpeg=458950,
|
||||
audio_ogg=458951,
|
||||
audio_s3m=458952,
|
||||
audio_tsp_audio=458953,
|
||||
audio_tsplayer=458954,
|
||||
audio_vnd_qcelp=458955,
|
||||
audio_voxware=458956,
|
||||
audio_x_flac=458957,
|
||||
audio_x_gsm=458958,
|
||||
audio_x_jam=458959,
|
||||
audio_x_liveaudio=458960,
|
||||
audio_x_m4a=458961,
|
||||
audio_x_midi=458962,
|
||||
audio_x_mod=458963,
|
||||
audio_x_mp4a_latm=458964,
|
||||
audio_x_mpeg_3=458965,
|
||||
audio_x_mpequrl=458966,
|
||||
audio_x_nspaudio=458967,
|
||||
audio_x_pn_realaudio=458968,
|
||||
audio_x_psid=458969,
|
||||
audio_x_realaudio=458970,
|
||||
audio_x_twinvq=458971,
|
||||
audio_x_twinvq_plugin=458972,
|
||||
audio_x_voc=458973,
|
||||
audio_x_wav=458974,
|
||||
audio_xm=458975,
|
||||
font_otf=327904 | 0x20000000,
|
||||
font_sfnt=327905 | 0x20000000,
|
||||
font_woff=327906 | 0x20000000,
|
||||
font_woff2=327907 | 0x20000000,
|
||||
image_cmu_raster=524516,
|
||||
image_fif=524517,
|
||||
image_florian=524518,
|
||||
image_g3fax=524519,
|
||||
image_gif=524520,
|
||||
image_ief=524521,
|
||||
image_jpeg=524522,
|
||||
image_jutvision=524523,
|
||||
image_naplps=524524,
|
||||
image_pict=524525,
|
||||
image_png=524526,
|
||||
image_svg=524527 | 0x80000000,
|
||||
image_svg_xml=524528 | 0x80000000,
|
||||
image_tiff=524529,
|
||||
image_vnd_adobe_photoshop=524530 | 0x80000000,
|
||||
image_vnd_djvu=524531 | 0x80000000,
|
||||
image_vnd_fpx=524532,
|
||||
image_vnd_microsoft_icon=524533,
|
||||
image_vnd_rn_realflash=524534,
|
||||
image_vnd_rn_realpix=524535,
|
||||
image_vnd_wap_wbmp=524536,
|
||||
image_vnd_xiff=524537,
|
||||
image_webp=524538,
|
||||
image_x_cmu_raster=524539,
|
||||
image_x_cur=524540,
|
||||
image_x_dwg=524541,
|
||||
image_x_eps=524542,
|
||||
image_x_exr=524543,
|
||||
image_x_icns=524544,
|
||||
image_x_icon=524545 | 0x80000000,
|
||||
image_x_jg=524546,
|
||||
image_x_jps=524547,
|
||||
image_x_ms_bmp=524548,
|
||||
image_x_niff=524549,
|
||||
image_x_pcx=524550,
|
||||
image_x_pict=524551,
|
||||
image_x_portable_bitmap=524552,
|
||||
image_x_portable_graymap=524553,
|
||||
image_x_portable_pixmap=524554,
|
||||
image_x_quicktime=524555,
|
||||
image_x_rgb=524556,
|
||||
image_x_tga=524557,
|
||||
image_x_tiff=524558,
|
||||
image_x_xcf=524559 | 0x80000000,
|
||||
image_x_xpixmap=524560 | 0x80000000,
|
||||
image_x_xwindowdump=524561,
|
||||
message_rfc822=196882,
|
||||
model_vnd_dwf=65811,
|
||||
model_vnd_gdl=65812,
|
||||
model_vnd_gs_gdl=65813,
|
||||
model_vrml=65814,
|
||||
model_x_pov=65815,
|
||||
text_asp=590104,
|
||||
text_css=590105,
|
||||
text_html=590106,
|
||||
text_javascript=590107,
|
||||
text_mcf=590108,
|
||||
text_pascal=590109,
|
||||
text_plain=590110,
|
||||
text_richtext=590111,
|
||||
text_scriplet=590112,
|
||||
text_tab_separated_values=590113,
|
||||
text_troff=590114,
|
||||
text_uri_list=590115,
|
||||
text_vnd_abc=590116,
|
||||
text_vnd_fmi_flexstor=590117,
|
||||
text_vnd_wap_wml=590118,
|
||||
text_vnd_wap_wmlscript=590119,
|
||||
text_webviewhtml=590120,
|
||||
text_x_Algol68=590121,
|
||||
text_x_asm=590122,
|
||||
text_x_audiosoft_intra=590123,
|
||||
text_x_awk=590124,
|
||||
text_x_bcpl=590125,
|
||||
text_x_c=590126,
|
||||
text_x_c__=590127,
|
||||
text_x_component=590128,
|
||||
text_x_diff=590129,
|
||||
text_x_fortran=590130,
|
||||
text_x_java=590131,
|
||||
text_x_la_asf=590132,
|
||||
text_x_lisp=590133,
|
||||
text_x_m=590134,
|
||||
text_x_m4=590135,
|
||||
text_x_makefile=590136,
|
||||
text_x_msdos_batch=590137,
|
||||
text_x_pascal=590138,
|
||||
text_x_perl=590139,
|
||||
text_x_php=590140,
|
||||
text_x_po=590141,
|
||||
text_x_python=590142,
|
||||
text_x_ruby=590143,
|
||||
text_x_sass=590144,
|
||||
text_x_scss=590145,
|
||||
text_x_server_parsed_html=590146,
|
||||
text_x_setext=590147,
|
||||
text_x_sgml=590148,
|
||||
text_x_shellscript=590149,
|
||||
text_x_speech=590150,
|
||||
text_x_tcl=590151,
|
||||
text_x_tex=590152,
|
||||
text_x_uil=590153,
|
||||
text_x_uuencode=590154,
|
||||
text_x_vcalendar=590155,
|
||||
text_x_vcard=590156,
|
||||
text_xml=590157,
|
||||
video_animaflex=393550,
|
||||
video_avi=393551,
|
||||
video_avs_video=393552,
|
||||
video_mp4=393553,
|
||||
video_mpeg=393554,
|
||||
video_quicktime=393555,
|
||||
video_vdo=393556,
|
||||
video_vivo=393557,
|
||||
video_vnd_rn_realvideo=393558,
|
||||
video_vosaic=393559,
|
||||
video_webm=393560,
|
||||
video_x_amt_demorun=393561,
|
||||
video_x_amt_showrun=393562,
|
||||
video_x_atomic3d_feature=393563,
|
||||
video_x_dl=393564,
|
||||
video_x_dv=393565,
|
||||
video_x_fli=393566,
|
||||
video_x_flv=393567,
|
||||
video_x_isvideo=393568,
|
||||
video_x_jng=393569 | 0x80000000,
|
||||
video_x_matroska=393570,
|
||||
video_x_mng=393571,
|
||||
video_x_motion_jpeg=393572,
|
||||
video_x_ms_asf=393573,
|
||||
video_x_msvideo=393574,
|
||||
video_x_qtc=393575,
|
||||
video_x_sgi_movie=393576,
|
||||
application_x_ms_compress_szdd=655503,
|
||||
application_x_ms_pdb=655504,
|
||||
application_x_ms_reader=655505,
|
||||
application_x_navi_animation=655506,
|
||||
application_x_navidoc=655507,
|
||||
application_x_navimap=655508,
|
||||
application_x_navistyle=655509,
|
||||
application_x_netcdf=655510,
|
||||
application_x_newton_compatible_pkg=655511,
|
||||
application_x_object=655512,
|
||||
application_x_omc=655513,
|
||||
application_x_omcdatamaker=655514,
|
||||
application_x_omcregerator=655515,
|
||||
application_x_pagemaker=655516,
|
||||
application_x_pcl=655517,
|
||||
application_x_pixclscript=655518,
|
||||
application_x_pkcs7_certreqresp=655519,
|
||||
application_x_pkcs7_signature=655520,
|
||||
application_x_project=655521,
|
||||
application_x_qpro=655522,
|
||||
application_x_rar=655523,
|
||||
application_x_rpm=655524,
|
||||
application_x_sdp=655525,
|
||||
application_x_sea=655526,
|
||||
application_x_seelogo=655527,
|
||||
application_x_setupscript=655528,
|
||||
application_x_shar=655529,
|
||||
application_x_sharedlib=655530,
|
||||
application_x_shockwave_flash=655531,
|
||||
application_x_sprite=655532,
|
||||
application_x_sqlite3=655533,
|
||||
application_x_sv4cpio=655534,
|
||||
application_x_sv4crc=655535,
|
||||
application_x_tar=655536,
|
||||
application_x_tbook=655537,
|
||||
application_x_tex_tfm=655538,
|
||||
application_x_texinfo=655539,
|
||||
application_x_ustar=655540,
|
||||
application_x_visio=655541,
|
||||
application_x_vnd_audioexplosion_mzz=655542,
|
||||
application_x_vnd_ls_xpix=655543,
|
||||
application_x_vrml=655544,
|
||||
application_x_wais_source=655545,
|
||||
application_x_wine_extension_ini=655546,
|
||||
application_x_wintalk=655547,
|
||||
application_x_world=655548,
|
||||
application_x_wri=655549,
|
||||
application_x_x509_ca_cert=655550,
|
||||
application_x_xz=655551,
|
||||
application_xml=655552,
|
||||
application_zip=655553,
|
||||
audio_it=458946,
|
||||
audio_make=458947,
|
||||
audio_mid=458948,
|
||||
audio_midi=458949,
|
||||
audio_mp4=458950,
|
||||
audio_mpeg=458951,
|
||||
audio_ogg=458952,
|
||||
audio_s3m=458953,
|
||||
audio_tsp_audio=458954,
|
||||
audio_tsplayer=458955,
|
||||
audio_vnd_qcelp=458956,
|
||||
audio_voxware=458957,
|
||||
audio_x_flac=458958,
|
||||
audio_x_gsm=458959,
|
||||
audio_x_jam=458960,
|
||||
audio_x_liveaudio=458961,
|
||||
audio_x_m4a=458962,
|
||||
audio_x_midi=458963,
|
||||
audio_x_mod=458964,
|
||||
audio_x_mp4a_latm=458965,
|
||||
audio_x_mpeg_3=458966,
|
||||
audio_x_mpequrl=458967,
|
||||
audio_x_nspaudio=458968,
|
||||
audio_x_pn_realaudio=458969,
|
||||
audio_x_psid=458970,
|
||||
audio_x_realaudio=458971,
|
||||
audio_x_twinvq=458972,
|
||||
audio_x_twinvq_plugin=458973,
|
||||
audio_x_voc=458974,
|
||||
audio_x_wav=458975,
|
||||
audio_xm=458976,
|
||||
font_otf=327905 | 0x20000000,
|
||||
font_sfnt=327906 | 0x20000000,
|
||||
font_woff=327907 | 0x20000000,
|
||||
font_woff2=327908 | 0x20000000,
|
||||
image_cmu_raster=524517,
|
||||
image_fif=524518,
|
||||
image_florian=524519,
|
||||
image_g3fax=524520,
|
||||
image_gif=524521,
|
||||
image_ief=524522,
|
||||
image_jpeg=524523,
|
||||
image_jutvision=524524,
|
||||
image_naplps=524525,
|
||||
image_pict=524526,
|
||||
image_png=524527,
|
||||
image_svg=524528 | 0x80000000,
|
||||
image_svg_xml=524529 | 0x80000000,
|
||||
image_tiff=524530,
|
||||
image_vnd_adobe_photoshop=524531 | 0x80000000,
|
||||
image_vnd_djvu=524532 | 0x80000000,
|
||||
image_vnd_fpx=524533,
|
||||
image_vnd_microsoft_icon=524534,
|
||||
image_vnd_rn_realflash=524535,
|
||||
image_vnd_rn_realpix=524536,
|
||||
image_vnd_wap_wbmp=524537,
|
||||
image_vnd_xiff=524538,
|
||||
image_webp=524539,
|
||||
image_x_cmu_raster=524540,
|
||||
image_x_cur=524541,
|
||||
image_x_dwg=524542,
|
||||
image_x_eps=524543,
|
||||
image_x_exr=524544,
|
||||
image_x_icns=524545,
|
||||
image_x_icon=524546 | 0x80000000,
|
||||
image_x_jg=524547,
|
||||
image_x_jps=524548,
|
||||
image_x_ms_bmp=524549,
|
||||
image_x_niff=524550,
|
||||
image_x_pcx=524551,
|
||||
image_x_pict=524552,
|
||||
image_x_portable_bitmap=524553,
|
||||
image_x_portable_graymap=524554,
|
||||
image_x_portable_pixmap=524555,
|
||||
image_x_quicktime=524556,
|
||||
image_x_rgb=524557,
|
||||
image_x_tga=524558,
|
||||
image_x_tiff=524559,
|
||||
image_x_xcf=524560 | 0x80000000,
|
||||
image_x_xpixmap=524561 | 0x80000000,
|
||||
image_x_xwindowdump=524562,
|
||||
message_rfc822=196883,
|
||||
model_vnd_dwf=65812,
|
||||
model_vnd_gdl=65813,
|
||||
model_vnd_gs_gdl=65814,
|
||||
model_vrml=65815,
|
||||
model_x_pov=65816,
|
||||
text_asp=590105,
|
||||
text_css=590106,
|
||||
text_html=590107,
|
||||
text_javascript=590108,
|
||||
text_mcf=590109,
|
||||
text_pascal=590110,
|
||||
text_plain=590111,
|
||||
text_richtext=590112,
|
||||
text_scriplet=590113,
|
||||
text_tab_separated_values=590114,
|
||||
text_troff=590115,
|
||||
text_uri_list=590116,
|
||||
text_vnd_abc=590117,
|
||||
text_vnd_fmi_flexstor=590118,
|
||||
text_vnd_wap_wml=590119,
|
||||
text_vnd_wap_wmlscript=590120,
|
||||
text_webviewhtml=590121,
|
||||
text_x_Algol68=590122,
|
||||
text_x_asm=590123,
|
||||
text_x_audiosoft_intra=590124,
|
||||
text_x_awk=590125,
|
||||
text_x_bcpl=590126,
|
||||
text_x_c=590127,
|
||||
text_x_c__=590128,
|
||||
text_x_component=590129,
|
||||
text_x_diff=590130,
|
||||
text_x_fortran=590131,
|
||||
text_x_java=590132,
|
||||
text_x_la_asf=590133,
|
||||
text_x_lisp=590134,
|
||||
text_x_m=590135,
|
||||
text_x_m4=590136,
|
||||
text_x_makefile=590137,
|
||||
text_x_msdos_batch=590138,
|
||||
text_x_pascal=590139,
|
||||
text_x_perl=590140,
|
||||
text_x_php=590141,
|
||||
text_x_po=590142,
|
||||
text_x_python=590143,
|
||||
text_x_ruby=590144,
|
||||
text_x_sass=590145,
|
||||
text_x_scss=590146,
|
||||
text_x_server_parsed_html=590147,
|
||||
text_x_setext=590148,
|
||||
text_x_sgml=590149,
|
||||
text_x_shellscript=590150,
|
||||
text_x_speech=590151,
|
||||
text_x_tcl=590152,
|
||||
text_x_tex=590153,
|
||||
text_x_uil=590154,
|
||||
text_x_uuencode=590155,
|
||||
text_x_vcalendar=590156,
|
||||
text_x_vcard=590157,
|
||||
text_xml=590158,
|
||||
video_animaflex=393551,
|
||||
video_avi=393552,
|
||||
video_avs_video=393553,
|
||||
video_mp4=393554,
|
||||
video_mpeg=393555,
|
||||
video_quicktime=393556,
|
||||
video_vdo=393557,
|
||||
video_vivo=393558,
|
||||
video_vnd_rn_realvideo=393559,
|
||||
video_vosaic=393560,
|
||||
video_webm=393561,
|
||||
video_x_amt_demorun=393562,
|
||||
video_x_amt_showrun=393563,
|
||||
video_x_atomic3d_feature=393564,
|
||||
video_x_dl=393565,
|
||||
video_x_dv=393566,
|
||||
video_x_fli=393567,
|
||||
video_x_flv=393568,
|
||||
video_x_isvideo=393569,
|
||||
video_x_jng=393570 | 0x80000000,
|
||||
video_x_matroska=393571,
|
||||
video_x_mng=393572,
|
||||
video_x_motion_jpeg=393573,
|
||||
video_x_ms_asf=393574,
|
||||
video_x_msvideo=393575,
|
||||
video_x_qtc=393576,
|
||||
video_x_sgi_movie=393577,
|
||||
};
|
||||
char *mime_get_mime_text(unsigned int mime_id) {switch (mime_id) {
|
||||
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_cbz: return "application/x-cbz";
|
||||
case application_x_cbr: return "application/x-cbr";
|
||||
case application_x_ms_compress_szdd: return "application/x-ms-compress-szdd";
|
||||
default: return NULL;}}
|
||||
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);
|
||||
@@ -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, "exe", (gpointer)application_x_executable);
|
||||
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, "gsp", (gpointer)application_x_gsp);
|
||||
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, "cbz", (gpointer)application_x_cbz);
|
||||
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;}
|
||||
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);
|
||||
@@ -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-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-ms-compress-szdd", (gpointer)application_x_ms_compress_szdd);
|
||||
return mime_table;}
|
||||
#endif
|
||||
|
||||
@@ -75,6 +75,17 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
||||
stream = fz_open_memory(ctx, buf, buf_len);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
for (int current_page = 0; current_page < page_count; current_page++) {
|
||||
fz_page *page;
|
||||
if (current_page == 0) {
|
||||
fz_page *page; if (current_page == 0) {
|
||||
page = cover;
|
||||
} else {
|
||||
page = fz_load_page(ctx, fzdoc, current_page);
|
||||
|
||||
@@ -43,27 +43,40 @@ int javascript(void *p, onion_request *req, onion_response *res) {
|
||||
return OCS_PROCESSED;
|
||||
}
|
||||
|
||||
int style(void *p, onion_request *req, onion_response *res) {
|
||||
set_default_headers(res);
|
||||
onion_response_set_header(res, "Content-Type", "text/css");
|
||||
onion_response_set_length(res, sizeof(bundle_css));
|
||||
onion_response_write(res, bundle_css, sizeof(bundle_css));
|
||||
return OCS_PROCESSED;
|
||||
int client_requested_dark_theme(onion_request *req) {
|
||||
const char *cookie = onion_request_get_cookie(req, "sist");
|
||||
if (cookie == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return strcmp(cookie, "dark") == 0;
|
||||
}
|
||||
|
||||
int bg_bars(void *p, onion_request *req, onion_response *res) {
|
||||
int style(void *p, onion_request *req, onion_response *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_write(res, bg_bars_png, sizeof(bg_bars_png));
|
||||
|
||||
onion_response_set_header(res, "Content-Type", "text/css");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int img_sprite_skin_flag(void *p, onion_request *req, onion_response *res) {
|
||||
set_default_headers(res);
|
||||
onion_response_set_header(res, "Content-Type", "image/png");
|
||||
onion_response_set_length(res, sizeof(sprite_skin_flat_png));
|
||||
onion_response_write(res, sprite_skin_flat_png, sizeof(sprite_skin_flat_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_write(res, sprite_skin_flat_png, sizeof(sprite_skin_flat_png));
|
||||
}
|
||||
return OCS_PROCESSED;
|
||||
}
|
||||
|
||||
@@ -326,7 +339,7 @@ int index_info(void *p, onion_request *req, onion_response *res) {
|
||||
cJSON_AddStringToObject(idx_json, "name", idx->desc.name);
|
||||
cJSON_AddStringToObject(idx_json, "version", idx->desc.version);
|
||||
cJSON_AddStringToObject(idx_json, "id", idx->desc.uuid);
|
||||
cJSON_AddNumberToObject(idx_json, "timestamp", (double)idx->desc.timestamp);
|
||||
cJSON_AddNumberToObject(idx_json, "timestamp", (double) idx->desc.timestamp);
|
||||
cJSON_AddItemToArray(arr, idx_json);
|
||||
}
|
||||
|
||||
@@ -362,7 +375,7 @@ int file(void *p, onion_request *req, onion_response *res) {
|
||||
|
||||
int ret;
|
||||
if (strlen(idx->desc.rewrite_url) == 0) {
|
||||
ret =serve_file_from_disk(source, idx, req, res);
|
||||
ret = serve_file_from_disk(source, idx, req, res);
|
||||
} else {
|
||||
ret = serve_file_from_url(source, idx, req, res);
|
||||
}
|
||||
@@ -384,7 +397,6 @@ void serve(const char *hostname, const char *port) {
|
||||
onion_url_add(urls, "", search_index);
|
||||
onion_url_add(urls, "css", style);
|
||||
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, "es", search);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user