(setq user-full-name "Stephane Adjemian")
(setq user-mail-address "stepan@adjemian.eu")
(set-language-environment "UTF-8")

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)


(use-package ox-publish
  :init
  (setq  org-html-validation-link nil
         make-backup-files nil
         org-src-fontify-natively t)

  (defun sa-filter-local-links (link backend info)
    "Filter that converts all the /index.html links to /"
    (if (org-export-derived-backend-p backend 'html)
        (replace-regexp-in-string "/index.html" "/" link)))

  :config
  (setq org-publish-project-alist
        '(
          ;; Content that should be processed.
          ("pages"
           :base-directory "./pages"
           :base-extension "org"
           :publishing-directory "./output"
           :recursive t
           :publishing-function org-html-publish-to-html
           :headline-levels 4
           :section-numbers nil
           :html-head nil
           :html-head-include-default-style nil
           :html-head-include-scripts nil
           :html-preamble nil
           :html-postamble nil
           )
          ("blog"
           :base-directory "./blog"
           :base-extension "org"
           :publishing-directory "./output/posts"
           :recursive t
           :publishing-function org-html-publish-to-html
           :headline-levels 4
           :section-numbers nil
           :html-head nil
           :html-head-include-default-style nil
           :html-head-include-scripts nil
           :html-preamble "<h1 class=\"title\">%t</h1>
<ul style=\"text-align:center; font-size:1.2rem; list-style-type:none; margin:0; padding:0;\">
{<li style=\"display: inline;\"><a href=\"../\"><span style='font-size:25px;'>&#9757;</span></a></li>,
<li style=\"display: inline;\"><a href=\"./index.org\"><span style='font-size:25px;'>&#9760;</span></a></li>}
</ul>
<br/>
<br/>
"
           :html-postamble "<br/><br/><br/><hr/>
<footer>
  <div class=\"copyright-container-and-source\">
    <div class=\"copyright\">
      <ul style=\"text-align:center; font-size:1.2rem; list-style-type:none; margin:0; padding:0;\">
        %a, %d <br/>
        %e <br/>
      </ul>
    </div>
    <div class=\"generated\">
    <ul style=\"text-align:center; font-size:1.2rem; list-style-type:none; margin:0; padding:0;\">
      Created with %c on <a href=\"https://www.gnu.org\">GNU</a>/<a href=\"https://www.kernel.org/\">Linux</a>
    </ul>
    <div class=\"source\">
    <ul style=\"text-align:center; font-size:1.2rem; list-style-type:none; margin:0; padding:0;\">
      Org source for this post is available <a href=\"./index.org\">here</a>
    </ul>
    </div>
    <div class=\"cc-badge\">
      <ul style=\"text-align:center; margin:0; padding:0;\">
        <a rel=\"license\" href=\"https://creativecommons.org/share-your-work/public-domain/cc0/\">
          <img style=\"text-align:center;\", src=\"https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg\"/>
        </a>
      </ul>
    </div>
    <div class=\"gitlab-repo\">
      <ul style=\"text-align:center; margin:0; padding:0;\">
        <a href=\"https://git.adjemian.eu/stepan/stephane-adjemian.fr\" title=\"stephane-adjemian.fr\">
          <i class=\"fab fa-gitlab fa-lg\"></i>
        </a>
      </ul>
    </div>
  </div>
</footer>
<hr/>"
           )
          ;; For static files (untouched by emacs)
          ("static-pages"
           :base-directory "./pages"
           :base-extension "asc\\|css\\|scss\\|less\\|ttf\\|woff\\|woff2\\|eot\\|yml\\|json\\|js\\|png\\|ttf\\|jpg\\|gif\\|pdf\\|svg\\|tex\\|m\\|py\\|jl"
           :publishing-directory "./output"
           :recursive t
           :publishing-function org-publish-attachment
           )
          ("static-blog"
           :base-directory "./blog"
           :base-extension "org\\|css\\|yml\\|json\\|js\\|png\\|jpg\\|gif\\|pdf\\|svg\\|tex\\|m\\|py\\|jl"
           :publishing-directory "./output/posts"
           :recursive t
           :publishing-function org-publish-attachment
           )


          ;; Combine the two previous components in a single one
          ("site" :components ("pages" "blog" "static-pages" "static-blog"))))

  (add-to-list 'org-export-filter-link-functions 'sa-filter-local-links)
  )

                                        ;(use-package htmlize
                                        ;  :ensure t);
                                        ;
                                        ;(setq org-export-htmlize-output-type 'css);


(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (emacs-lisp . t)
   (org . t)
   (shell . t)
   (python . t)
   (gnuplot . t)
   (matlab . t)
   (R . t)
   (lilypond . t)
   ))

(setq org-confirm-babel-evaluate nil)
;(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(setq org-babel-python-command "python3")
(setq org-html-htmlize-output-type 'css)
(setq org-html-head-include-default-style nil)
