masasam / emacs-easy-hugo

Emacs major mode for managing hugo
https://gohugo.io/tools/editors/#emacs
GNU General Public License v3.0
362 stars 26 forks source link

Path to Hugo binary #41

Closed max-arnold closed 6 years ago

max-arnold commented 6 years ago

How to specify different Hugo binaries for different blogs (for example if I they require different versions or I do not want to place hugo in PATH)?

masasam commented 6 years ago

Hi @max-arnold . Thank you for comment.

if I they require different versions

I think that if your site don't work on the latest stable version of hugo you should correct the cause of your source. If absolutely require different version, you can do this by changing the binary of hugo when you move the current directory. You can do it by writing elisp in your init.el to change the symbolic link. I think that it is not a easy-hugo problem but your problem.

I do not want to place hugo in PATH

I don't want to support a method that doesn't conform to UNIX standards.

Hope that helps!

max-arnold commented 6 years ago

Ok, more details about my use case:

  1. I use separate python virtualenvs for each blog
  2. I need python in order to deploy my blog (I use Fabric tool for this) and perform other blog-related tasks
  3. I put Hugo binary to virtualenv bin (~/.virtualenvs/blog1/bin/hugo)

The binary is actually in the PATH, but only after I activate virtualenv by doing workon blog1. It allows me to freeze and isolate blog dependencies. Upgrading hugo everywhere is too risky, I prefer to do this separately for each blog.

So, because supporting virtualenvs is out of scope of this project, what I'm asking is to allow me to customize hugo path on per-blog basis.

max-arnold commented 6 years ago

I found multiple (call-process "hugo") calls in the code. Does it make sense to apply the DRY principle and extract them into a function or macros, along with the ability to customize the binary path?

masasam commented 6 years ago

I found multiple (call-process "hugo") calls in the code. Does it make sense to apply the DRY principle and extract them into a function or macros, along with the ability to customize the binary path?

If customizing the binary path permit you to solve the problem, I can respond.

masasam commented 6 years ago

The following runs the Rakefile. Does this method solve your problem?

You can do it in the following way. put deploy.sh and Rakefile at easy-hugo-basedir

deploy.sh

!/bin/sh

rake hello rake pen rake apple chmod a+x deploy.sh

Rakefile

task :hello do File.open("hello.txt", "w") do |f| f.puts("Hello, World!") end end task :pen do File.open("pen.txt", "w") do |f| f.puts("I have a pen!") end end task :apple do File.open("apple.txt", "w") do |f| f.puts("I have an apple!") end end

M-x easy-hugo-github-deploy or Press G on easy-hugo-mode

max-arnold commented 6 years ago

If customizing the binary path permit you to solve the problem, I can respond.

Yes, this would solve my case.

max-arnold commented 6 years ago

And sorry, but I do not understand your Rakefile example. If it is about deployment tasks, then I do not plan to change my deployment method or switch to Rake.

masasam commented 6 years ago

Hi @max-arnold .

Make hugo's binary changeable for each blog at https://github.com/masasam/emacs-easy-hugo/commit/3b0516c87d33a75dd777f6336fdf53be0374abcb

It will be reflected in melpa in around 6 hours.

sample setting

(setq easy-hugo-url "https://yourdomain") (setq easy-hugo-bin "/.virtualenvs/blog1/bin/hugo") (setq easy-hugo-basedir "~/yoursource/") (setq easy-hugo-sshdomain "blogdomain") (setq easy-hugo-root "/home/yourblog/")

(setq easy-hugo-bloglist '(((easy-hugo-basedir . "~/yoursource2/") (easy-hugo-bin . "/.virtualenvs/blog2/bin/hugo") (easy-hugo-url . "https://yourdomain2") (easy-hugo-sshdomain . "blogdomain") (easy-hugo-root . "/home/yourblog2/"))))

max-arnold commented 6 years ago

Thanks a lot! Will try it tomorrow and report here if it works.

max-arnold commented 6 years ago

Sorry, I forgot to inform you that my use case is solved and everything works just fine. You are great!

masasam commented 6 years ago

Hi @max-arnold . Thank you for test. Thanks for the report.