Git Product home page Git Product logo

site-generator's Introduction

site-generator

A Clojure library designed to ... well, that part is up to you.

Run Locally

You must generate a src/site_generator/env.clj file and insert your AWS credentials into it (this allows for S3 image upload to work). The file should look like the following:

(ns site-generator.env)

(def cred {:access-key "YOUR AWS ACCESS KEY", :secret-key "YOUR AWS SECRET KEY"})

Then in your terminal, run: bin/set_env.sh [STAGE] (Either dev, staging, or production) lein ring server-headless

The site can be reached in your browser at http://localhost:3000/

Notes on Enlive

Snippets are the parts of your page. Snippets can contain other snippets.

For a static website templates define each page. They contain snippets. A template itself is basically a snippet that serializes its output. So it will return a seq of strings.

In larger applications templates need not define a full page and can be a part of a page.

Both snippets and templates require an HTML file on the classpath that they can operate on.

Selectors are like CSS selectors and allow you to specify the part of the HTML that you want to transform. Transformations are the functions to transform the HTML selected by the selectors.

A selector is a vector of predicates. For a logical AND within a selector put the predicates to be AND'ed into a subvector.

So [:p (attr? :lang)] is going to match any elements with a lang attribute inside a :p element. On the other hand, [[:p (attr? :lang)]] is going to match any p with a lang attribute.

On the other hand sets are a logical OR. So [#{:div.class1 :div.class2}] match every div which has either class1 or class2. This can alternatively be written as [[:div #{:.class1 .class2}]]. Indeed you can have nested "ors" and "ands" which means nested sets and vectors.

Deployment

Deployment is very simple. We use the bin/deploy.sh script:

bin/deploy.sh {STAGE}

e.g. bin/deploy.sh staging

where STAGE is one of production or staging.

staging deploys to staging.epxlabs.com production deploys to www.epxlabs.com

What happens when we run bin/deploy.sh?

  1. Verify the stage is one of staging or production
  2. Switch the correct stage config to src/site_generator/active_config.clj
  3. Build the site and export to resources/exported_site with lein export-site
  4. Upload the exported site and related assets to the corresponding website S3 bucket

What happens when we run lein export-site?

  1. Leiningen runs lein run -m site-generator.core/export
  2. export hydrates templates and exports the site and bundled assets to resources/exported_site

Super manual deploy (not recommended):

  1. In emacs, navigate to src/site-generator/core.clj
  2. Use C-c M-j to boot a repl
  3. Use C-c M-n to switch to the namespace of the core file
  4. Use C-c C-k to compile
  5. Run the (export) in your repl
  6. In your terminal, run ./deploy.sh {STAGE} (note this will basically repeat the above 5 steps)

This will deploy to staging.epxlabs.com

Editing HTML

To edit HTML files and see the changes immediately without rebooting your local server, navigate to src/site-generator/snippets.clj and use M-x touch

Adding a Blog Post

Blog posts should be in markdown format and should be located in resources/partials/blog-posts. They should use the format YEAR-MONTH-DATE-blog-title.markdown.

Additionally, you must add your blog_post to the blogs vector in src/site_generator/snippets.clj using the following format:

{:title "Your title"
 :date "Today's date"
 :author "Your name"
 :file-path "resources/partials/blog-posts/your-blog.markdown"
 :display-image "your-image.jpg"}

To add images to your blog post, place them in resources/public/blog_images and use the following markdown syntax: ![ALT-TEXT]~*FILE NAME*~

Alt text should be whatever you want the name of the image to be when it is hovered over, and file name should be the exact name of the image file.

NOTE: Both file names in the blog and in the display-image key in the map should just be the name of the file itself without the path. So, "your-image.jpg" instead of "resources/public/blog_images/your_image.jpg".

License

Copyright © 2016 EPX Labs, Inc.

But now Ebahsini says: WTF License -- Have Fun!

site-generator's People

Contributors

alexmartin1124 avatar ebahsini avatar prachetasp avatar brianknapp avatar alex-shlyonov avatar scelve avatar cmcgill2 avatar brianrosamilia avatar hakutsuru avatar bogdan1709 avatar

Watchers

James Cloos avatar  avatar  avatar

site-generator's Issues

Make the Mission less about me

Would like to make the Mission less about me and more about being leaders in the Serverless movement and assembling a world-class team that can take on a wide range of problems and deliver better solutions faster.

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.