GithubHelp home page GithubHelp logo

Comments (6)

lacarmen avatar lacarmen commented on June 14, 2024 1

The one in server.clj is for when you're editing (lein ring server) and the one in the -main is for lein run (ie. Compiling once for deployment). Hope that clears things up!

from cryogen-core.

lacarmen avatar lacarmen commented on June 14, 2024

This should help :) You can do what you suggested to read in a different config and then pass that to compile-assets-timed

from cryogen-core.

Folcon avatar Folcon commented on June 14, 2024

So one thing that's unclear, do I need to modify them both? Or is modifying the src/cryogen/server.clj for when I'm editing, and modifying the src/cryogen/core.clj for stuff that always runs?

from cryogen-core.

Folcon avatar Folcon commented on June 14, 2024

It might be worthwhile mentioning that in the docs? 🤷 Thanks a ton for the help =)...

from cryogen-core.

Folcon avatar Folcon commented on June 14, 2024

Managed to figure out a decent enough solution, documented here if anyone else wants do this =)...

In project.clj:

(defproject cryogen "0.1.0"
  :description "Simple static site generator"
  :url "https://github.com/lacarmen/cryogen"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [...
                 [environ "1.1.0"]]  ;; <-- added in environ
  :plugins [[lein-ring "0.12.5"]
            [lein-environ "1.1.0"]]   ;; <-- + the lein plugin
  :main cryogen.core
  :ring {:init cryogen.server/init
         :handler cryogen.server/handler}
  :aliases {"preview" ["ring" "server-headless"]  ;; <-- defined some preview/writing aliases
            "write"   ["with-profile" "write" "ring" "server-headless"]}
  :profiles {:write {:env {:config-path "content/drafting.edn"}}})

In src/cryogen/server.clj, mainly adjusted init:

(ns cryogen.server
  (:require 
   ...
   [environ.core :refer [env]]))

(defn init []
  (load-plugins)
  (let [custom-config-path (env :config-path)
        config-override (fn [] (when custom-config-path (read-string (slurp custom-config-path))))
        compile-assets-timed-fn (if config-override
                                 (comp compile-assets-timed config-override)
                                 compile-assets-timed)]
   (compile-assets-timed-fn)
   (let [ignored-files (-> (resolve-config) :ignored-files)]
     (start-watcher! "content" ignored-files compile-assets-timed-fn)
     (start-watcher! "themes" ignored-files compile-assets-timed-fn))))

This maintains the pleasant property that editing the supplied config while the server is running content/drafting.edn in this case, reloads the config =)...

Works great, thanks!

from cryogen-core.

lacarmen avatar lacarmen commented on June 14, 2024

Nice! Glad you found a solution :)

from cryogen-core.

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.