/
org2blog.el
executable file
·3151 lines (2769 loc) · 119 KB
/
org2blog.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; org2blog.el --- Blog from Org mode to WordPress -*- lexical-binding: t; byte-compile-warnings: (not docstrings); -*-
;; Copyright (C) 2008 Ashish Shukla
;; Copyright (C) 2010 Benjamin Beckwith <bnbeckwith@gmail.com>
;; Copyright (C) 2010 Marcel van der Boom <marcel@hsdev.com>
;; Copyright (C) 2010-2014 Puneeth Chaganti <punchagan+org2blog@muse-amuse.in>
;; Copyright (C) 2010 Sacha Chua <sacha@sachachua.com>
;; Copyright (C) 2010 Giovanni Moretti <Giovanni@reflections.co.nz>
;; Copyright (C) 2010 Matt Price <matt@roke.mercey.dyndns.org>
;; Copyright (C) 2011 Mykola Nikishov <mn@mn.com.ua>
;; Copyright (C) 2013 Peter Vasil <mail@petervasil.net>
;; Copyright (C) 2015-2022 Grant Rettke <grant@wisdomandwonder.com>
;; Author: Puneeth Chaganti <punchagan+org2blog@gmail.com>
;; Maintainer: Grant Rettke <grant@wisdomandwonder.com>
;; Version: 1.1.16
;; Package-Requires: ((emacs "27.1") (htmlize "1.56") (hydra "0.15.0") (xml-rpc "1.6.15") (writegood-mode "2.2.0") (metaweblog "1.1.16"))
;; Keywords: comm, convenience, outlines, wp
;; Homepage: https://github.com/org2blog/org2blog
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; A portion of the code in this file is based on blog.el posted to
;; http://www.mail-archive.com/gnu-emacs-sources@gnu.org/msg01576.html
;; copyrighted by Ashish Shukla.
;;;; Code:
;;; System Definition
(defconst org2blog/wp-version "1.1.16"
"Current version of org2blog.el.")
(cl-defstruct
org2blog-pkg
name
version
(version-prefix "")
url)
(cl-defstruct
org2blog-def
name
version
wordpress-version
metaweblog
ox-wp
doc
emacs
emacs-api
org
requirements
keywords
authors
maintainer
homepage)
(defconst org2blog-defi
(make-org2blog-def
:name "org2blog"
:version org2blog/wp-version
:metaweblog org2blog/wp-version
:wordpress-version "6.0"
:ox-wp org2blog/wp-version
:doc "Blog from Org mode to WordPress"
:emacs "28.1"
:emacs-api "27.1"
:org "9.5.2"
:requirements (list
(make-org2blog-pkg
:name "htmlize"
:version "1.56"
:version-prefix "release/"
:url "https://github.com/hniksic/emacs-htmlize.git")
(make-org2blog-pkg
:name "hydra"
:version "0.15.0"
:url "https://github.com/abo-abo/hydra.git")
(make-org2blog-pkg
:name "xml-rpc"
:version "1.6.15"
:url "https://github.com/hexmode/xml-rpc-el.git")
(make-org2blog-pkg
:name "writegood-mode"
:version "2.2.0"
:version-prefix "v"
:url "https://github.com/bnbeckwith/writegood-mode")
(make-org2blog-pkg
:name "metaweblog"
:version org2blog/wp-version
:version-prefix "v"
:url "https://github.com/org2blog/org2blog.git"))
:keywords '("comm" "convenience" "outlines" "wp")
:authors '(("Puneeth Chaganti" . "punchagan+org2blog@gmail.com"))
:maintainer '("Grant Rettke" . "grant@wisdomandwonder.com")
:homepage "https://github.com/org2blog/org2blog"))
(defun org2blog-def-update-artifacts ()
"Update dependent artifacts with version information.
Use data from `org2blog-def--package'.
Before calling this update and evaluate `org2blog-def--package'
with the new release version number.
This function requires that you are calling it while visiting a
file located in the project's top level directory because it
opens all of the files relatively.
It also leaves the file buffers open because you probably want to
inspect the generated code."
(interactive)
(org2blog-def--update-readme)
(org2blog-def--update-org2blog)
(org2blog-def--update-ox-wp)
(org2blog-def--update-metaweblog)
(org2blog-def--update-pkg))
(defmacro org2blog-def--update-the (file &rest body)
"Visit FILE and evaluate BODY."
`(save-excursion
(save-buffer)
(let ((origin (current-buffer)))
(find-file ,file)
(save-excursion
,@body)
(save-buffer)
(unless (eq origin (current-buffer))
(previous-buffer)))))
(defun org2blog-def--update-readme ()
"Update README.org."
(interactive)
(org2blog-def--update-the
"README.org"
(goto-char (point-min))
(re-search-forward "^Current Requirements: Org2Blog")
(kill-whole-line 1)
(insert (format "Current Requirements: Org2Blog %s, Emacs %s, which includes Org mode %s, and WordPress %s.\n"
(org2blog-def-version org2blog-defi)
(org2blog-def-emacs org2blog-defi)
(org2blog-def-org org2blog-defi)
(org2blog-def-wordpress-version org2blog-defi))))
(org2blog-def--update-the
"README.org"
(goto-char (point-min))
(re-search-forward "^Start by installing Emacs Version ")
(kill-whole-line 1)
(insert (format "Start by installing Emacs Version %s.\n"
(org2blog-def-emacs org2blog-defi)))))
(defun org2blog-def--contact-info (contact)
"Create string from CONTACT info."
(let ((result (concat (car contact) " <" (cdr contact) ">")))
result))
(defun org2blog-def--interpose (sep list)
"Return a new list of all elements in LIST separated by SEP."
(let* ((it (mapcar (lambda (x) (list x sep)) list))
(it (apply 'concatenate 'list it))
(it (seq-take it (- (length it) 1))))
it))
(defun org2blog-def--contacts-info (contacts)
"Create string from CONTACTS info."
(let* ((contacts (mapcar
'org2blog-def--contact-info
contacts))
(separated (org2blog-def--interpose ", " contacts))
(all (apply 'concat separated)))
all))
(defun org2blog-def--update-header (file version requirements keywords)
"Update FILE header with VERSION, REQUIREMENTS, and KEYWORDS."
(interactive)
(org2blog-def--update-the
file
(goto-char (point-min))
(re-search-forward "^;; Author: ")
(kill-whole-line 6)
(insert (format ";; Author: %s\n" (org2blog-def--contacts-info
(org2blog-def-authors org2blog-defi))))
(insert (format ";; Maintainer: %s\n" (org2blog-def--contact-info
(org2blog-def-maintainer org2blog-defi))))
(insert (format ";; Version: %s\n" version))
(insert (format ";; Package-Requires: ((emacs \"%s\")"
(org2blog-def-emacs-api org2blog-defi)))
(mapc
(lambda (req)
(let* ((name (org2blog-pkg-name req))
(version (org2blog-pkg-version req))
(str (format " (%s \"%s\")" name version)))
(insert str)))
requirements)
(insert (format ")\n"))
(insert (format ";; Keywords: %s\n"
(apply 'concat (org2blog-def--interpose ", " keywords))))
(insert (format ";; Homepage: %s\n" (org2blog-def-homepage org2blog-defi)))))
(defun org2blog-def--update-org2blog ()
"Update Org2Blog file."
(interactive)
(org2blog-def--update-header
"org2blog.el"
(org2blog-def-version org2blog-defi)
(org2blog-def-requirements org2blog-defi)
(org2blog-def-keywords org2blog-defi)))
(defun org2blog-def--update-pkg ()
"Update package definition."
(interactive)
(org2blog-def--update-the
"org2blog-pkg.el"
(erase-buffer)
(pp
`(define-package ,(org2blog-def-name org2blog-defi) ,(org2blog-def-version org2blog-defi) ,(org2blog-def-doc org2blog-defi)
',(seq-mapcat
(lambda (req)
(list
(list (intern (org2blog-pkg-name req))
(org2blog-pkg-version req)
(org2blog-pkg-url req))))
(org2blog-def-requirements org2blog-defi))
:authors
',(org2blog-def-authors org2blog-defi)
:maintainer
',(org2blog-def-maintainer org2blog-defi)
:keywords
',(org2blog-def-keywords org2blog-defi)
:homepage
,(org2blog-def-homepage org2blog-defi))
(current-buffer))))
(defun org2blog-def--update-ox-wp ()
"Update ox-wp file."
(interactive)
(let ((file "ox-wp.el"))
(org2blog-def--update-header
file
(org2blog-def-version org2blog-defi)
nil
(org2blog-def-keywords org2blog-defi))
(org2blog-def--update-the
file
(goto-char (point-min))
(re-search-forward "(defconst ox-wp-version")
(kill-whole-line 2)
(insert (format "(defconst ox-wp-version \"%s\"\n"
(org2blog-def-ox-wp org2blog-defi)))
(insert (format " \"Current version of ox-wp.el.\")\n")))))
(defun org2blog-def--update-metaweblog ()
"Update metaweblog file."
(interactive)
(let ((file "metaweblog.el"))
(org2blog-def--update-header
file
(org2blog-def-metaweblog org2blog-defi)
nil
'("comm"))
(org2blog-def--update-the
file
(goto-char (point-min))
(re-search-forward "(defconst metaweblog-version")
(kill-whole-line 2)
(insert (format "(defconst metaweblog-version \"%s\"\n"
(org2blog-def-metaweblog org2blog-defi)))
(insert (format " \"Current version of metaweblog.el.\")\n")))))
(defun org2blog-def-checkout-statement ()
"Create Git checkout commands for system code and packages into INSTALL-DIR.
Copy them from the *Messages* buffer into your Terminal."
(interactive)
(let ((install-dir (read-directory-name "Directory:")))
(princ (format "cd %s\n" install-dir))
(mapcar
(lambda (req)
(let* ((name (org2blog-pkg-name req))
(version (org2blog-pkg-version req))
(version-prefix (org2blog-pkg-version-prefix req))
(url (org2blog-pkg-url req)))
(princ (format
"git clone %s %s/%s\n"
url
install-dir
name))
(princ (format "cd %s\n" name))
(princ (format
"git checkout %s%s\n"
version-prefix
version))
(princ (format "cd ..\n" name))))
(org2blog-def-requirements org2blog-defi))))
(defun org2blog-def-load-statement ()
"Create Elisp code to load the libraries."
(interactive)
(let* ((install-dir (read-directory-name "Directory:"))
(install-dir (concat install-dir
(if (string-match "/\\'"
install-dir)
"" "/"))))
(mapcar
(lambda (req)
(let* ((name (org2blog-pkg-name req)))
(princ (format "(add-to-list 'load-path \"%s%s\")\n"
install-dir
name))
(princ (format "(require '%s)\n" name))))
(org2blog-def-requirements org2blog-defi))))
(defun org2blog-estimated-word-count (&optional subtreep)
"Estimate word count using a UTF-8 text export.
Review the export by opening the buffer:
'(switch-to-buffer-other-window \"*Org ASCII Export*\"))'
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
"
(interactive)
(let ((async nil)
(visible-only nil)
(body-only nil)
(ext-plist
'(:ascii-charset utf-8))
(org-export-show-temporary-export-buffer nil)
(export-buffer "*Org ASCII Export*"))
(org-ascii-export-as-ascii
async subtreep visible-only body-only ext-plist)
(with-current-buffer export-buffer
(let ((word-count
(count-words (point-min) (point-max))))
(message "Estimated Word Count: %s" word-count)))
(when (get-buffer export-buffer) (kill-buffer export-buffer))))
;;; Requires
;; Packages - External
(require 'htmlize)
(require 'hydra)
(require 'xml-rpc)
(require 'metaweblog)
(require 'writegood-mode)
;; Packages - Internal
(require 'org)
(require 'ox-wp)
(eval-when-compile (require 'subr-x))
;;; Constants
(defconst org2blog/wp-required-org-version (org2blog-def-org org2blog-defi)
"Minimum variable ‘org-version’ required to run this package.")
(defconst org2blog--minimal-emacs (org2blog-def-emacs org2blog-defi)
"Minimum variable ‘emacs-version’ required to run this package.")
(defconst org2blog--default-blogid "1"
"Default WordPress Blog ID.
Nearly every XML-RPC API call requires the blog id.
What exactly is BLOGID?
There are two ways to run a WordPress site. Number one is a
single “site” with one installation directory and one blog.
Number two is a Multisite “network of sites” mode with one
installation hosting any number of blogs.
When you talk to WordPress over its API you need to tell it
which blog you are talking to. If you are running a “site”
then it will be ID “1”. If you are running a Multisite then
it will be “1” or above.
The most likely case for bloggers is a single “site” setup.
Therefore after you login and Org2Blog can’t find an ‘:id’,
then it defaults to this value: it defaults to “1”.
The blog specific property is: :id
Example: An integer defined by a string.")
(defconst org2blog-metaweblog-app-key
"E8620BB2-C481-4A10-9B55-18D03202EFE5"
"MetaWeblog API Requirement: Created randomly. Never change it.")
(defconst org2blog-deprecation "2.0.0"
"Release in which obsolete objects will be removed.")
;;; Deprecations
(mapc (lambda (ls)
(define-obsolete-function-alias (car ls) (cadr ls) org2blog-deprecation))
'((org2blog/wp-buffer-kill-prompt org2blog-on-new-entry-kill)
(org2blog/wp-complete-category org2blog-complete)
(org2blog/wp-delete-entry org2blog-post-trash)
(org2blog/wp-delete-page org2blog-page-trash)
(org2blog/wp-format-buffer org2blog-entry-buffer-make)
(org2blog/wp-insert-post-or-page-link org2blog-insert-link)
(org2blog/wp-login org2blog-user-login)
(org2blog/wp-logout org2blog-user-logout)
(org2blog/wp-new-entry org2blog-buffer-new)
(org2blog/wp-org-mode-hook-fn org2blog-maybe-start)
(org2blog/wp-password org2blog-user-set-password)
(org2blog/wp-post-buffer org2blog-buffer-post-save)
(org2blog/wp-post-buffer-and-publish org2blog-buffer-post-publish)
(org2blog/wp-post-buffer-as-page org2blog-buffer-page-save)
(org2blog/wp-post-subtree org2blog-subtree-post-save)
(org2blog/wp-post-subtree-and-publish org2blog-subtree-post-publish)
(org2blog/wp-post-subtree-as-page org2blog-subtree-page-save)
(org2blog/wp-post-subtree-as-page-and-publish org2blog-subtree-page-publish)
(org2blog/wp-preview-buffer-post org2blog-buffer-post-or-page-view)
(org2blog/wp-preview-subtree-post org2blog-subtree-post-or-page-view)
(org2blog/wp-reload-entry-mode-map org2blog-reload-entry-mode-map)
(org2blog/wp-track-buffer org2blog-buffer-track)
(org2blog/wp-track-subtree org2blog-subtree-track)))
(mapc (lambda (ls)
(define-obsolete-variable-alias (car ls) (cadr ls) org2blog-deprecation))
'((org2blog/wp-after-new-post-or-page-functions org2blog-buffer-entry-save-hook)
(org2blog/wp-blog org2blog-blog)
(org2blog/wp-blog-name org2blog-blog-key)
(org2blog/wp-buffer-name org2blog-buffer-name)
(org2blog/wp-categories-list org2blog-categories)
(org2blog/wp-entry-mode-map org2blog-mode-map)
(org2blog/wp-export-options org2blog-export-options)
(org2blog/wp-logged-in org2blog-logged-in)
(org2blog/wp-mode-hook org2blog-mode-hook)
(org2blog/wp-pages-list org2blog-pages)
(org2blog/wp-server-blogid org2blog-blogid)
(org2blog/wp-server-pass org2blog-password)
(org2blog/wp-server-userid org2blog-username)
(org2blog/wp-server-xmlrpc-url org2blog-xmlrpc)
(org2blog/wp-tags-list org2blog-tags)))
;;; Variables
(defvar org2blog-blog nil
"Parameters of the currently selected blog.")
(defvar org2blog-blog-key nil
"Name of the blog, to pick from `org2blog/wp-blog-alist'.")
(defvar org2blog-categories nil
"List of weblog categories.")
(defvar org2blog-tags nil
"List of weblog tags.")
(defvar org2blog-pages nil
"List of WP pages.")
(defvar org2blog-xmlrpc nil
"WordPress server XML-RPC URL.
The blog specific property is: :url
Example: \"https://www.wisdomandwonder.com/xmlrpc.php\"")
(defvar org2blog-username nil
"WordPress server user id.
The blog specific property is: :url
Example: \"admin\"")
(defvar org2blog-blogid nil
"WordPress Blog ID.")
(defvar org2blog-mode-map nil
"Keymap for blog entry buffer.")
(defvar org2blog-logged-in nil
"Flag whether user is logged-in or not.")
(defvar org2blog-buffer-name "*Org2Blog (%s): %s*"
"Name of the blog buffer.")
(defvar org2blog-mode-hook nil
"Hook to run upon entry into mode.
Here is an example of creating keybindings:
(defun ahook ()
(local-set-key (kbd \"M-9\") #'org2blog-user-interface)
(local-set-key (kbd \"M-0\") #'org2blog-complete))
(add-hook 'org2blog/wp-mode-hook #'ahook).")
(defvar org2blog-buffer-entry-save-hook nil
"Hooks run after a new post or page save.
Each function is called with one argument, the object
representing the aforementioned post or page.
Here is an example that outputs the entire object to the *Messages* buffer:
(defun ahook (entry)
(pp entry))
(add-hook 'org2blog-buffer-entry-save-hook #'ahook).")
(defvar org2blog-export-options
'(:section-numbers
nil
:with-priority nil
:with-sub-superscript nil
:with-toc nil
:with-tags nil
:with-todo-keywords nil)
"Export options to be used when exporting buffers and subtrees.
Look at `org-export-options-alist' for the available options.
Also, note that these options are over-ridden by in-file
options.")
(defvar org2blog-password nil
"WordPress user password.
The blog specific property is: :password
Example: \"bilbo\"")
(defvar org2blog-step-time 0.2 "Number of seconds to sleep between actions.
Must be greater than or equal to 0.2 seconds.")
;;; Groups
(defgroup org2blog/wp nil
"Blog from Org mode to WordPress"
:group 'org2blog/wp)
;;; Customize
(defcustom org2blog/wp-blog-alist nil
"User blog definitions.
Association list to set information for each blog.
Each element of the alist is a blog name. The CAR of each
element is a string, uniquely identifying the project. The CDR
of each element is a well-formed property list with an even
number of elements, alternating keys and values, specifying
parameters for the blog.
(:property value :property value ... )
When a property is given a value in org2blog/wp-blog-alist, its
setting overrides the value of the corresponding user
variable (if any) during publishing.
:url and :username are required.
All the other properties are optional. They over-ride the global variables.
:group 'org2blog/wp
:type '(alist :value-type plist)
Example:
(\"myblog\"
:url \"https://www.wisdomandwonder.com/xmlrpc.php\"
:username username
:password password
:confirm t)"
:group 'org2blog/wp
:type '(alist))
(defcustom org2blog/wp-default-categories '("Org2Blog" "WordPress")
"Default list of categories for a new buffer entry.
The blog specific property is: :default-categories
Example: '(\"category 1\" \"category 2\")"
:group 'org2blog/wp
:type '(repeat string))
(defcustom org2blog/wp-default-categories-subtree '("Org2Blog" "WordPress")
"Default list of categories for a new subtree entry.
The blog specific property is: :default-categories-sub
Example: See default value."
:group 'org2blog/wp
:type '(repeat string))
(defcustom org2blog/wp-default-tags '("Emacs" "Lisp")
"Default list of tags for a new buffer entry.
The blog specific property is: :default-tags
Example: '(\"tag 1\" \"tag 2\")"
:group 'org2blog/wp
:type '(repeat string))
(defcustom org2blog/wp-default-tags-subtree '("Emacs" "Lisp")
"Default list of tags for a new subtree entry.
The blog specific property is: :default-tags-sub
Example: '(\"tag 1\" \"tag 2\")"
:group 'org2blog/wp
:type '(repeat string))
(defcustom org2blog/wp-buffer-template
"#+ORG2BLOG:
#+DATE: %s
#+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil
#+CATEGORY: %s
#+TAGS: %s
#+DESCRIPTION:
#+TITLE: %s
\n"
"The default template to be inserted in a new buffer entry.
It is passed to ‘format’ with 4 string arguments:
- Today’s date and time
- Your configuration of default buffer entry categories
- Your configuration of default buffer entry tags
- Your configuration of default buffer entry title."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-buffer-template-prefix nil
"A prefix to the default template used for a new post buffer."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-buffer-subtree-template
"#+ORG2BLOG
* %s
:PROPERTIES:
:BLOG: %s
:DATE: %s
:OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil
:CATEGORY: %s
:POST_TAGS: %s
:END:\n\n"
"The default template to be inserted in a new subtree entry.
It is passed to ‘format’ with 5 string arguments:
- Your configuration of default subtree title.
- Your Blog ID.
- Today’s date and time
- Your configuration of default subtree entry categories.
- Your configuration of default subtree entry tags."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-buffer-subtree-template-prefix nil
"A prefix to the default template used for a new subtree entry."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-buffer-format-function 'org2blog-entry-buffer-make
"Function formatting a buffer according to `org2blog/wp-buffer-template'."
:group 'org2blog/wp
:type 'function)
(defcustom org2blog/wp-buffer-subtree-format-function 'org2blog-entry-subtree-make
"Function formatting an entry according to `org2blog/wp-buffer-subtree-template'."
:group 'org2blog/wp
:type 'function)
(defcustom org2blog/wp-default-title "Hello, Buffer"
"Title of a newly generated buffer entry.
The blog specific property is: :default-title
Example: See default value."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-default-title-subtree "Hello, Subtree"
"Title of a newly generated subtree entry.
The blog specific property is: :default-title-sub
Example: See default value"
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-use-tags-as-categories nil
"Non-nil means assign :tags: to WordPress categories instead.
The blog specific property is: :tags-as-categories
Example: A Boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-confirm-post nil
"Non-nil means confirm before Publishing a post or page.
The blog specific property is: :confirm
Example: A Boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-safe-trash t
"Non-nil means confirm before Trashing a post or page.
The blog specific property is: :safe-trash
Example: A Boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-safe-new-entry-buffer-kill t
"Non-nil means confirm before killing a new entry buffer.
The blog specific property is: :safe-new-entry-buf-kill
Example: A Boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-show-post-in-browser 'dont
"How to automatically display an entry after save or publish.
Eventually you will have a lot of examples of how you prefer to
blog. This is your “personal workflow” and this option should
reflect that.
This variable is a symbol with options:
- ask :: Ask you whether to display it or not.
This is useful when your workflow is to make
continuous changes that you just don’t know
whether or not you want to display it each time.
- show :: Show it immediately.
This is useful your workflow is to write your entry
once and basically have it be perfect on the first
try. That way you save it, review it, see that
it looks good, publish it, and you are done.
- dont :: Don’t show it at all.
This is useful when your workflow is to display
your entry once and manually refresh the page
yourself after saving or publishing. If you’ve
blogged before then this is the easiest and least
surprising approach.
The blog specific property is: :show"
:group 'org2blog/wp
:type 'symbol)
(defcustom org2blog/wp-keep-new-lines nil
"Non-nil means do not strip newlines.
When Org mode exports to HTML it removed line endings so
the web page “looks right”. If for some reason you don’t
what that typical behavior set this to program t.
The blog specific property is: :keep-new-lines
Example: A boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-use-sourcecode-shortcode nil
"Non-nil means convert <pre> tags to WP sourcecode blocks.
The blog specific property is: :wp-code"
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-use-wp-latex t
"Non-nil means convert LaTeX to WP LaTeX blocks.
The blog specific property is: :wp-latex
Example: A boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-shortcode-langs-map nil
"Map source language to SyntaxHighlighter Evolved.
Each element of the list maps the Org mode source code
language (key) to the language spec that should be used
for syntax highlighting in shortcode blocks.
Read more about this here:
- SyntaxHighlighter Evolved :
URL ‘https://wordpress.org/plugins/syntaxhighlighter/’
- Org mode source blocks:
URL ‘https://orgmode.org/manual/Working-with-source-code.html’"
:group 'org2blog/wp
:type '(alist :key-type string :value-type string))
(defcustom org2blog/wp-track-posts
(list ".org2blog.org" "Posts")
"Tracking file name location and parent headline.
.org file in which to save logs about posts, and
corresponding headline in file under which the logs should
be added.
The blog specific property is: :track-posts
Example: See default value."
:group 'org2blog/wp
:type '(list string string))
(defcustom org2blog/wp-keymap-prefix
"C-c M-p"
"Mode keymap prefix.
Call `org2blog-reload-entry-mode-map' after making
change for them to takes effect."
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/wp-image-upload nil
"Non-nil means upload supported Org mode image types.
Upload to the WordPress Media Library.
The blog specific property is: :image-upload
Example: A boolean value."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-image-thumbnails nil
"Non-nil means WordPress inserts a thumbnail link to a full-size image."
:group 'org2blog/wp
:type 'boolean)
(defcustom org2blog/wp-image-thumbnail-size "medium_large"
"Default image thumbnail size.
Choices are: thumbnail (150px), medium (300px),
medium_large (768px) or large (1024px)"
:group 'org2blog/wp
:type 'string)
(defcustom org2blog/link-selection-size 100
"Number of most recent entries to present for insertion.
function ‘org2blog-insert-link’ inserts an
Org link for an entry ID. Retrieve the
variable ‘org2blog/link-selection-size' most recent entries
to present to the user for selection.
It is only as useful as quickly it helps the writer.
If you set the value too high it will take too long to
load and interrupt the authors flow. If you set the value
too low then it won’t help for looking things up forcing
them to just open the blog in a browser and search for the
entry.
Since usage style is a personal preference, the default setting
here seemed to be a good balance between speed and value(s)."
:group 'org2blog/wp
:type 'integer)
;;; User Interface
(defun org2blog--hlpf (name)
"Abstracts displaying information about symbol NAME."
(describe-symbol name))
(defun org2blog--hlpv (name)
"Abstracts displaying information about variable NAME."
(describe-variable name))
(defconst org2blog--hydra-letters-main-menu
"
Char : ABCDE FGHIJ KLMNO PQRST UVWXY Z1234 56789 0`-=[ ]\;', ./
None : XoXXX XoXXX XXooX XXXoo XXXoo oXXXX ooooo ooooo ooXoo oo
Shift: ooooo oooXX XXooX Xoooo XXXoo ooooo ooooo ooooo ooXoo oo
"
"Documents Main Menu Shortcut Letters
This is for the top-level main-menu.
Review this before making changes to it―
document this after making them.
Legend:
Columns: Key name and modifier applied
Rows: Key itself
`o': Un-used
`X': Used")
(defhydra org2blog--hydra-main (:color blue :hint nil)
"
╔═^═════════╗
║ ^Org2Blog ║^ (Main Menu) %(org2blog--login-status)^
╠═^═════════╩^═══════╦══════════════^═══^╦════════^════════════^╦═^═══════^═══════════^═╗
║ ^Admin^ ║ ^Use^ ║ ^Buffer^ ║ ^Subtree^ ^ ║
╚═^═════^════════════╩═^═══^═════════════╩═^══════^═════════════╩═^═══════^═══════════^═╝
[_4_] Login [_e_] New Buffer [_j_] Save Post Draft [_u_] Save Post Draft
[_3_] Reporting On [_r_] New Subtree [_k_] View Post [_i_] View Post
[_2_] Reporting Off [_c_] Completion [_l_] Publish Post [_o_] Publish Post
[_1_] Logout [_f_] Trash ID [_;_] Trash Post [_p_] Trash Post
[_a_] About [_d_] Insert A [_J_] Save Page Draft [_U_] Save Page Draft
[_W_] Version [_v_] README [_K_] View Page [_I_] View Page
[_h_] Help [_V_] Variables [_L_] Publish Page [_O_] Publish Page
[_q_] Quit [_w_] Writer Tools [_:_] Trash Page [_P_] Trash Page
"
("4" org2blog-user-login :exit nil)
("3" org2blog-user-report-on :exit nil)
("2" org2blog-user-report-off :exit nil)
("1" org2blog-user-logout :exit nil)
("a" org2blog-about)
("W" org2blog-version-info)
("h" (org2blog--hydra-main-help/body))
("q" nil)
("e" org2blog-buffer-new)
("r" org2blog-subtree-new)
("c" org2blog-complete)
("f" org2blog-entry-trash-prompt)
("d" org2blog--hydra-main-inserts/body)
("v" org2blog-readme)
("V" org2blog--hydra-main-variables/body)
("w" org2blog--hydra-main-writer-tools/body)
("j" org2blog-buffer-post-save)
("k" org2blog-buffer-post-view)
("l" org2blog-buffer-post-publish)
(";" org2blog-buffer-post-trash)
("J" org2blog-buffer-page-save)
("K" org2blog-buffer-page-view)
("L" org2blog-buffer-page-publish)
(":" org2blog-buffer-page-trash)
("u" org2blog-subtree-post-save)
("i" org2blog-subtree-post-view)
("o" org2blog-subtree-post-publish)
("p" org2blog-subtree-post-trash)
("U" org2blog-subtree-page-save)
("I" org2blog-subtree-page-view)
("O" org2blog-subtree-page-publish)
("P" org2blog-subtree-page-trash))
(defhydra org2blog--hydra-main-help (:color blue :hint nil)
"
╔═^═════════╗
║ ^Org2Blog ║^ (Main Menu → Help) Select any item for more detail
╠═^═════════╩^═══════╦══════════════^═══^╦════════^════════════^╦═^═══════^═══════════^═╗
║ ^Admin^ ║ ^Use^ ║ ^Buffer^ ║ ^Subtree^ ^ ║
╚═^═════^════════════╩═^═══^═════════════╩═^══════^═════════════╩═^═══════^═══════════^═╝
[_4_] Login [_e_] New Buffer [_j_] Save Post Draft [_u_] Save Post Draft
[_3_] Reporting On [_r_] New Subtree [_k_] View Post [_i_] View Post
[_2_] Reporting Off [_c_] Completion [_l_] Publish Post [_o_] Publish Post
[_1_] Logout [_f_] Trash ID [_;_] Trash Post [_p_] Trash Post
[_a_] About [_d_] Insert A [_J_] Save Page Draft [_U_] Save Page Draft
[_W_] Version [_v_] README [_K_] View Page [_I_] View Page
^ ^ [_V_] Variables [_L_] Publish Page [_O_] Publish Page
[_q_] Back [_w_] Writer Tools [_:_] Trash Page [_P_] Trash Page
"
("4" (org2blog--hlpf 'org2blog-user-login))
("3" (org2blog--hlpf 'org2blog-user-report-on))
("2" (org2blog--hlpf 'org2blog-user-report-off))
("1" (org2blog--hlpf 'org2blog-user-logout))
("a" (org2blog--hlpf 'org2blog-about))
("W" (org2blog--hlpf 'org2blog-version-info))
("q" org2blog--hydra-main/body)
("e" (org2blog--hlpf 'org2blog-buffer-new))
("r" (org2blog--hlpf 'org2blog-subtree-new))
("c" (org2blog--hlpf 'org2blog-complete))
("f" (org2blog--hlpf 'org2blog-entry-trash-prompt))
("d" (org2blog--hlpf 'org2blog--main-inserts))
("v" (org2blog--hlpf 'org2blog-readme))
("V" (org2blog--hlpf 'org2blog--main-variables))
("w" (org2blog--hlpf 'org2blog--main-writer-tools))
("j" (org2blog--hlpf 'org2blog-buffer-post-save))
("k" (org2blog--hlpf 'org2blog-buffer-post-view))
("l" (org2blog--hlpf 'org2blog-buffer-post-publish))
(";" (org2blog--hlpf 'org2blog-buffer-post-trash))
("J" (org2blog--hlpf 'org2blog-buffer-page-save))
("K" (org2blog--hlpf 'org2blog-buffer-page-view))
("L" (org2blog--hlpf 'org2blog-buffer-page-publish))
(":" (org2blog--hlpf 'org2blog-buffer-page-trash))