Coder Social home page Coder Social logo

Comments (9)

geeklhem avatar geeklhem commented on May 21, 2024 1

I had a crack at it. Here is a quick hack for the posts (not the drafts).

The trick is to use directory-files-recursively instead of directory-file

 (defun org-static-blog-get-post-filenames ()
   "Returns a list of all posts."
-  (directory-files
-   org-static-blog-posts-directory t ".*\\.org$" nil))
+  (directory-files-recursively
+   org-static-blog-posts-directory ".*\\.org$" nil))
 
 (defun org-static-blog-get-draft-filenames ()
   "Returns a list of all drafts."

Then we have to correctly match html files with the org-files.
The user is automatically prompted to create non existing directories when org-static-blog-publish is called, thanks to some emacs' magic.

@@ -147,13 +147,15 @@ re-rendered."
 (defun org-static-blog-matching-publish-filename (post-filename)
   "Generate HTML file name for POST-FILENAME."
   (concat org-static-blog-publish-directory
+	  (file-name-directory
+	   (file-relative-name post-filename org-static-blog-posts-directory))
           (file-name-base post-filename)
           ".html"))

The save function has to be slightly changed to keep the directory structure:

@@ -167,7 +169,9 @@ The buffer is disposed after the macro exits (unless it already
 existed before)."
   `(save-excursion
      (let ((current-buffer (current-buffer))
-           (buffer-exists (get-buffer (file-name-nondirectory ,file)))
+           (buffer-exists (get-buffer (concat
+				       (file-relative-name ,file org-static-blog-posts-directory)
+				       (file-name-nondirectory ,file))))
            (result nil))
        (if buffer-exists
            (switch-to-buffer buffer-exists)

Finally, the URLs need to reflect the directory structure too.

@@ -255,8 +259,11 @@ Preamble and Postamble are excluded, too."
 
 (defun org-static-blog-get-url (post-filename)
   "Generate a URL to the published POST-FILENAME."
+  (concat
+   (file-name-directory
+     (file-relative-name post-filename org-static-blog-posts-directory))
   (file-name-nondirectory
-   (org-static-blog-matching-publish-filename post-filename)))
+   (org-static-blog-matching-publish-filename post-filename))))
 
 ;;;###autoload
 (defun org-static-blog-publish-file (post-filename)
` 

If you guys think its on the good track we can polish it up once I am done with the semantic HTML PR.

from org-static-blog.

neeasade avatar neeasade commented on May 21, 2024 1

One alternative approach I would like to see is a user provided function that returns the output target. It could take in the existing file path, or the file path + time, then you could return /path/to/site/2018/05/03/post.html -- The default value could just be a function that returns post.html for existing stuff, but then users could use whatever they like

from org-static-blog.

bastibe avatar bastibe commented on May 21, 2024

That's a great idea! Do you want to create a pull request and make sure that it works?

from org-static-blog.

bandali0 avatar bandali0 commented on May 21, 2024

Sorry for the late reply; I've been swamped lately.

If I manage to find some free time I'll try to put together a PR and send it over, but otherwise, feel free to beat me to it :)

from org-static-blog.

bastibe avatar bastibe commented on May 21, 2024

Cool, no rush!

from org-static-blog.

bastibe avatar bastibe commented on May 21, 2024

Cool! I'll look forward to the PR!

from org-static-blog.

bastibe avatar bastibe commented on May 21, 2024

Cool idea! I like it!

from org-static-blog.

justinabrahms avatar justinabrahms commented on May 21, 2024

I believe this is done now as of #83

from org-static-blog.

bandali0 avatar bandali0 commented on May 21, 2024

I think so too, thanks! Closing; but feel free to reopen if needed.

from org-static-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.