Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site content is not updated #5

Open
zenzjtech opened this issue Mar 7, 2017 · 13 comments
Open

Site content is not updated #5

zenzjtech opened this issue Mar 7, 2017 · 13 comments

Comments

@zenzjtech
Copy link

你好,
Site content is not updated after bm/config-vars, bm/init, and bm/preview, but can only be updated after bm/config-vars, restart Emacs, bm/init, and bm/preview.

Is this a nomal behavior of blog-minimal?
谢谢

@thiefuniverse
Copy link
Owner

Hello, do you eval-buffer with your blog-minimal-vars.el ? Oh, maybe I can add it before executing blog-minimal-init.

@zenzjtech
Copy link
Author

Hello,
I try eval-buffer my 'bog-minimal-vars.el`, but still no effect :(.

@thiefuniverse
Copy link
Owner

Thank you, it's really a bug. I haven't updated vars when generate index.html. Now it's fixed. You can download new three *.el to change your origin files. I changed blog-minimal-preview-blog function.
Thank you again.

@thiefuniverse
Copy link
Owner

I think I have fixed it passing my test. Hope you can test it.

@zenzjtech
Copy link
Author

Hi,
I've replaced old folder by new folder, but still have to restart Emacs for the change to take effects.

@thiefuniverse
Copy link
Owner

I test it like this. It works. Really sometimes it can't refresh and you can try press F5 to refresh these static htmls.( I think maybe browser recognizes static htmls and just load them with cache buffer).
out

@zenzjtech
Copy link
Author

zenzjtech commented Mar 9, 2017

Hmm, I check the content of index.html every time after executing blog-minimal-init, but its content is constant until I restarted emacs and executing bm-init again.

@thiefuniverse
Copy link
Owner

You can try to eval

   (blog-minimal-render-main-index)

at *scratch* buffer , and then see there is a line 'wrote **** index.html' sentance at *message* buffer.

This function should be like this, you can examine whether it's same with mine or not.

(defun blog-minimal-render-main-index ()
  "Render main index for blog minimal."
  (blog-minimal-update-vars)  ;;; this function will update your configuration vars
  (ht-remove blog-minimal-header-vars "high-dir")
  (blog-minimal-update-index-vars t)

  (let ((main-vars
	  (ht-merge blog-minimal-header-vars blog-minimal-person-zone-vars blog-minimal-nav-vars blog-minimal-blog-index-vars blog-minimal-footer-vars)))
      (blog-minimal-string-to-file (mustache-render
		   "{{> main-index}}"
		   main-vars)
		      (concat blog-minimal-blog-main-dir "index.html"))))

When you want to add new post, you can use

(blog-minimal-render-current-article)
(blog-minimal-render-all-org-files)

update index you can use this (actually it's invoked in function blog-minimal-preview-blog)

   (blog-minimal-render-main-index)

I think blog-minimal-init is a function for your init configuration, then you don't need to invoke it.

@zenzjtech
Copy link
Author

Hi Thief,
I tried your latest suggestion several times, but still doesn't work. It is really a weird phenomenon,
since I witness the line wrote **** index.html already, and did also try eval-buffer the bm-vars.

@thiefuniverse
Copy link
Owner

Hello,
I think you can examine index.html in your blog-main-dir is whether changed or not.
And what's your definition of function blog-minimal-render-main-index ? (You can press C-h f, and then find this function's location) It's same with my previous code? Maybe you can try to use latest version or press F5 to refresh pages. I am also confused.

@zenzjtech
Copy link
Author

zenzjtech commented Mar 13, 2017

After pulling the newest code, I tried your suggestion, the result is that index.html isn't updated at all.
I found this works: in blog-minimal-vars.el, Instead of updating the value at the default position, I change variables directly within defun blog-minimal-update-vars() as you can see in the following paragraph of code, then eval-buffer and finally preview.

  "Update all vars for template."
  (eval-buffer)
  (setq blog-minimal-header-vars
        (ht
   ;;; for header
         ("page-title" blog-minimal-page-title)
         ("author" blog-minimal-author)
         ("description" blog-minimal-description)
         ("keywords" blog-minimal-blog-keywords)))

  (setq blog-minimal-person-zone-vars
        (ht
   ;;; for person-zone
         ("blog-name" "nononame00.el")  =>>>>>>>>> HERE
         ("master-name" blog-minimal-master-name)
         ("avatar" blog-minimal-avatar-path)    ; for avatar
         ("one-cool-sentence" blog-minimal-one-cool-sentence)))
....

@thiefuniverse
Copy link
Owner

You can see that I invoke blog-minimal-render-main-index , and invoke (blog-minimal-update-vars) in blog-minimal-render-main-index.

(defun blog-minimal-preview-blog ()
  "Preivew blog minimal."
  (interactive)
  (blog-minimal-render-main-index) ;;; here
  (httpd-serve-directory blog-minimal-blog-main-dir)
  (browse-url (format "http://%s:%d" "127.0.0.1" httpd-port)))
(defun blog-minimal-render-main-index ()
  "Render main index for blog minimal."
  (blog-minimal-update-vars) ;;; here
  (ht-remove blog-minimal-header-vars "high-dir")
  (blog-minimal-update-index-vars t)

So when its vars are changed, you invoke preview-blog which has updated vars.

@zenzjtech
Copy link
Author

Yep, I can see the logic flow. I try debugging stacktrace by edebug already.
What I would like to say in the previous post is that (blog-minimal-update-vars) is not working as expected. As I understand, the function need to record the change of vars made by user, but actually it didnot fulfil that. It is until I change the values of vars directly inside that function that index.html would work normally as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants