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