void finalize_store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *dd) { dt_imageio_latex_t *d = (dt_imageio_latex_t *)dd; char filename[PATH_MAX] = { 0 }; snprintf(filename, sizeof(filename), "%s", d->cached_dirname); char *c = filename + strlen(filename); sprintf(c, "/photobook.cls"); copy_res("/latex/photobook.cls", filename); sprintf(c, "/main.tex"); const char *title = d->title; FILE *f = fopen(filename, "wb"); if(!f) return; fprintf(f, "\\newcommand{\\dttitle}{%s}\n" "\\newcommand{\\dtauthor}{the author}\n" "\\newcommand{\\dtsubject}{the matter}\n" "\\newcommand{\\dtkeywords}{this, that}\n" "\\documentclass{photobook} %% use [draftmode] for preview\n" "\\color{white}\n" "\\pagecolor{black}\n" "\\begin{document}\n" "\\maketitle\n" "\\pagestyle{empty}\n", title); while(d->l) { pair_t *p = (pair_t *)d->l->data; fprintf(f, "%s", p->line); free(p); d->l = g_list_delete_link(d->l, d->l); } fprintf(f, "\\end{document}" "%% created with %s\n", darktable_package_string); fclose(f); }
void finalize_store(dt_imageio_module_storage_t *self, void *dd) { dt_imageio_gallery_t *d = (dt_imageio_gallery_t *)dd; char filename[DT_MAX_PATH_LEN]; snprintf(filename, DT_MAX_PATH_LEN, "%s", d->cached_dirname); char *c = filename + strlen(filename); // also create style/ subdir: sprintf(c, "/style"); g_mkdir_with_parents(filename, 0755); sprintf(c, "/style/style.css"); copy_res("/style/style.css", filename); sprintf(c, "/style/favicon.ico"); copy_res("/style/favicon.ico", filename); sprintf(c, "/style/bullet.gif"); copy_res("/style/bullet.gif", filename); sprintf(c, "/style/close.gif"); copy_res("/style/close.gif", filename); sprintf(c, "/style/closelabel.gif"); copy_res("/style/closelabel.gif", filename); sprintf(c, "/style/donate-button.gif"); copy_res("/style/donate-button.gif", filename); sprintf(c, "/style/download-icon.gif"); copy_res("/style/download-icon.gif", filename); sprintf(c, "/style/image-1.jpg"); copy_res("/style/image-1.jpg", filename); sprintf(c, "/style/lightbox.css"); copy_res("/style/lightbox.css", filename); sprintf(c, "/style/loading.gif"); copy_res("/style/loading.gif", filename); sprintf(c, "/style/nextlabel.gif"); copy_res("/style/nextlabel.gif", filename); sprintf(c, "/style/prevlabel.gif"); copy_res("/style/prevlabel.gif", filename); sprintf(c, "/style/thumb-1.jpg"); copy_res("/style/thumb-1.jpg", filename); // create subdir js for lightbox2 viewer scripts sprintf(c, "/js"); g_mkdir_with_parents(filename, 0755); sprintf(c, "/js/builder.js"); copy_res("/js/builder.js", filename); sprintf(c, "/js/effects.js"); copy_res("/js/effects.js", filename); sprintf(c, "/js/lightbox.js"); copy_res("/js/lightbox.js", filename); sprintf(c, "/js/lightbox-web.js"); copy_res("/js/lightbox-web.js", filename); sprintf(c, "/js/prototype.js"); copy_res("/js/prototype.js", filename); sprintf(c, "/js/scriptaculous.js"); copy_res("/js/scriptaculous.js", filename); sprintf(c, "/index.html"); const char *title = d->title; FILE *f = fopen(filename, "wb"); if(!f) return; fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" " <head>\n" " <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n" " <link rel=\"shortcut icon\" href=\"style/favicon.ico\" />\n" " <link rel=\"stylesheet\" href=\"style/style.css\" type=\"text/css\" />\n" " <link rel=\"stylesheet\" href=\"style/lightbox.css\" type=\"text/css\" media=\"screen\" />" " <script type=\"text/javascript\" src=\"js/prototype.js\"></script>\n" " <script type=\"text/javascript\" src=\"js/scriptaculous.js?load=effects,builder\"></script>\n" " <script type=\"text/javascript\" src=\"js/lightbox.js\"></script>\n" " <title>%s</title>\n" " </head>\n" " <body>\n" " <div class=\"title\">%s</div>\n" " <div class=\"page\">\n", title, title); while(d->l) { pair_t *p = (pair_t *)d->l->data; fprintf(f, "%s", p->line); free(p); d->l = g_list_delete_link(d->l, d->l); } fprintf(f, " <p style=\"clear:both;\"></p>\n" " </div>\n" " <div class=\"footer\">\n" " <script language=\"JavaScript\" type=\"text/javascript\">\n" " document.write(\"download all: <em>wget -r -np -nc -k \" + document.documentURI + \"</em>\")\n" " </script><br />\n" " created with darktable "PACKAGE_VERSION"\n" " </div>\n" " </body>\n" "</html>\n" ); fclose(f); }
void finalize_store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *dd) { dt_imageio_gallery_t *d = (dt_imageio_gallery_t *)dd; char filename[PATH_MAX] = { 0 }; snprintf(filename, sizeof(filename), "%s", d->cached_dirname); char *c = filename + strlen(filename); // also create style/ subdir: sprintf(c, "/style"); g_mkdir_with_parents(filename, 0755); sprintf(c, "/style/style.css"); copy_res("/style/style.css", filename); sprintf(c, "/style/favicon.ico"); copy_res("/style/favicon.ico", filename); // create subdir pswp for photoswipe scripts sprintf(c, "/pswp/default-skin/"); g_mkdir_with_parents(filename, 0755); sprintf(c, "/pswp/photoswipe.js"); copy_res("/pswp/photoswipe.js", filename); sprintf(c, "/pswp/photoswipe.min.js"); copy_res("/pswp/photoswipe.min.js", filename); sprintf(c, "/pswp/photoswipe-ui-default.js"); copy_res("/pswp/photoswipe-ui-default.js", filename); sprintf(c, "/pswp/photoswipe.css"); copy_res("/pswp/photoswipe.css", filename); sprintf(c, "/pswp/photoswipe-ui-default.min.js"); copy_res("/pswp/photoswipe-ui-default.min.js", filename); sprintf(c, "/pswp/default-skin/default-skin.css"); copy_res("/pswp/default-skin/default-skin.css", filename); sprintf(c, "/pswp/default-skin/default-skin.png"); copy_res("/pswp/default-skin/default-skin.png", filename); sprintf(c, "/pswp/default-skin/default-skin.svg"); copy_res("/pswp/default-skin/default-skin.svg", filename); sprintf(c, "/pswp/default-skin/preloader.gif"); copy_res("/pswp/default-skin/preloader.gif", filename); sprintf(c, "/index.html"); const char *title = d->title; FILE *f = g_fopen(filename, "wb"); if(!f) return; fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" " <head>\n" " <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n" " <link rel=\"shortcut icon\" href=\"style/favicon.ico\" />\n" " <link rel=\"stylesheet\" href=\"style/style.css\" type=\"text/css\" />\n" " <link rel=\"stylesheet\" href=\"pswp/photoswipe.css\">\n" " <link rel=\"stylesheet\" href=\"pswp/default-skin/default-skin.css\">\n" " <script src=\"pswp/photoswipe.min.js\"></script>\n" " <script src=\"pswp/photoswipe-ui-default.min.js\"></script>\n" " <title>%s</title>\n" " </head>\n" " <body>\n" " <div class=\"title\">%s</div>\n" " <div class=\"page\">\n", title, title); size_t count = 0; GList *tmp = d->l; while(tmp) { pair_t *p = (pair_t *)tmp->data; fprintf(f, "%s", p->line); tmp = g_list_next(tmp); count++; } fprintf(f, " <p style=\"clear:both;\"></p>\n" " </div>\n" " <div class=\"footer\">\n" " <script language=\"JavaScript\" type=\"text/javascript\">\n" " document.write(\"download all: <em>curl -O# \" + document.documentURI.replace( /\\\\/g, '/' ).replace( /\\/[^\\/]*$/, '' ) + \"/img_[0000-%04zu].jpg</em>\")\n" " </script><br />\n" " created with %s\n" " </div>\n" " <div class=\"pswp\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">\n" " <div class=\"pswp__bg\"></div>\n" " <div class=\"pswp__scroll-wrap\">\n" " <div class=\"pswp__container\">\n" " <div class=\"pswp__item\"></div>\n" " <div class=\"pswp__item\"></div>\n" " <div class=\"pswp__item\"></div>\n" " </div>\n" " <div class=\"pswp__ui pswp__ui--hidden\">\n" " <div class=\"pswp__top-bar\">\n" " <div class=\"pswp__counter\"></div>\n" " <button class=\"pswp__button pswp__button--close\" title=\"Close (Esc)\"></button>\n" " <button class=\"pswp__button pswp__button--share\" title=\"Share\"></button>\n" " <button class=\"pswp__button pswp__button--fs\" title=\"Toggle fullscreen\"></button>\n" " <button class=\"pswp__button pswp__button--zoom\" title=\"Zoom in/out\"></button>\n" " <div class=\"pswp__preloader\">\n" " <div class=\"pswp__preloader__icn\">\n" " <div class=\"pswp__preloader__cut\">\n" " <div class=\"pswp__preloader__donut\"></div>\n" " </div>\n" " </div>\n" " </div>\n" " </div>\n" " <div class=\"pswp__share-modal pswp__share-modal--hidden pswp__single-tap\">\n" " <div class=\"pswp__share-tooltip\"></div>\n" " </div>\n" " <button class=\"pswp__button pswp__button--arrow--left\" title=\"Previous (arrow left)\">\n" " </button>\n" " <button class=\"pswp__button pswp__button--arrow--right\" title=\"Next (arrow right)\">\n" " </button>\n" " <div class=\"pswp__caption\">\n" " <div class=\"pswp__caption__center\"></div>\n" " </div>\n" " </div>\n" " </div>\n" " </div>\n" " </body>\n" "<script>\n" "var pswpElement = document.querySelectorAll('.pswp')[0];\n" "var items = [\n", count, darktable_package_string); while(d->l) { pair_t *p = (pair_t *)d->l->data; fprintf(f, "%s", p->item); free(p); d->l = g_list_delete_link(d->l, d->l); } fprintf(f, "];\n" "function openSwipe(img)\n" "{\n" " // define options (if needed)\n" " var options = {\n" " // optionName: 'option value'\n" " index: img // start at first slide\n" " };\n" " var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);\n" " gallery.init();\n" "}\n" "</script>\n" "</html>\n"); fclose(f); }