Giter VIP home page Giter VIP logo

dropblog's Introduction

Dropblog

A simple blog engine written in clojure and noir. Just drop a markdown file into your dropbox folder, and watch your post go live.

Getting Started

First add dropblog as a dependency in your project.clj file:

[benekastah/dropblog "0.1.0-SNAPSHOT"]

Then, create a directory under resources/posts (or, in order to make it work from Dropbox, symlink a folder inside your Dropbox folder into resources/posts). This will act as a hotfolder: any markdown file placed in this folder will turn into a blog post within 10 or so seconds.

To make this work, add a small bit of code to your server.clj file:

(ns myblog.server
  (:require [noir.server :as server]
            [dropblog.core :as dropblog]))

(dropblog/initialize :default-author-name "Block Design")

This will initialize the options you pass in and start the process that looks for new posts.

Then you just need to define a couple simple routes, one for the blog stream and the other for a single post:

(ns myblog.views.home
  (:require [dropblog.views [post-stream :as post-stream]
                             [post :as post]])
  (:use [noir.core :only [defpage defpartial]]
        [hiccup.core :only [html5]]))

(defpartial base [& content]
  (html5
    [:head
      [:title "My Blog"]]
    [:body
      [:h1 "My Blog"]
      [:div content]]))

(defpage "/" []
  (base
    [:h1 "Block Blog"]
    ;; Simply pass in the maximum number of posts you with to display per page
    (post-stream/stream 50)))

(defpage "/post/:year/:month/:day/:title" {:keys [year month day title]}
  (base
    (post/get-post year month day title)))

Then run lein run in your terminal. Once the server starts, navigate to localhost:8080. Go into resources/posts and create a markdown file there (make sure its extension is either md or markdown). Wait a few moments and refresh the page in your browser. You will know the server processed the file properly when you see it renamed to something like 2012-07-04-your-file-name.md.

Once you see the post appear on the web page successfully, reopen the markdown file (make sure you open the renamed file, not the old one which may still be in your editor). You will see it added some json at the top of the file like this:

<!--{
	"created" : "2012-07-05T22:55:02.653Z"
}-->

This is how Dropblog keeps track of exactly what order the posts go in. You can add author information here as well:

<!--{
	"created" : "2012-07-05T22:55:02.653Z",
	"author" : "Paul Harper"
}-->

You can get fancier than that:

<!--{
	"created" : "2012-07-05T22:55:02.653Z",
	"author" : {
		"name" : "Paul Harper",
		"web" : "www.mysite.com",
		"email" : "[email protected]"
	}
}-->

Your byline will change depending on what you include.

License

Copyright (C) 2012 Paul Harper

Distributed under the MIT license.

dropblog's People

Contributors

benekastah avatar inerd89 avatar

Watchers

 avatar

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.