Merge remote-tracking branch 'srht/master'
[worg.git] / blorgit.org
blob76dfef91894cded9d12b646934193db220ec1d0a
1 #+OPTIONS:    H:3 num:nil toc:2 \n:nil ::t |:t ^:{} -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
2 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
3 #+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TAGS:       Write(w) Update(u) Fix(f) Check(c) 
5 #+TITLE:      Blorgit: Org-Mode based, git amenable, blogging engine
6 #+AUTHOR:     Eric Schulte
7 #+EMAIL:      schulte.eric at gmail dot com
8 #+LANGUAGE:   en
9 #+PRIORITIES: A C B
10 #+CATEGORY:   worg
12 # This file is released by its authors and contributors under the GNU
13 # Free Documentation license v1.3 or later, code examples are released
14 # under the GNU General Public License v3 or later.
16 # This file is the default header for new Org files in Worg.  Feel free
17 # to tailor it to your needs.
19 [[file:index.org][{Back to Worg's index}]]
21 * Introduction
23 Blorgit is a blogging engine which uses [[https://orgmode.org][Org-Mode]] for markup, runs on
24 the [[http://www.sinatrarb.com/][Sinatra]] mini web framework, and is amenable to posting and
25 maintenance through [[http://git-scm.com/][git]].  With the addition of a little [[http://www.ruby-lang.org/en/][Ruby]] blorgit
26 creates interactive web pages with [[https://orgmode.org][Org-Mode]].
28 ** Features
30 [[file:images/blorgit/blorgit_features.png]]
32 1) *In Browser Editing* Org-mode files can be edited through the
33      browser.  Upon submitting an edit the original org-mode file is
34      overwritten and the web-page is re-exported.  Edits can be turned
35      on off or with the =editable= [[* Changing Configuration Options][configuration option]] and can be
36      password protected by setting the =auth= [[* Changing Configuration Options][configuration option]]
37 2) *Export to org-mode and LaTeX formats*  The raw *Org-mode* source,
38      and *LaTeX* exports of all pages can be downloaded.
39 3) *Search* The search bar compares your search terms as a
40    /perl-style/ regular expression (in most cases working just like a
41    simple term search) against the org-mode source of each page
42    returning a ranked list.  [[file:images/blorgit/blorgit_search.png]]
43 4) *Sidebar with Recent changes and Directory Listing* The top =N=
44      recently edited pages, and/or directory listings can optionally
45      be presented in a sidebar.  These are controlled through the
46      =recent= and =dir_list= configuration options.
47 5) *Themes* The [[http://github.com/eschulte/blorgit_themes/tree/master][blorgit_themes]] git repository holds prepackaged
48    themes for blorgit.  These can be applied to your installation
49    using the supplied rake commands.  For a list of available themes
50    run =rake themes= from the root of your blorgit installation.
51    Please share any new themes you might
52    create. [[file:images/blorgit/themes.png]]
53 6) *Comments in org-mode files* Pages can optionally be opened for
54    comments, all comments will be stored in a special =* COMMENT
55    Comments= outline header appended to the end of the org file.
56 7) *Git Synchronization* By setting the =git_commit= [[* Changing Configuration Options][configuration
57    option]] to =true= blorgit can be made to automatically commit and
58    push to a git repository after every comment or edit of an org-mode
59    file.
62 * Getting Started (installation and use)
64 0) *Install Ruby*
66    If you don't already have ruby installed on your system then you
67    will need to install [[http://www.ruby-lang.org/en/][Ruby]] and [[http://rubygems.org/][Ruby Gems]] (Ruby's package managment
68    system).*  Be sure to install Ruby 1.8 (should be default option)
69    *not* Ruby 1.9.
71 1) *Install the Required Gems*
73    #+begin_src sh
74    sudo gem install rake sinatra haml sass activesupport
75    #+end_src
77 2) *Install blorgit*
79    #+begin_src sh 
80    git clone git://github.com/eschulte/blorgit.git
81    #+end_src
83    Update the submodules of blorgit to provide file based persistence
84    ([[http://github.com/eschulte/active_file/tree/master][active_file]]), org-mode interaction ([[http://github.com/eschulte/acts_as_org/tree/master][acts_as_org]]), and themes
85    ([[http://github.com/eschulte/blorgit_themes/tree/master][blorgit_themes]]).
87    #+begin_src sh 
88    cd blorgit
89    git submodule init
90    git submodule update
91    #+end_src
93 3) *Create Blogs Directory*
95    Create a blogs directory (in =~/blogs/=) with the default
96    configuration (To change the location of the blogs directory edit
97    =blorgit.yml= in this directory).  Apply the default minimal theme
98    (for a list of available themes run =rake themes=). The Emacs Server
99    must have been started at least once as described under point 5.
101    #+begin_src sh 
102    rake new
103    rake themes:default
104    #+end_src
106 4) *Start Servers*
107   - *Emacs Server*
109     Starting your emacs server allows Emacs to act as a server which
110     can then export org-mode file to html.  To do this we simply need
111     to load the =org-interaction.el= file in =acts_as_org=.  You can
112     do this by executing the following in emacs
114    #+begin_src sh 
115    M-x load-file /path/to/blorgit/backend/acts_as_org/elisp/org-interaction.el
116    #+end_src
118     or with the following shell command
120    #+begin_src sh 
121    emacs -l backend/acts_as_org/elisp/org-interaction.el
122    #+end_src
124   - *Web Server*
126     Start your sinatra web server with the following command
128    #+begin_src sh 
129    ruby blorgit.rb
130    #+end_src
132 5) *View in Browser*
134    [[http://localhost:4567]]
137 * Additional Information
138 ** Common Tasks
139 Ruby has its own make tool called [[http://rake.rubyforge.org/][Rake]].  For a list of the blorgit
140 rake commands run =rake -T= from the root of your blorgit
141 installation.  At the time of writing the available rake tasks are...
143 #+begin_src sh
144 $ rake -T
145 (in /Users/eschulte/src/blorgit)
146 rake exported:delete  # delete all temporary exported files
147 rake exported:list    # list all temporary exported files
148 rake index            # drop a minimal index page into /Users/eschulte/Site...
149 rake info             # return configuration information about the current ...
150 rake new              # create a new blorgit instance
151 rake themes           # list the available themes
152 rake themes:default   # a default theme, should serve as a good starting point
153 rake themes:food      # a food theme for my recipes
154 rake themes:org       # an org-mode theme featuring the folding unicorn
155 #+end_src
157 ** Changing Configuration Options
159 The configuration is controlled through a [[http://www.yaml.org][YAML]] file located at
160 =blorgit.yml= in the base of your blorgit installation.  Configuration
161 variables can be used to control the *title*, *index page*,
162 *stylesheet*, the number of *recent entries* and *directory_listings*
163 shown in the sidebar, automatic synchronization with a *git*
164 repository, *commentability*, *editability* and optional *password
165 protection* for posting edits, .  The default configuration is...
167 #+name: configuration_options
168 #+begin_src sh 
169 --- 
170 title: Blorgit
171 index: index
172 style: stylesheet.css
173 recent: 5
174 dir_list: false
175 git_commit: false
176 commentable: true
177 editable: false
178 auth: 
179 - admin
180 - password
181 #+end_src
183 *** Directory Local Configuration
184 It is possible to specify configuration options for each individual
185 directories of your blorgit site.  To do so write the configuration
186 options you wish to specify to a file named =.blorgit.yml=.  These
187 options will be used when displaying files in the same directory as
188 the =.blorgit.yml= file.  This file follows the same format shown [[* Changing Configuration
189  Options][above]].
191 ** Git
193 If you're wondering where git comes in, initialize your new blogs
194 directory as a git repo, and post all future blogs, moderate comments
195 and commentability of blogs, and manage configuration through git.
197 #+begin_src sh 
198 cd ./blogs
199 git init
200 echo ".exported_*" > .gitignore # ignore export files created automatically by blorgit
201 git add .
202 git commit -a -m "initial commit"
203 #+end_src
205 ** Change blogs directory
207 To change the location of the blogs directory see the =blorgit.yml=
208 global configuration file in the base of your blorgit directory.
210 ** Deploying to a Remote Server
212 **** Thin web server
213 To run using the =run.ru= rackup file use a command like the following
214 (requires the =thin= gem =sudo gem install -v=1.0.0 thin=)
216 #+begin_src sh 
217 ./run.ru -sthin -p4567
218 #+end_src
220 **** Deploying behind a url prefix
221 If you don't want blorgit to sit at the top level of your webserver,
222 but would rather is exist behind a url prefix set the =url_prefix=
223 variable in the run.ru file.
225 **** Remote Emacs Server
226 Blorgit requires a running Emacs to handle the actual export of
227 org-mode pages to html (through the =emacsclient= command).  This
228 requires that an instance of Emacs be left running on the remote
229 server, which I be problematic.  I use [[http://www.gnu.org/software/screen/][gnu-screen]] to start and detach
230 from this Emacs instance as follows...
232 1) ssh into your remote server
233 2) start your screen session with the =screen= command
234    #+begin_src sh 
235    screen
236    #+end_src
237 3) cd to your blorgit directory
238    #+begin_src sh 
239    cd ~/src/blorgit
240    #+end_src
241 4) start emacs loading the =org-interaction.el= file
242    #+begin_src sh 
243    emacs -l backend/acts_as_org/elisp/org-interaction.el
244    #+end_src
245 5) optionally run your webserver through screen as well by 
246    1) switching to a new screen window with =\C-a c=
247    2) start your webserver
248       #+begin_src sh 
249       ./run.ru -sthin
250       #+end_src
251 6) disconnect form screen leaving emacs and the webserver running with
252    =\C-a d=
253 7) logoff from the server
254 8) at any later date you can log back into the server and reattach to
255    the original screen session with
256    #+begin_src sh 
257    screen -r
258    #+end_src
260 ** Extending Blorgit
261 Simplicity and a small hackable code base were key goals in the
262 construction of blorgit.  The =blorgit.rb= file in the base of the
263 application contains all of the logic and html.  Any extensions should
264 be possible through modification of this single file.  For information
265 on the structure of this file, or on the framework on which it is run
266 see [[http://www.sinatrarb.com/][Sinatra]].
267 ** Deploying on a Mac with Apache/Passenger Pane
268 A handy tool for hosting local sites on Mac OSX is the
269 [[http://www.fngtps.com/2008/06/putting-the-pane-back-into-deployment][Apache/Passenger Pane]].  This allows the setup and running of local
270 ruby web applications through a System Preferences Pane, and can be
271 used with blorgit.
273 1) First follow the installation instructions from [[http://www.fngtps.com/2008/06/putting-the-pane-back-into-deployment][putting-the-pane-back-into-deployment]].
274 2) clone blorgit to your =~/Sites= directory
275    #+begin_src sh
276    cd ~/Sites
277    git clone git://github.com/eschulte/blorgit.git
278    cd blorgit
279    git submodule init
280    git submodule update
281    #+end_src
282 3) Create a public and tmp directory, and copy =run.ru= to =config.ru=
283    to trick [[http://www.modrails.com/][Passenger]] into thinking blorgit is a [[http://rubyonrails.org/][rails]] application.
284    #+begin_src sh
285    mkdir public
286    mkdir tmp
287    cp run.ru config.ru
288    #+end_src
289 4) rename the blorgit directory to the name of your local site (in my
290    case "foods")
291    #+begin_src sh
292    cd ~/Sites
293    mv blorgit foods
294    #+end_src
295 5) Configure blorgit as you would normally  (see [[* Getting Started (installation and use)][Getting Started (installation and use)]])
296 6) Add your new blorgit site to Passenger Pane.
298    [[file:images/blorgit/Passenger.png]]
299 7) Restart Apache
300    #+begin_src sh
301    sudo apachectl restart
302    #+end_src
303 8) Point your browser at the url displayed in the Passenger Pane.
304    
305    [[file:images/blorgit/foods.png]]