Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 486 lines (422 sloc) 16.24 kb
fe063651 » purcell
2013-12-26 Add missing package description and trailing line
1 ;;; hyde.el --- Major mode to help create and manage Jekyll blogs
2
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
3 ;; Copyright (C) 2004 Noufal Ibrahim <noufal at nibrahim.net.in>
4 ;;
5 ;; This program is not part of Gnu Emacs
6 ;;
7 ;; hyde.el is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
274a70fb »
2011-12-11 Bumps LICENSE to GPLv3 and adds LICENSE and CHANGELOG files
9 ;; the Free Software Foundation; either version 3 of the License, or
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
10 ;; (at your option) any later version.
11 ;;
12 ;; This program is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, write to the Free Software
19 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 ;; 02111-1307, USA.
21
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
22 ;; Requirements
23 (require 'hyde-git)
0062e3f0 »
2010-11-10 Implemented a skeleton hyde-markdown mode and use that for all work t…
24 (require 'hyde-md)
fd69e199 » csw
2012-05-13 Added basic menu.
25 (require 'easymenu)
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
26
95841c15 »
2010-11-10 A few mode map entries
27 ;; Constants for internal use
bdb9e2e7 »
2013-06-18 Bump up version number.
28 (defconst hyde/hyde-version "0.3a"
7b0e8e48 »
2010-11-10 Got font lock to work right
29 "Hyde version")
30
95841c15 »
2010-11-10 A few mode map entries
31 ;; Internal customisable variables
4ce55da6 »
2011-12-11 Added group for all the customisable items
32 (defcustom hyde-mode-hook nil
33 "Hook called by \"hyde-mode\""
34 :type 'hook
35 :group 'hyde)
7b0e8e48 »
2010-11-10 Got font lock to work right
36
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
37
95841c15 »
2010-11-10 A few mode map entries
38 (defcustom hyde-deploy-dir
39 "_site"
4ce55da6 »
2011-12-11 Added group for all the customisable items
40 "Directory which needs to be deployed"
41 :type 'string
42 :group 'hyde)
43
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
44
95841c15 »
2010-11-10 A few mode map entries
45 (defcustom hyde-posts-dir
46 "_posts"
4ce55da6 »
2011-12-11 Added group for all the customisable items
47 "Directory which contains the list of posts"
48 :type 'string
49 :group 'hyde)
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
50
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
51 (defcustom hyde-drafts-dir
52 "_drafts"
4ce55da6 »
2011-12-11 Added group for all the customisable items
53 "Directory which contains post drafts"
54 :type 'string
55 :group 'hyde)
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
56
ad9880a8 »
2013-06-15 Commit assets along with post
57 (defcustom hyde-images-dir
58 "images"
59 "Directory which contains images embedded on the blog"
4ce55da6 »
2011-12-11 Added group for all the customisable items
60 :type 'string
61 :group 'hyde)
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
62
ad9880a8 »
2013-06-15 Commit assets along with post
63
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
64 (defcustom hyde/jekyll-command
a347706b »
2010-11-11 Changed jekyll command
65 "jekyll"
4ce55da6 »
2011-12-11 Added group for all the customisable items
66 "Command to run jekyll to create the blog"
67 :type 'string
68 :group 'hyde)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
69
b19c6d8f » michaeldickens
2013-12-15 Added functions to serve and stop serving.
70 (defcustom hyde/serve-command
71 "jekyll serve"
72 "Command to serve jekyll to the localhost"
73 :type 'string
74 :group 'hyde)
75
76 (defvar hyde/serve-process nil "Process to keep track of serve")
77
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
78 (defcustom hyde/deploy-command
79 "rsync -vr _site/* nkv@ssh.hcoop.net:/afs/hcoop.net/user/n/nk/nkv/public_html/nibrahim.net.in/"
4ce55da6 »
2011-12-11 Added group for all the customisable items
80 "Command used to deploy the site to the actual server"
81 :type 'string
82 :group 'hyde)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
83
95841c15 »
2010-11-10 A few mode map entries
84 ;; Faces and font-locking
7b0e8e48 »
2010-11-10 Got font lock to work right
85 (defface hyde-header-face
86 '(
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
87 (((type tty) (class color)) (:foreground "blue" :background "gray"))
88 (((type graphic) (class color)) (:foreground "blue" :background "gray"))
89 (t (:foreground "blue" :background "gray"))
7b0e8e48 »
2010-11-10 Got font lock to work right
90 )
4ce55da6 »
2011-12-11 Added group for all the customisable items
91 "Face for a hyde header"
92 :group 'hyde)
7b0e8e48 »
2010-11-10 Got font lock to work right
93
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
94 (defface hyde-committed-face
95 '(
96 (((type tty) (class color)) (:foreground "blue"))
97 (((type graphic) (class color)) (:foreground "blue"))
98 (t (:foreground "blue"))
99 )
4ce55da6 »
2011-12-11 Added group for all the customisable items
100 "Face for a file that has been committed"
101 :group 'hyde)
102
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
103
104 (defface hyde-modified-face
105 '(
106 (((type tty) (class color)) (:foreground "red"))
107 (((type graphic) (class color)) (:foreground "red"))
108 (t (:foreground "red"))
109 )
4ce55da6 »
2011-12-11 Added group for all the customisable items
110 "Face for a file that has been modified but not committed"
111 :group 'hyde)
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
112
113 (defface hyde-unsaved-face
114 '(
115 (((type tty) (class color)) (:foreground "black" :background "red"))
116 (((type graphic) (class color)) (:foreground "black" :background "red"))
117 (t (:foreground "black" :background "red"))
118 )
4ce55da6 »
2011-12-11 Added group for all the customisable items
119 "Face for a file that has been modified but not even saved"
120 :group 'hyde)
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
121
122 (defface hyde-pushed-face
123 '(
124 (((type tty) (class color)) (:foreground "green"))
125 (((type graphic) (class color)) (:foreground "green"))
126 (t (:foreground "green"))
127 )
4ce55da6 »
2011-12-11 Added group for all the customisable items
128 "Face for a file that has been pushed to the remote repo"
129 :group 'hyde)
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
130
7b0e8e48 »
2010-11-10 Got font lock to work right
131 (defvar hyde-header-face 'hyde-header-face "Face for a hyde header")
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
132 (defvar hyde-committed-face 'hyde-committed-face)
133 (defvar hyde-modified-face 'hyde-modified-face)
134 (defvar hyde-unsaved-face 'hyde-unsaved-face )
135 (defvar hyde-pushed-face 'hyde-pushed-face)
7b0e8e48 »
2010-11-10 Got font lock to work right
136
137 (defconst hyde-font-lock-keywords
138 (list
139 '("^::.*" . hyde-header-face)
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
140 '("^C :.*" . hyde-committed-face)
141 '("^M :.*" . hyde-modified-face)
142 '("^E :.*" . hyde-unsaved-face)
143 '("^\\. :.*" . hyde-pushed-face)
7b0e8e48 »
2010-11-10 Got font lock to work right
144 )
145 "Font lock keywords for Hyde mode")
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
146
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
147 ;; Version control abstraction
148 (defalias 'hyde/vc-uncommittedp 'hyde/git/uncommittedp "Command to check whether a file has uncommitted changes")
149 (defalias 'hyde/vc-unpushedp 'hyde/git/unpushedp "Command to check whether a file has unpushed changes")
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
150 (defalias 'hyde/vc-pushedp 'hyde/git/pushedp "Command to check whether a file has pushed changes")
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
151 (defalias 'hyde/vc-add 'hyde/git/add "Command to add a file to the DVCS")
152 (defalias 'hyde/vc-commit 'hyde/git/commit "Command to add a file to the DVCS")
153 (defalias 'hyde/vc-push 'hyde/git/push "Command to push the repository")
a71c08bd »
2013-06-18 Use VC rename instead of just mv
154 (defalias 'hyde/vc-rename 'hyde/git/rename "Command to rename files")
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
155
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
156 (defun hyde/hyde-file-local-uncommitted-changed (dir file)
1633403c »
2011-12-11 Added docstrings to all functions
157 "Return whether the given file in the given dir is uncommitted"
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
158 (hyde/vc-uncommittedp (concat hyde-home "/" dir) file))
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
159
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
160 (defun hyde/hyde-file-committed-not-pushed (dir file)
1633403c »
2011-12-11 Added docstrings to all functions
161 "Return whether the given file in the given dir is unpushed"
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
162 (hyde/vc-unpushedp (concat hyde-home "/" dir) file))
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
163
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
164 (defun hyde/hyde-file-committed-pushed (dir file)
1633403c »
2011-12-11 Added docstrings to all functions
165 "Return whether the given file in the given dir is pushed"
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
166 (hyde/vc-pushedp (concat hyde-home "/" dir) file))
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
167
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
168 (defun hyde/hyde-add-file (file)
1633403c »
2011-12-11 Added docstrings to all functions
169 "Stages the given file for commit."
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
170 (hyde/vc-add (concat hyde-home "/" hyde-posts-dir) file))
171
a71c08bd »
2013-06-18 Use VC rename instead of just mv
172 (defun hyde/hyde-rename-file (from to)
ad9880a8 »
2013-06-15 Commit assets along with post
173 "Renames the given version controlled file from to to"
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
174 (hyde/vc-rename hyde-home from to))
175
176 (defun hyde/hyde-commit-post (pos commit-message)
1633403c »
2011-12-11 Added docstrings to all functions
177 "Commits the changes in the repository"
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
178 (interactive "d\nMCommit message : ")
ad9880a8 »
2013-06-15 Commit assets along with post
179 (let* (
180 (post-file-name (nth
181 1
182 (split-string (strip-string (thing-at-point 'line)) " : ")))
183 (dir (get-text-property pos 'dir))
184 (post-full-path (concat hyde-home "/" dir "/" post-file-name))
185 )
186 (hyde/vc-commit (concat hyde-home "/" dir)
187 (append (hyde/hyde-get-post-assets post-full-path) (list post-file-name))
188 commit-message)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
189 (hyde/load-posts)))
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
190
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
191 (defun hyde/hyde-push ()
1633403c »
2011-12-11 Added docstrings to all functions
192 "Publishes the changes to the remote repository"
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
193 (interactive)
194 (hyde/vc-push hyde-home)
195 (hyde/load-posts))
196
197 (defun hyde/run-jekyll ()
1633403c »
2011-12-11 Added docstrings to all functions
198 "Runs jekyll on the directory"
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
199 (interactive)
f711ae11 »
2012-09-22 Expands directory names
200 (shell-command (format "cd %s && %s" (expand-file-name hyde-home) hyde/jekyll-command)))
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
201
b19c6d8f » michaeldickens
2013-12-15 Added functions to serve and stop serving.
202 (defun hyde/stop-serve ()
203 "Stops jekyll serve if running"
204 (interactive)
205 (when hyde/serve-process
206 (delete-process hyde/serve-process)
207 (setq hyde/serve-process nil)))
208
209 (defun hyde/serve ()
210 "Serves jekyll to localhost in an asynchronous process. If
211 already started, stops and restarts."
212 (interactive)
213 (hyde/stop-serve)
214 (setq hyde/serve-process
215 (start-process-shell-command "hyde/serve" "*hyde/serve*"
216 (format "cd %s && %s" (expand-file-name hyde-home) hyde/serve-command))))
217
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
218 (defun hyde/deploy ()
1633403c »
2011-12-11 Added docstrings to all functions
219 "Deploys the generated website (should be run after hyde/run-jekyll"
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
220 (interactive)
f711ae11 »
2012-09-22 Expands directory names
221 (shell-command (format "cd %s && %s" (expand-file-name hyde-home) hyde/deploy-command)))
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
222
223
95841c15 »
2010-11-10 A few mode map entries
224 ;; Utility functions
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
225 (defun hyde/hyde-file-local-unsaved-changed (dir file)
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
226 "Returns true if and only if the given file contains unsaved changes"
227 (let (
228 (buffer (get-file-buffer file))
229 )
230 (if buffer
231 (buffer-modified-p buffer)
232 nil)))
233
234 (defun strip-string (str)
235 "Returns STR with all trailing whitespaces gone"
236 (replace-regexp-in-string "\n$" "" str))
237
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
238 (defun hyde/file-status (dir file)
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
239 "Returns an letter indicating the status of the file as far as
240 hyde is concerned
241
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
242 Committed means that the changes have been committed into your DVCS
243 Pushed out means that they have been pushed to a safe remote repo (github, bitbucket etc.)
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
244
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
245 Status indicators are as follows:
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
246
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
247 . Committed and pushed
248 C Committed but not yet pushed
249 M Local saved changes (uncommitted)
250 E Local unsaved changes"
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
251 (or
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
252 (and (hyde/hyde-file-local-unsaved-changed dir file) "E")
253 (and (hyde/hyde-file-local-uncommitted-changed dir file) "M")
254 (and (hyde/hyde-file-committed-not-pushed dir file) "C")
255 (and (hyde/hyde-file-committed-pushed dir file) ".")))
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
256
257
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
258 (defun hyde/list-format-posts (dir)
259 "Gets the lists of posts from the given directory, formats them
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
260 properly and returns them so that they can be presented to the
261 user"
ad9880a8 »
2013-06-15 Commit assets along with post
262 (let* (
263 (posts-dir (concat (expand-file-name hyde-home) "/" dir))
a8d33601 » alexpos
2014-01-31 Added support for the .md markdown file-extension
264 (posts (directory-files posts-dir nil ".*md\\|.*markdown" nil)))
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
265 (map 'list (lambda (f) (format "%s : %s" (hyde/file-status dir f) f)) posts)))
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
266
ad9880a8 »
2013-06-15 Commit assets along with post
267 (defun hyde/hyde-get-post-assets (post)
268 (save-excursion
088ae8b0 »
2013-06-18 Don't switch buffers while moving assets.
269 (with-current-buffer (find-file post)
270 (goto-char (point-min))
271 (let ((assets '()))
272 (while (re-search-forward "!\\[\\(.*?\\)\\](\\(.*?\\))" nil t)
273 ;; TBD don't try to process http assets.
274 (add-to-list 'assets (concat
275 (strip-string (shell-command-to-string (format "dirname %s" post)))
276 "/"
277 (match-string-no-properties 2))))
278 assets))))
0957a0c4 »
2013-06-15 Fixes hyde-get-post-assets to generate complete list of assets
279
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
280 (defun hyde/promote-to-post (pos)
1633403c »
2011-12-11 Added docstrings to all functions
281 "Promotes the post under the cursor from a draft to a post"
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
282 (interactive "d")
283 (let (
284 (post-file-name (nth
285 1
286 (split-string (strip-string (thing-at-point 'line)) " : ")))
287 (dir (get-text-property pos 'dir)))
288 (if (equal dir hyde-drafts-dir)
ad9880a8 »
2013-06-15 Commit assets along with post
289 (progn
290 ;; Move over post assets
291 (dolist (asset (hyde/hyde-get-post-assets (concat dir "/" post-file-name)))
292 (progn
5d9b093f »
2013-06-18 Change location of published asset directory.
293 (message (concat "Asset is : " asset))
294 (hyde/hyde-rename-file asset
295 (format "%s%s" hyde-home
296 (replace-regexp-in-string "_drafts" "" asset)))))
ad9880a8 »
2013-06-15 Commit assets along with post
297 ;; Move over the actual post
298 (hyde/hyde-rename-file (concat dir "/" post-file-name)
299 (concat hyde-posts-dir "/" post-file-name))))
b0e9063b »
2013-06-18 Automatically commit after promoting.
300 (hyde/vc-commit hyde-home
301 '()
302 (concat "Promoting " post-file-name))
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
303 (hyde/load-posts)))
eab53341 »
2010-11-10 Delayed commit. Verified the statuses working for files in different …
304
7b0e8e48 »
2010-11-10 Got font lock to work right
305
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
306 (defun hyde/open-post-maybe (pos)
1633403c »
2011-12-11 Added docstrings to all functions
307 "Opens the post under cursor in the editor"
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
308 (interactive "d")
309 (let (
1bcd7dce »
2010-11-10 Small fix to open the right file name
310 (post-file-name (nth
311 1
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
312 (split-string (strip-string (thing-at-point 'line)) " : ")))
313 (dir (get-text-property pos 'dir)))
a2f399f5 »
2013-02-17 Implements simple embedding of images.
314 (let ((hyde-buffer (current-buffer)))
315 (find-file
316 (strip-string (concat hyde-home "/" dir "/" post-file-name)))
317 (hyde-markdown-activate-mode hyde-buffer))))
318
95841c15 »
2010-11-10 A few mode map entries
319
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
320 (defun hyde/new-post (title)
1633403c »
2011-12-11 Added docstrings to all functions
321 "Creates a new post"
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
322 (interactive "MEnter post title: ")
aeced31d » copyninja
2012-08-08 Minor fix and a Feature addition
323 (let ((post-file-name (expand-file-name (format "%s/%s/%s.markdown"
32063d97 »
2012-09-22 Merge branch 'copyninja_master'
324 hyde-home hyde-drafts-dir (concat
325 (format-time-string "%Y-%m-%d-")
ad9880a8 »
2013-06-15 Commit assets along with post
326 (downcase (replace-regexp-in-string " " "_" title))))))
327 (hyde-buffer (current-buffer)))
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
328 (save-excursion
329 (find-file post-file-name)
330 (insert "---\n")
331 (insert "layout: post\n")
332 (insert (format "title: \"%s\"\n" title))
aeced31d » copyninja
2012-08-08 Minor fix and a Feature addition
333 (insert (format "date: \"%s\"\n" (format-time-string "%Y-%m-%d %H:%M:%S %z")))
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
334 (insert "---\n\n")
335 (save-buffer))
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
336 (hyde/hyde-add-file post-file-name)
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
337 (find-file post-file-name)
338
339 ;; hyde-home not available in markdown buffer (FIXME)
5bccfad0 »
2013-03-25 Passes hyde-home to markdown buffer even when creating a new post
340 (hyde-markdown-activate-mode hyde-buffer)))
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
341
fdeec3a1 »
2011-12-10 Added quit as a function to hyde
342 (defun hyde/quit ()
343 "Quits hyde"
1633403c »
2011-12-11 Added docstrings to all functions
344 (interactive)
fdeec3a1 »
2011-12-10 Added quit as a function to hyde
345 (kill-buffer (current-buffer)))
346
347
95841c15 »
2010-11-10 A few mode map entries
348 ;; Keymaps
349 (defvar hyde-mode-map
350 (let
351 ((hyde-mode-map (make-sparse-keymap)))
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
352 (define-key hyde-mode-map (kbd "n") 'hyde/new-post)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
353 (define-key hyde-mode-map (kbd "g") 'hyde/load-posts)
354 (define-key hyde-mode-map (kbd "c") 'hyde/hyde-commit-post)
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
355 (define-key hyde-mode-map (kbd "P") 'hyde/hyde-push)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
356 (define-key hyde-mode-map (kbd "j") 'hyde/run-jekyll)
b19c6d8f » michaeldickens
2013-12-15 Added functions to serve and stop serving.
357 (define-key hyde-mode-map (kbd "s") 'hyde/serve)
358 (define-key hyde-mode-map (kbd "k") 'hyde/stop-serve)
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
359 (define-key hyde-mode-map (kbd "d") 'hyde/deploy)
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
360 (define-key hyde-mode-map (kbd "p") 'hyde/promote-to-post)
fdeec3a1 »
2011-12-10 Added quit as a function to hyde
361 (define-key hyde-mode-map (kbd "q") 'hyde/quit)
ee0a681e »
2010-11-10 Basic commands to get statuses of posts working
362 (define-key hyde-mode-map (kbd "RET") 'hyde/open-post-maybe)
95841c15 »
2010-11-10 A few mode map entries
363 hyde-mode-map)
364 "Keymap for Hyde")
365
fd69e199 » csw
2012-05-13 Added basic menu.
366 ;; Menu
367 (easy-menu-define hyde-mode-menu hyde-mode-map
368 "Hyde menu"
369 '("Hyde"
370 ["New post" hyde/new-post t]
371 ["Open post" hyde/open-post-maybe t]
372 ["Commit post" hyde/hyde-commit-post t]
373 ["Promote post" hyde/promote-to-post t]
374 "---"
375 ["Refresh" hyde/load-posts t]
376 ["Run Jekyll" hyde/run-jekyll t]
bfac807d »
2014-01-08 Adds server start/stop to easy menu.
377 ["(Re)start server" hyde/serve t]
378 ["Stop server" hyde/stop-serve t]
379 "---"
fd69e199 » csw
2012-05-13 Added basic menu.
380 ["Deploy" hyde/deploy t]
381 ["Push" hyde/hyde-push t]
382 ["Quit" hyde/quit t]
383 ))
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
384
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
385 (defun hyde/load-posts ()
386 "Load up the posts and present them to the user"
407bea15 »
2010-11-11 Implemeted commit, generate and deploy
387 (interactive)
cb37e9fa »
2010-11-11 A few new faces for the various status types and rudimentary creation…
388 ;; Clear the buffer
389 (toggle-read-only -1)
390 (delete-region (point-min) (point-max))
391 ;; Insert headers
392 (insert ":: Editing blog at:" hyde-home "\n")
9af5e196 »
2010-12-27 Posts are drafts by default now and will be promoted only upon request
393 (insert ":: Posts\n")
394 ;; Insert posts from posts directory
395 (let
396 ((posts (hyde/list-format-posts hyde-posts-dir)))
397 (dolist (post posts)
398 (progn
399 (save-excursion
400 (insert (concat post "\n")))
401 (put-text-property (point) (+ (point) (length post)) 'dir hyde-posts-dir)
402 (forward-line))))
2f9812f9 »
2012-06-24 Creates drafts directory if non existent.
403 ;; Inserts post for the drafts directory
404 (insert "\n:: Drafts\n")
405 (let
406 ((posts (hyde/list-format-posts hyde-drafts-dir)))
407 (dolist (post posts)
408 (progn
409 (save-excursion
410 (insert (concat post "\n")))
411 (put-text-property (point) (+ (point) (length post)) 'dir hyde-drafts-dir)
412 (forward-line))))
413 ;; Insert footer
414 (insert (concat "\n\n:: Hyde version " hyde/hyde-version "\n"))
415 (insert "Key:\n-----\n . Committed and pushed\n C Committed but not yet pushed\n M Local saved changes (uncommitted)\n E Local unsaved changes\n")
416 (toggle-read-only 1))
95841c15 »
2010-11-10 A few mode map entries
417
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
418 (defun hyde/read-config (hyde-home)
d6fa1a60 »
2011-12-10 Adds interactive prompt for hyde-home and config reader
419 "Loads up the config file to set the blog deployment and other information"
420 (let (
421 (config-file (concat hyde-home "/.hyde.el"))
422 )
149ee603 »
2013-06-18 Abort if .hyde.el not found.
423 (if (not (file-exists-p config-file))
424 (error (format "Config file '%s' is missing. Won't continue" config-file)))
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
425 (message (format "Loading %s" config-file))
d6fa1a60 »
2011-12-10 Adds interactive prompt for hyde-home and config reader
426 (load-file config-file)
427 ))
428
2f9812f9 »
2012-06-24 Creates drafts directory if non existent.
429 (defun hyde/setup-directories (home)
430 "Create expected directories if they don't exist"
431 (let
432 (
433 (drafts-dir (concat home "/" hyde-drafts-dir))
434 )
435 (if (not (file-exists-p drafts-dir))
436 (make-directory drafts-dir t))))
d6fa1a60 »
2011-12-10 Adds interactive prompt for hyde-home and config reader
437
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
438 (defun hyde/hyde-mode (home)
0f8f9c34 » csw
2012-05-13 Show the key bindings in help.
439 "The Hyde major mode to edit Jekyll posts.
440
441 \\{hyde-mode-map}"
7b0e8e48 »
2010-11-10 Got font lock to work right
442 (kill-all-local-variables)
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
443 (dolist (x '(hyde-deploy-dir
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
444 hyde-posts-dir
445 hyde-drafts-dir
446 hyde/jekyll-command
447 hyde/deploy-command
448 hyde/git/remote
449 hyde/git/remote-branch))
450 (make-variable-buffer-local x))
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
451 (set (make-local-variable 'hyde-home) home)
7b0e8e48 »
2010-11-10 Got font lock to work right
452 (use-local-map hyde-mode-map)
453 (set (make-local-variable 'font-lock-defaults) '(hyde-font-lock-keywords))
95841c15 »
2010-11-10 A few mode map entries
454 (setq major-mode 'hyde/hyde-mode
97b9ab53 » csw
2012-05-13 Set default-directory to the Hyde home dir.
455 mode-name "Hyde"
456 default-directory home)
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
457 (hyde/read-config hyde-home)
2f9812f9 »
2012-06-24 Creates drafts directory if non existent.
458 (hyde/setup-directories hyde-home)
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
459 (hyde/load-posts)
460 (hl-line-mode t)
1e95b6f1 »
2013-06-16 Creates image directories at the main entry point.
461 ;; Create directories for images
462 (let ((draft-images-dir (concat hyde-home hyde-drafts-dir "/" hyde-images-dir))
5d9b093f »
2013-06-18 Change location of published asset directory.
463 (posts-images-dir (concat hyde-home "/" hyde-images-dir)))
464 (progn
465 (message (concat "Drafts image dir :"draft-images-dir))
466 (message (concat "Posts image dir :"posts-images-dir))
467 (if (not (file-exists-p draft-images-dir))
468 (make-directory draft-images-dir))
469 (if (not (file-exists-p posts-images-dir))
470 (make-directory posts-images-dir))))
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
471 (run-hooks hyde-mode-hook))
472
95841c15 »
2010-11-10 A few mode map entries
473
474 ;; Entry point
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
475 (defun hyde (home)
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
476 "Enters hyde mode"
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
477 (interactive "DBlog : ")
d6fa1a60 »
2011-12-10 Adds interactive prompt for hyde-home and config reader
478 (let (
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
479 (hyde-buffer (concat "*Hyde : " home "*"))
d6fa1a60 »
2011-12-10 Adds interactive prompt for hyde-home and config reader
480 )
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
481 (switch-to-buffer (get-buffer-create hyde-buffer)))
181f9d2f »
2012-01-21 Made hyde-home buffer local to handle multiple blogs and fixed new bugs
482 (hyde/hyde-mode home))
860c0919 »
2011-12-11 Add support for multiple blogs using a config file in the blog directory
483
caa728d4 »
2010-11-10 Initial version. Some code to load up posts
484 (provide 'hyde)
fe063651 » purcell
2013-12-26 Add missing package description and trailing line
485
486 ;;; hyde.el ends here
Something went wrong with that request. Please try again.