mhc 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,8 @@ module Mhc
20
20
  SymbolicExpression.new(date_range: date_range, options:options)
21
21
  when :howm
22
22
  Howm.new(date_range: date_range, options:options)
23
+ when :json
24
+ FullCalendar.new(date_range: date_range, options:options)
23
25
  else
24
26
  raise FormatterNameError.new("Unknown format: #{formatter} (#{formatter.class})")
25
27
  end
@@ -308,5 +310,31 @@ module Mhc
308
310
  end
309
311
  end # class Howm
310
312
 
313
+ class FullCalendar < Base
314
+ require "json"
315
+
316
+ def format_body(context)
317
+ events = []
318
+ @occurrences.each do |oc|
319
+ if oc.categories.map{|c| c.to_s.downcase}.include?('holiday')
320
+ color = "red"
321
+ elsif oc.allday?
322
+ color = "green"
323
+ else
324
+ color = ""
325
+ end
326
+ events << {
327
+ id: oc.record_id,
328
+ allDay: oc.allday?,
329
+ title: oc.subject,
330
+ start: oc.dtstart.iso8601,
331
+ end: oc.dtend.iso8601,
332
+ color: color
333
+ }
334
+ end
335
+ return events.to_json
336
+ end
337
+ end # class FullCalendar
338
+
311
339
  end # module Formatter
312
340
  end # module Mhc
@@ -1,4 +1,4 @@
1
1
  module Mhc
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  PRODID = "-//Quickhack.net//MHC #{Mhc::VERSION}//EN"
4
4
  end
@@ -18,6 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency "thor", ">= 0.19.1"
22
+ spec.add_runtime_dependency "ri_cal", ">= 0.8.8"
23
+ spec.add_runtime_dependency "tzinfo", ">= 1.2.2"
24
+ spec.add_runtime_dependency "tzinfo-data", ">= 1.2015.4"
25
+
21
26
  spec.add_development_dependency "bundler", "~> 1.5"
22
27
  spec.add_development_dependency "rake"
23
28
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,15 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshinari Nomura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: ri_cal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.8
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.8
41
+ - !ruby/object:Gem::Dependency
42
+ name: tzinfo
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: tzinfo-data
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2015.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2015.4
13
69
  - !ruby/object:Gem::Dependency
14
70
  name: bundler
15
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +142,6 @@ files:
86
142
  - emacs/mhc-message.el
87
143
  - emacs/mhc-minibuf.el
88
144
  - emacs/mhc-misc.el
89
- - emacs/mhc-mua.el
90
145
  - emacs/mhc-parse.el
91
146
  - emacs/mhc-process.el
92
147
  - emacs/mhc-ps.el
@@ -1,260 +0,0 @@
1
- ;;; mhc-mua.el --- MUA backend for MHC
2
-
3
- ;; Author: Yoshinari Nomura <nom@quickhack.net>
4
- ;; Created: 2014-09-20
5
-
6
- ;;; Commentary:
7
-
8
- ;; This file is a part of MHC, backend methods for Generic MUA.
9
-
10
- ;;; Code:
11
-
12
- (defconst mhc-mua/summary-filename-regex
13
- ".*\r *\\+\\([^ \t]+\\)[ \t]+\\([^ \t\n]+\\)")
14
-
15
- ;; Setup function:
16
-
17
- (eval-and-compile
18
- (autoload 'rfc2047-decode-region "rfc2047")
19
- (autoload 'rfc2047-decode-string "rfc2047")
20
- ;; (autoload 'eword-encode-string "eword-encode")
21
- ;; (autoload 'rfc2047-encode-message-header "rfc2047")
22
- ;; (autoload 'rfc2047-encode-string "rfc2047")
23
- )
24
-
25
- ;;;###autoload
26
- (defun mhc-mua-setup ()
27
- (require 'mhc)
28
- (setq mhc-mailer-package 'mua)
29
- (mhc-setup)
30
- (add-hook 'mhc-summary-mode-hook 'mhc-mode))
31
-
32
- ;;; Backend methods:
33
-
34
- ;;; for mhc-summary
35
-
36
- (defun mhc-mua-summary-filename ()
37
- (let (folder number)
38
- (save-excursion
39
- (beginning-of-line)
40
- (if (not (looking-at mhc-mua/summary-filename-regex))
41
- ()
42
- (buffer-substring (match-beginning 2) (match-end 2))))))
43
-
44
- (defun mhc-mua-summary-display-article ()
45
- "Display the current article pointed in summary."
46
- (let ((file (mhc-mua-summary-filename)))
47
- (if (not (and (stringp file) (file-exists-p file)))
48
- (message "File does not exist.")
49
- (mhc-window-push)
50
- ;; (view-file-other-window file)
51
- (pop-to-buffer (get-buffer-create "*MHC message*"))
52
- ;; eword decode
53
- (let ((buffer-read-only nil))
54
- (goto-char (point-min))
55
- (erase-buffer)
56
- (insert-file-contents file)
57
- (mhc-header-narrowing
58
- (mhc-header-delete-header
59
- "^\\(Content-.*\\|Mime-Version\\|User-Agent\\):" 'regexp))
60
- (mhc-header-delete-empty-header
61
- "^X-SC-.*:" 'regexp)
62
- (mhc-message-mode)
63
- (mhc-message-set-file-name file))
64
- ;; (setq view-exit-action 'mhc-calendar-view-exit-action)
65
- (set-visited-file-name nil)
66
- ;; (rename-buffer (file-name-nondirectory file) 'unique)
67
- ;; (run-hooks 'mhc-calendar-view-file-hook)
68
- (set-buffer-modified-p nil)
69
- (setq buffer-read-only t)
70
- )))
71
-
72
- (defun mhc-mua-get-import-buffer (&optional get-raw)
73
- "Return a buffer visiting import article.
74
- If GET-RAW is non-nil, return a cons of buffer: car keeps a raw
75
- message and cdr keeps a visible message."
76
- (let ((buffer
77
- (or
78
- (save-window-excursion
79
- (let ((mode (progn (other-window 1) major-mode)))
80
- (if (or
81
- (eq mode 'mew-message-mode)
82
- (eq mode 'mhc-message-mode))
83
- (current-buffer))))
84
- (current-buffer))))
85
- ;; XXX get-raw is gone soon
86
- (if get-raw
87
- (cons buffer buffer)
88
- buffer)))
89
-
90
- (defun mhc-mua-generate-summary-buffer (name-or-date)
91
- "Generate a summary buffer for DATE-OR-DATE, and change current buffer to it."
92
- (switch-to-buffer
93
- (set-buffer
94
- (mhc-get-buffer-create
95
- (if (stringp name-or-date)
96
- name-or-date
97
- (mhc-date-format name-or-date "%04d-%02d" yy mm)))))
98
- (setq inhibit-read-only t
99
- buffer-read-only nil
100
- selective-display t
101
- selective-display-ellipses nil
102
- indent-tabs-mode nil)
103
- (widen)
104
- (delete-region (point-min) (point-max)))
105
-
106
- (defun mhc-mua/schedule-foldermsg (schedule)
107
- (concat "\r +MHC " (mhc-record-name (mhc-schedule-record schedule))))
108
-
109
- (defun mhc-mua-insert-summary-contents (inserter)
110
- (funcall inserter)
111
- (insert (mhc-mua/schedule-foldermsg mhc-tmp-schedule) "\n"))
112
-
113
- (defun mhc-mua-summary-mode-setup (date)
114
- (mhc-summary-mode))
115
-
116
-
117
- (defvar mhc-message-eof-marker-face 'mhc-message-eof-marker-face)
118
- (defvar mhc-message-subject-face 'mhc-message-subject-face)
119
-
120
- (defface mhc-message-eof-marker-face
121
- '((((class color)
122
- (background dark))
123
- (:background "aquamarine2"))
124
- (((class color)
125
- (background light))
126
- (:background "aquamarine2"))
127
- (t
128
- ()))
129
- "*Face used by mhc-message-eof-marker."
130
- :group 'mhc-faces)
131
-
132
- (defface mhc-message-subject-face
133
- '((((class color)
134
- (background dark))
135
- (:foreground "OrangeRed" :bold t))
136
- (((class color)
137
- (background light))
138
- (:foreground "Firebrick" :bold t))
139
- (t
140
- ()))
141
- "*Face used by mhc-message-subject."
142
- :group 'mhc-faces)
143
-
144
- (defvar mhc-message-font-lock-keywords
145
- '(("\\([12][0-9][0-9][0-9]\\)\\([0-1][0-9]\\)\\([0-3][0-9]\\)"
146
- (1 font-lock-type-face)
147
- (2 font-lock-comment-face)
148
- (3 font-lock-builtin-face))
149
- ("\\(X-SC-\\(Subject\\|Location\\|Day\\|Time\\|Category\\|Priority\\|Recurrence-Tag\\|Mission-Tag:\\|Cond\\|Duration\\|Alarm\\|Record-Id\\|Sequence\\):\\)"
150
- (1 font-lock-keyword-face))
151
- ("\\(\\[End of message\\]\\)"
152
- (1 mhc-message-eof-marker-face))
153
- ("\\(X-SC-Subject:\\) *\\(.*\\)"
154
- (1 font-lock-keyword-face)
155
- (2 mhc-message-subject-face))
156
- ))
157
-
158
- (defun mhc-mua-highlight-message (&optional for-draft)
159
- "Hilight message in the current buffer.
160
- If FOR-DRAFT is non-nil, Hilight message as draft message."
161
- (set (make-local-variable 'font-lock-defaults)
162
- '(mhc-message-font-lock-keywords t)))
163
-
164
- (defalias 'mhc-mua-eword-decode-string 'rfc2047-decode-string)
165
-
166
- (defun mhc-mua-decode-header ()
167
- (save-restriction
168
- (mhc-header-narrowing
169
- (rfc2047-decode-region (point-min) (point-max)))))
170
-
171
- ;;; for mhc-draft
172
-
173
- (defun mhc-mua-draft-setup-new ()
174
- (insert mail-header-separator "\n"))
175
-
176
- (defun mhc-mua-draft-reedit-buffer (buffer original)
177
- ;; If current buffer is specified as buffer, no need to replace.
178
- (unless (eq (current-buffer) buffer)
179
- (erase-buffer)
180
- (insert-buffer-substring buffer))
181
- (mhc-header-narrowing
182
- (mhc-header-delete-header
183
- "^\\(Content-.*\\|Mime-Version\\|User-Agent\\):" 'regexp)
184
- (rfc2047-decode-region (point-min) (point-max)))
185
- (goto-char (point-min))
186
- (when (re-search-forward "^\r?$" nil t)
187
- (insert mail-header-separator)))
188
-
189
- (defun mhc-mua-draft-reedit-file (file)
190
- (erase-buffer)
191
- (insert-file-contents file)
192
- (mhc-mua-draft-reedit-buffer (current-buffer) 'original))
193
-
194
- (defun mhc-mua-draft-translate ()
195
- "Convert an article in the current buffer to an ENCODED one.
196
- ENCODED article should be valid for storeing to a mhc file.
197
- This function can be empty for the current mhc, whereas
198
- the old mhc was supposed to encode the article into MIME message."
199
- (save-excursion
200
- (goto-char (point-min))
201
- (when (search-forward (concat "\n" mail-header-separator "\n") nil t)
202
- (replace-match "\n\n"))))
203
-
204
- ;;; for mhc-calendar
205
-
206
- (defun mhc-mua-goto-message (&optional view)
207
- "Go to a view position on summary buffer."
208
- (when view
209
- (mhc-summary-display)))
210
-
211
- (provide 'mhc-mua)
212
- (put 'mhc-mua 'summary-filename 'mhc-mua-summary-filename)
213
- (put 'mhc-mua 'summary-display-article 'mhc-mua-summary-display-article)
214
- (put 'mhc-mua 'get-import-buffer 'mhc-mua-get-import-buffer)
215
- (put 'mhc-mua 'highlight-message 'mhc-mua-highlight-message)
216
- (put 'mhc-mua 'draft-mode 'mhc-mua-draft-mode)
217
- (put 'mhc-mua 'generate-summary-buffer 'mhc-mua-generate-summary-buffer)
218
- (put 'mhc-mua 'insert-summary-contents 'mhc-mua-insert-summary-contents)
219
- (put 'mhc-mua 'summary-search-date 'mhc-mua-summary-search-date)
220
- (put 'mhc-mua 'summary-mode-setup 'mhc-mua-summary-mode-setup)
221
- (put 'mhc-mua 'draft-setup-new 'mhc-mua-draft-setup-new)
222
- (put 'mhc-mua 'draft-reedit-buffer 'mhc-mua-draft-reedit-buffer)
223
- (put 'mhc-mua 'draft-reedit-file 'mhc-mua-draft-reedit-file)
224
- (put 'mhc-mua 'draft-translate 'mhc-mua-draft-translate)
225
- (put 'mhc-mua 'eword-decode-string 'mhc-mua-eword-decode-string)
226
- (put 'mhc-mua 'decode-header 'mhc-mua-decode-header)
227
- (put 'mhc-mua 'goto-message 'mhc-mua-goto-message)
228
-
229
- ;;; Copyright Notice:
230
-
231
- ;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
232
- ;; Copyright (C) 2000 MHC developing team. All rights reserved.
233
-
234
- ;; Redistribution and use in source and binary forms, with or without
235
- ;; modification, are permitted provided that the following conditions
236
- ;; are met:
237
- ;;
238
- ;; 1. Redistributions of source code must retain the above copyright
239
- ;; notice, this list of conditions and the following disclaimer.
240
- ;; 2. Redistributions in binary form must reproduce the above copyright
241
- ;; notice, this list of conditions and the following disclaimer in the
242
- ;; documentation and/or other materials provided with the distribution.
243
- ;; 3. Neither the name of the team nor the names of its contributors
244
- ;; may be used to endorse or promote products derived from this software
245
- ;; without specific prior written permission.
246
- ;;
247
- ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
248
- ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
249
- ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
250
- ;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
251
- ;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
252
- ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
253
- ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
254
- ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
255
- ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
256
- ;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
257
- ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
258
- ;; OF THE POSSIBILITY OF SUCH DAMAGE.
259
-
260
- ;;; mhc-mua.el ends here