-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite-publish.html
821 lines (742 loc) · 49.1 KB
/
website-publish.html
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
<!DOCTYPE html>
<html lang="pt_BR">
<head>
<!-- 2024-04-08 seg 21:12 -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Geracao estatica website com emacs org-mode</title>
<meta name="author" content="Ildenir Barbosa" />
<meta name="description" content="Como este site eh gerado estaticamente com emacs." />
<meta name="generator" content="Org Mode" />
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
<!-- -*- org -*- -->
<link rel="stylesheet" href="/css/xtreme-simple.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Roboto font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
</head>
<body>
<div id="preamble" class="status">
<header>
<nav id="mySidenav" class="sidenav">
<ul class="menu-principal">
<li><a href="http://github.com/ildenir">
<span class="fa fa-github"></span></a></li>
<li><a href="https://bitbucket.org/UilCoder">
<span class="fa fa-bitbucket"></span></a></li>
<li><a href="/index.html"> Home </a></li>
<li> <a href="/articles.html"> Artigos </a></li>
<li> <a href="/books.html"> Resenhas </a></li>
<li><a href="/about.html"> Sobre </a></li>
</ul>
</nav>
</header>
</div>
<div id="content" class="content">
<h1 class="title">Geracao estatica website com emacs org-mode</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Índice</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org09d6e41">Overview</a></li>
<li><a href="#orgc6bd0b7">Variaveis utilitarias</a></li>
<li><a href="#org04a6526">Header e footer do site</a></li>
<li><a href="#orgd83b8f9">Conteudo dinamico</a></li>
<li><a href="#orgd6d79c4">Componentes do projeto</a></li>
<li><a href="#org3363886">Suporte ao fluxo de trabalho</a>
<ul>
<li><a href="#org78b2aab">Producao de conteudo</a></li>
</ul>
</li>
<li><a href="#orgdf6f06c">Exporta pacote website-publish</a></li>
<li><a href="#orgb756832">Codigos</a></li>
<li><a href="#orgf8400c5">Referencia</a></li>
</ul>
</div>
</div>
<div id="outline-container-org09d6e41" class="outline-2">
<h2 id="org09d6e41">Overview</h2>
<div class="outline-text-2" id="text-org09d6e41">
<p>
Este documento descreve o processo de geracao estatica do site baseado no
modulo org-mode do emacs.
</p>
<p>
O script emacs-lisp para configurar projeto do org-mode pode ser gerado
processando este documento com
org-mode babel. Basta executar o script
seguinte com o comando <code>C-c C-c</code> com o cursor sobre o bloco.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(org-babel-tangle)
(load-file (concat (file-name-base) <span style="color: #95e454;">".el"</span>))
</pre>
</div>
<p>
O objetivo site eh ser simples e com pouco conteudo
dinamico. Basicamente um conjunto de paginas de artigos e breve biografia.
</p>
<p>
O projeto do site segue a estrutura de diretorios como mostrado
abaixo. O diretorio <code>org</code> corresponde aos arquivos fontes de paginas
escritas em org-mode, estilos em css e etc. Os arquivos gerados ao
publicar o site eh escrito no diretorio raiz do projeto sendo o
conteudo eh resultado da compilacao dos arquivos fonte, e portanto,
totalmente descartável.
</p>
<pre class="example" id="org8509577">
.
├── about.org
├── articles
├── articles.org
├── books.org
├── css
├── font-awesome-4.7.0
├── index.org
├── js
├── site-map.org
├── todo.org
├── website-publish.el
├── website-publish.org
└── website-publish.sh
</pre>
</div>
</div>
<div id="outline-container-orgc6bd0b7" class="outline-2">
<h2 id="orgc6bd0b7">Variaveis utilitarias</h2>
<div class="outline-text-2" id="text-orgc6bd0b7">
<p>
Essas variaveis definem a localizacao dos diretorios do projeto.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orga305d23">(<span style="color: #8ac6f2; font-weight: bold;">defcustom</span> <span style="color: #cae682;">website-project-dir</span>
(expand-file-name
(file-name-as-directory <span style="color: #95e454;">"~/ProjectsGitHub/ildenir.github.com/"</span>))
<span style="color: #95e454;">"Diretorio do projeto do website."</span>
<span style="color: #e5786d;">:type</span> 'directory)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">publish-dir</span> ()
<span style="color: #95e454;">"Diretorio onde sera publicado o website."</span>
website-project-dir)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">src-dir</span> ()
<span style="color: #95e454;">"Diretorio dos arquivos fonte org, imagens, css e ..."</span>
website-project-dir)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">src-articles-dir</span> ()
<span style="color: #95e454;">"Diretorio fonte dos artigos."</span>
(concat (file-name-as-directory (src-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>)))
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">publish-articles-dir</span> ()
<span style="color: #95e454;">"Diretorio do artigos publicados."</span>
(concat (file-name-as-directory (publish-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>)))
</pre>
</div>
</div>
</div>
<div id="outline-container-org04a6526" class="outline-2">
<h2 id="org04a6526">Header e footer do site</h2>
<div class="outline-text-2" id="text-org04a6526">
<p>
Toda pagina possui uma barra de navegacao e um rodape com referencia
ao emacs como gerenciador de conteudo, data da ultima atualizacao.
</p>
<p>
O conteudo do preambulo e <b>head</b> do html foram definidos em
variaveis separadas para simplificar definicao dos componentes do projeto.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orgc216050"> (<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-load-file</span> (filename)
<span style="color: #95e454;">"Carrega arquivo apartir de FILENAME e retorna string com conteudo."</span>
(<span style="color: #8ac6f2; font-weight: bold;">with-temp-buffer</span> (insert-file-contents filename)
(buffer-substring (point-min) (point-max))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-preamble-loader</span> (val)
(website-load-file (concat (file-name-as-directory (src-dir)) <span style="color: #95e454;">"preamble.html"</span>)))
(<span style="color: #8ac6f2; font-weight: bold;">defvar</span> <span style="color: #cae682;">website-html-preamble</span> 'website-preamble-loader
<span style="color: #95e454;">"Cabecalho inserido em toda pagina."</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd83b8f9" class="outline-2">
<h2 id="orgd83b8f9">Conteudo dinamico</h2>
<div class="outline-text-2" id="text-orgd83b8f9">
<p>
O conteudo da pagina <b>artigos</b> eh gerado dinamicamente com base nos
dados dos outro artigos publicados. A tecnica usada eh equivalente
a descrita em [jgkamat]. A ideia consiste em criar o arquivo
<code>articles.org</code> com um <b>source block</b> elisp dinamico. O source block
dinamico executa o script lisp contido e substitui o bloco pelo
resultado do script. O processo de publicacao segue normalmente
como os outros arquivos <code>org</code>. No caso do artigo, o script elisp
executado serah a funcao <code>website-generate-article-list</code>, que
produzirah uma lista <code>plist</code> com titulo, primeiro paragrafo como breve descricao,
link para primeira imagem se existir e data de publicacao.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org96a78af">(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">org-element</span>)
(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">cl-lib</span>)
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extrack-kv</span> (ast)
<span style="color: #95e454;">"Rotina interna para extrair (key value) da AST."</span>
(org-element-map ast 'keyword
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span>(key) (list
(org-element-property <span style="color: #e5786d;">:key</span> key)
(org-element-property <span style="color: #e5786d;">:value</span> key)) )))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extract-link</span> (ast)
<span style="color: #95e454;">"Rotina interna para extrair link para image da AST."</span>
(org-element-map ast 'link
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span>(lk) (<span style="color: #8ac6f2; font-weight: bold;">when</span> (string= (org-element-property <span style="color: #e5786d;">:type</span> lk) <span style="color: #95e454;">"fuzzy"</span>)
lk))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-filter-kv</span> (kws filterregexp)
<span style="color: #95e454;">"Filtra lista KWS com key match padrao FILTERREGEXP."</span>
(cl-remove-if-not (<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (el) (string-match filterregexp (car el))) kws))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-extract-article-data</span> (filename)
<span style="color: #95e454;">"Extrai dados do artigo com nome FILENAME.</span>
<span style="color: #95e454;">Retorna plist keys title image description date"</span>
(<span style="color: #8ac6f2; font-weight: bold;">with-temp-buffer</span>
(insert-file-contents filename)
(org-mode)
(<span style="color: #8ac6f2; font-weight: bold;">let*</span> ((filterregex <span style="color: #95e454;">"</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">(</span><span style="color: #95e454;">TITLE</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">DATE</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">DESCRIPTION</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">EMAIL</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">KEYWORDS</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">AUTHOR</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">)</span><span style="color: #95e454;">"</span>)
(ast (org-element-parse-buffer))
(kv (website--extrack-kv ast))
(link (website--extract-link ast))
(kv-filtered (website-filter-kv kv filterregex))
kv-plist)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kv-plist
(plist-put kv-plist
'image (org-element-interpret-data (car link))))
(<span style="color: #8ac6f2; font-weight: bold;">dolist</span> (k kv-filtered kv-plist)
(message (car k))
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kv-plist
(plist-put kv-plist
(intern (downcase (car k))) (car (cdr k))))))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-generate-article</span> ()
<span style="color: #95e454;">"Gera lista com dados de artigos do projeto.</span>
<span style="color: #95e454;">A lista retornada possui o formato</span>
<span style="color: #95e454;">'(filename (title desc link-img pub-date)) onde link-img pode ser nil caso nao</span>
<span style="color: #95e454;">exista. Description vai ser extraida de #+DESCRIPTION:"</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((files (directory-files-recursively (src-dir) <span style="color: #95e454;">"</span><span style="color: #ccaa8f;">\</span><span style="color: #95e454;">.org$"</span>)))
(mapcar (<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (fn) (list fn (website-extract-article-data fn)))
files)))
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd6d79c4" class="outline-2">
<h2 id="orgd6d79c4">Componentes do projeto</h2>
<div class="outline-text-2" id="text-orgd6d79c4">
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org3b8ac3f">(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">ox-publish</span>)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> org-publish-project-alist
`(
(<span style="color: #95e454;">"org-notes"</span>
<span style="color: #e5786d;">:base-directory</span> ,(src-dir)
<span style="color: #e5786d;">:base-extension</span> <span style="color: #95e454;">"org"</span>
<span style="color: #e5786d;">:publishing-directory</span> ,(publish-dir)
<span style="color: #e5786d;">:recursive</span> t
<span style="color: #e5786d;">:publishing-function</span> org-html-publish-to-html
<span style="color: #e5786d;">:headline-levels</span> 4 <span style="color: #99968b;">; </span><span style="color: #99968b;">Just the default for this project.</span>
<span style="color: #e5786d;">:auto-preamble</span> t
<span style="color: #e5786d;">:org-html-doctype</span> html5
<span style="color: #e5786d;">:html-doctype</span> <span style="color: #95e454;">"html5"</span>
<span style="color: #e5786d;">:org-html-html5-fancy</span> t
<span style="color: #e5786d;">:exclude</span> <span style="color: #95e454;">".*--ig--.*"</span>
<span style="color: #e5786d;">:html-preamble</span> ,website-html-preamble
<span style="color: #e5786d;">:html-postamble-format</span> <span style="color: #95e454;">""</span>
<span style="color: #e5786d;">:auto-sitemap</span> t
<span style="color: #e5786d;">:sitemap-title</span> <span style="color: #95e454;">"Site map"</span>
<span style="color: #e5786d;">:sitemap-filename</span> <span style="color: #95e454;">"site-map.org"</span>
)
(<span style="color: #95e454;">"org-static"</span>
<span style="color: #e5786d;">:base-directory</span> ,(src-dir)
<span style="color: #e5786d;">:base-extension</span> <span style="color: #95e454;">"css</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">js</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">png</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">jpg</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">gif</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">pdf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">mp3</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">ogg</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">swf|otf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">woff</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">woff2</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">ttf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">svg"</span>
<span style="color: #e5786d;">:publishing-directory</span> ,(publish-dir)
<span style="color: #e5786d;">:recursive</span> t
<span style="color: #e5786d;">:publishing-function</span> org-publish-attachment
)
(<span style="color: #95e454;">"org"</span> <span style="color: #e5786d;">:components</span> (<span style="color: #95e454;">"org-notes"</span> <span style="color: #95e454;">"org-static"</span>))))
</pre>
</div>
</div>
</div>
<div id="outline-container-org3363886" class="outline-2">
<h2 id="org3363886">Suporte ao fluxo de trabalho</h2>
<div class="outline-text-2" id="text-org3363886">
<p>
O fluxo de trabalho consiste em criar/editar os arquivos <code>org</code>,
<code>css</code>, <code>js</code> e etc com conteudo que pertencera ao site. Ao terminar
todas as edicoes, basta gerar o site com o comando
<code>org-publish</code> para publicar um projeto especifio ou
<code>org-publish-all</code> para publicar todos os projetos. Essa opcoes
tambem estao acessiveis pela combinacao de teclas <code>C-c C-e P x</code> ou
<code>C-c C-e P a</code>, respectivamente.
</p>
<p>
Ocasionamente, pode-se publicar o website via comando shell
<code>website-publish.sh</code>.
</p>
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #99968b;">#</span><span style="color: #99968b;">!/bin/</span><span style="color: #8ac6f2; font-weight: bold;">bash</span>
emacs --batch -l ./website-publish.el <span style="color: #95e454;">\</span>
--eval=<span style="color: #95e454;">"(require 'website-publish)"</span><span style="color: #95e454;">\</span>
--eval=<span style="color: #95e454;">"(org-publish-all)"</span>
</pre>
</div>
<p>
Os comando utilizados para publicar o site soh funcionara quando
o arquivo <code>website-publish.el</code> for carregado. No inicio deste
documento, tem uma instruncao para carregar. Mas sempre sera
necessario abrir este documento e executar as intrucoes. Para
evitar esse trabalho extra, coloque as seguinte intrucao no seu
arquivo <code>.emacs</code>:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(add-to-list 'load-path
(expand-file-name <span style="color: #95e454;">"~/ProjectsGitHub/ildenir.github.com/org"</span>))
(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">website-publish</span>)
</pre>
</div>
<p>
O fluxo tambem suporta a escrita de rascunho. O rascunho consistem
em um artigo quem nao sera publicado com as instrucoes acima. Para
criar um rascunho, basta inserir um <code>- (menos)</code> no inicio do nome
do arquivo, como <code>-Meu Artigo.org</code>.
</p>
</div>
<div id="outline-container-org78b2aab" class="outline-3">
<h3 id="org78b2aab">Producao de conteudo</h3>
<div class="outline-text-3" id="text-org78b2aab">
<p>
A estrutura basica de um artigo pode ser composto rapidamente com o
comando <code>website-new-article</code>. O comando pergunta por informacoes
como o titulo, descricao, palavra-chave e ao final do processo gera
o artigo na estrutura de diretorios do projeto.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="orga3ecdaa">
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extract-kw</span> (kw)
<span style="color: #95e454;">"Auxiliar cria funcao que extrai lista de KW de todos os artigos."</span>
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (data)
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((pl (car (cdr data))) )
(plist-get pl kw))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--list-all</span> (keyword)
<span style="color: #95e454;">"Extrai lista de keyword de todos os arquivos"</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((articles (website-generate-article)))
(remove nil (mapcar (website--extract-kw keyword) articles))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--keyword-list</span> ()
<span style="color: #95e454;">"Lista de todas opcoes KEYWORD dos artigos."</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((articles-kw (website--list-all 'keywords))
(split-string-default-separators <span style="color: #95e454;">"[ \f\t\n\r\v,]+"</span>)
(kw-list (list)))
(<span style="color: #8ac6f2; font-weight: bold;">dolist</span> (l articles-kw kw-list)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kw-list (append kw-list (split-string l))))
(remove <span style="color: #95e454;">"nil"</span> (delete-dups kw-list))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-new-article</span> ()
<span style="color: #95e454;">"Entrevista usuario e insera conteudo ao projeto"</span>
(<span style="color: #8ac6f2; font-weight: bold;">interactive</span>)
(<span style="color: #8ac6f2; font-weight: bold;">let*</span> ((title (read-string <span style="color: #95e454;">"Title: "</span> ))
(description (read-string <span style="color: #95e454;">"Descricao: "</span>))
(author (completing-read <span style="color: #95e454;">"Autor: "</span> (website--list-all 'author)))
(date (format-time-string <span style="color: #95e454;">"%d/%m/%Y"</span>))
(email (completing-read <span style="color: #95e454;">"Email: "</span> (website--list-all 'email)))
(keywords (completing-read-multiple <span style="color: #95e454;">"Palavras-chave: "</span>
(website--keyword-list)))
(filename (string-join
(list (concat (file-name-as-directory (src-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>))
(format-time-string <span style="color: #95e454;">"%Y%m%d"</span>) <span style="color: #95e454;">"-"</span>
(string-join (split-string title) <span style="color: #95e454;">"_"</span>) <span style="color: #95e454;">".org"</span>))))
(<span style="color: #8ac6f2; font-weight: bold;">with-current-buffer</span> (get-buffer-create filename)
(insert <span style="color: #95e454;">"#+SETUPFILE: ../setup/xtreme-simple-theme\n"</span>)
(insert (format <span style="color: #95e454;">"#+TITLE: %s\n"</span> title))
(insert (format <span style="color: #95e454;">"#+DATE: %s\n"</span> date))
(insert (format <span style="color: #95e454;">"#+AUTHOR: %s\n"</span> author))
(insert (format <span style="color: #95e454;">"#+EMAIL: %s\n"</span> email))
(insert (format <span style="color: #95e454;">"#+DESCRIPTION: %s\n"</span> description))
(insert (format <span style="color: #95e454;">"#+KEYWORDS: %s\n"</span> keywords))
(insert <span style="color: #95e454;">"#+LANGUAGE: pt_BR\n"</span>)
(insert <span style="color: #95e454;">"#+OPTIONS: num:nil\n"</span>)
(write-file filename))))
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgdf6f06c" class="outline-2">
<h2 id="orgdf6f06c">Exporta pacote website-publish</h2>
<div class="outline-text-2" id="text-orgdf6f06c">
<p>
Agora o script serah finalizado com a exportacao do pacote para emacs.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="org7468bde">(<span style="color: #8ac6f2; font-weight: bold;">provide</span> '<span style="color: #e5786d;">website-publish</span>)
<span style="color: #99968b;">;;; </span><span style="color: #99968b;">website-publish.el ends here</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb756832" class="outline-2">
<h2 id="orgb756832">Codigos</h2>
<div class="outline-text-2" id="text-orgb756832">
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: #99968b;">;;; </span><span style="color: #99968b;">website-publish.el --- Configuracao publicar site com org-mode -*- lexical-binding:t -*-</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">Copyright (C) 2017 Ildenir Barbosa</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">Author: I. C. Barbosa <a href="mailto:ildenir+github%40googlemail.com"><[email protected]></a></span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">Version: 0.0</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">Keywords: website</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">URL: http://github.com/ildenir/ildenir.github.com</span>
<span style="color: #99968b;">;;; </span><span style="color: #99968b;">Commentary:</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">Este pacote configura/customiza o exportador do org-mode para gerar</span>
<span style="color: #99968b;">;; </span><span style="color: #99968b;">o website.</span>
<span style="color: #99968b;">;;; </span><span style="color: #99968b;">Code:</span>
(<span style="color: #8ac6f2; font-weight: bold;">defcustom</span> <span style="color: #cae682;">website-project-dir</span>
(expand-file-name
(file-name-as-directory <span style="color: #95e454;">"~/ProjectsGitHub/ildenir.github.com/"</span>))
<span style="color: #95e454;">"Diretorio do projeto do website."</span>
<span style="color: #e5786d;">:type</span> 'directory)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">publish-dir</span> ()
<span style="color: #95e454;">"Diretorio onde sera publicado o website."</span>
website-project-dir)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">src-dir</span> ()
<span style="color: #95e454;">"Diretorio dos arquivos fonte org, imagens, css e ..."</span>
website-project-dir)
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">src-articles-dir</span> ()
<span style="color: #95e454;">"Diretorio fonte dos artigos."</span>
(concat (file-name-as-directory (src-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>)))
(<span style="color: #8ac6f2; font-weight: bold;">defsubst</span> <span style="color: #cae682;">publish-articles-dir</span> ()
<span style="color: #95e454;">"Diretorio do artigos publicados."</span>
(concat (file-name-as-directory (publish-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>)))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-load-file</span> (filename)
<span style="color: #95e454;">"Carrega arquivo apartir de FILENAME e retorna string com conteudo."</span>
(<span style="color: #8ac6f2; font-weight: bold;">with-temp-buffer</span> (insert-file-contents filename)
(buffer-substring (point-min) (point-max))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-preamble-loader</span> (val)
(website-load-file (concat (file-name-as-directory (src-dir)) <span style="color: #95e454;">"preamble.html"</span>)))
(<span style="color: #8ac6f2; font-weight: bold;">defvar</span> <span style="color: #cae682;">website-html-preamble</span> 'website-preamble-loader
<span style="color: #95e454;">"Cabecalho inserido em toda pagina."</span>)
(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">org-element</span>)
(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">cl-lib</span>)
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extrack-kv</span> (ast)
<span style="color: #95e454;">"Rotina interna para extrair (key value) da AST."</span>
(org-element-map ast 'keyword
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span>(key) (list
(org-element-property <span style="color: #e5786d;">:key</span> key)
(org-element-property <span style="color: #e5786d;">:value</span> key)) )))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extract-link</span> (ast)
<span style="color: #95e454;">"Rotina interna para extrair link para image da AST."</span>
(org-element-map ast 'link
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span>(lk) (<span style="color: #8ac6f2; font-weight: bold;">when</span> (string= (org-element-property <span style="color: #e5786d;">:type</span> lk) <span style="color: #95e454;">"fuzzy"</span>)
lk))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-filter-kv</span> (kws filterregexp)
<span style="color: #95e454;">"Filtra lista KWS com key match padrao FILTERREGEXP."</span>
(cl-remove-if-not (<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (el) (string-match filterregexp (car el))) kws))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-extract-article-data</span> (filename)
<span style="color: #95e454;">"Extrai dados do artigo com nome FILENAME.</span>
<span style="color: #95e454;">Retorna plist keys title image description date"</span>
(<span style="color: #8ac6f2; font-weight: bold;">with-temp-buffer</span>
(insert-file-contents filename)
(org-mode)
(<span style="color: #8ac6f2; font-weight: bold;">let*</span> ((filterregex <span style="color: #95e454;">"</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">(</span><span style="color: #95e454;">TITLE</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">DATE</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">DESCRIPTION</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">EMAIL</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">KEYWORDS</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">AUTHOR</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">)</span><span style="color: #95e454;">"</span>)
(ast (org-element-parse-buffer))
(kv (website--extrack-kv ast))
(link (website--extract-link ast))
(kv-filtered (website-filter-kv kv filterregex))
kv-plist)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kv-plist
(plist-put kv-plist
'image (org-element-interpret-data (car link))))
(<span style="color: #8ac6f2; font-weight: bold;">dolist</span> (k kv-filtered kv-plist)
(message (car k))
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kv-plist
(plist-put kv-plist
(intern (downcase (car k))) (car (cdr k))))))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-generate-article</span> ()
<span style="color: #95e454;">"Gera lista com dados de artigos do projeto.</span>
<span style="color: #95e454;">A lista retornada possui o formato</span>
<span style="color: #95e454;">'(filename (title desc link-img pub-date)) onde link-img pode ser nil caso nao</span>
<span style="color: #95e454;">exista. Description vai ser extraida de #+DESCRIPTION:"</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((files (directory-files-recursively (src-dir) <span style="color: #95e454;">"</span><span style="color: #ccaa8f;">\</span><span style="color: #95e454;">.org$"</span>)))
(mapcar (<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (fn) (list fn (website-extract-article-data fn)))
files)))
(<span style="color: #8ac6f2; font-weight: bold;">require</span> '<span style="color: #e5786d;">ox-publish</span>)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> org-publish-project-alist
`(
(<span style="color: #95e454;">"org-notes"</span>
<span style="color: #e5786d;">:base-directory</span> ,(src-dir)
<span style="color: #e5786d;">:base-extension</span> <span style="color: #95e454;">"org"</span>
<span style="color: #e5786d;">:publishing-directory</span> ,(publish-dir)
<span style="color: #e5786d;">:recursive</span> t
<span style="color: #e5786d;">:publishing-function</span> org-html-publish-to-html
<span style="color: #e5786d;">:headline-levels</span> 4 <span style="color: #99968b;">; </span><span style="color: #99968b;">Just the default for this project.</span>
<span style="color: #e5786d;">:auto-preamble</span> t
<span style="color: #e5786d;">:org-html-doctype</span> html5
<span style="color: #e5786d;">:html-doctype</span> <span style="color: #95e454;">"html5"</span>
<span style="color: #e5786d;">:org-html-html5-fancy</span> t
<span style="color: #e5786d;">:exclude</span> <span style="color: #95e454;">".*--ig--.*"</span>
<span style="color: #e5786d;">:html-preamble</span> ,website-html-preamble
<span style="color: #e5786d;">:html-postamble-format</span> <span style="color: #95e454;">""</span>
<span style="color: #e5786d;">:auto-sitemap</span> t
<span style="color: #e5786d;">:sitemap-title</span> <span style="color: #95e454;">"Site map"</span>
<span style="color: #e5786d;">:sitemap-filename</span> <span style="color: #95e454;">"site-map.org"</span>
)
(<span style="color: #95e454;">"org-static"</span>
<span style="color: #e5786d;">:base-directory</span> ,(src-dir)
<span style="color: #e5786d;">:base-extension</span> <span style="color: #95e454;">"css</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">js</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">png</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">jpg</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">gif</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">pdf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">mp3</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">ogg</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">swf|otf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">woff</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">woff2</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">ttf</span><span style="color: #95e454; font-weight: bold;">\\</span><span style="color: #95e454; font-weight: bold;">|</span><span style="color: #95e454;">svg"</span>
<span style="color: #e5786d;">:publishing-directory</span> ,(publish-dir)
<span style="color: #e5786d;">:recursive</span> t
<span style="color: #e5786d;">:publishing-function</span> org-publish-attachment
)
(<span style="color: #95e454;">"org"</span> <span style="color: #e5786d;">:components</span> (<span style="color: #95e454;">"org-notes"</span> <span style="color: #95e454;">"org-static"</span>))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--extract-kw</span> (kw)
<span style="color: #95e454;">"Auxiliar cria funcao que extrai lista de KW de todos os artigos."</span>
(<span style="color: #8ac6f2; font-weight: bold;">lambda</span> (data)
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((pl (car (cdr data))) )
(plist-get pl kw))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--list-all</span> (keyword)
<span style="color: #95e454;">"Extrai lista de keyword de todos os arquivos"</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((articles (website-generate-article)))
(remove nil (mapcar (website--extract-kw keyword) articles))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website--keyword-list</span> ()
<span style="color: #95e454;">"Lista de todas opcoes KEYWORD dos artigos."</span>
(<span style="color: #8ac6f2; font-weight: bold;">let</span> ((articles-kw (website--list-all 'keywords))
(split-string-default-separators <span style="color: #95e454;">"[ \f\t\n\r\v,]+"</span>)
(kw-list (list)))
(<span style="color: #8ac6f2; font-weight: bold;">dolist</span> (l articles-kw kw-list)
(<span style="color: #8ac6f2; font-weight: bold;">setq</span> kw-list (append kw-list (split-string l))))
(remove <span style="color: #95e454;">"nil"</span> (delete-dups kw-list))))
(<span style="color: #8ac6f2; font-weight: bold;">defun</span> <span style="color: #cae682;">website-new-article</span> ()
<span style="color: #95e454;">"Entrevista usuario e insera conteudo ao projeto"</span>
(<span style="color: #8ac6f2; font-weight: bold;">interactive</span>)
(<span style="color: #8ac6f2; font-weight: bold;">let*</span> ((title (read-string <span style="color: #95e454;">"Title: "</span> ))
(description (read-string <span style="color: #95e454;">"Descricao: "</span>))
(author (completing-read <span style="color: #95e454;">"Autor: "</span> (website--list-all 'author)))
(date (format-time-string <span style="color: #95e454;">"%d/%m/%Y"</span>))
(email (completing-read <span style="color: #95e454;">"Email: "</span> (website--list-all 'email)))
(keywords (completing-read-multiple <span style="color: #95e454;">"Palavras-chave: "</span>
(website--keyword-list)))
(filename (string-join
(list (concat (file-name-as-directory (src-dir))
(file-name-as-directory <span style="color: #95e454;">"articles"</span>))
(format-time-string <span style="color: #95e454;">"%Y%m%d"</span>) <span style="color: #95e454;">"-"</span>
(string-join (split-string title) <span style="color: #95e454;">"_"</span>) <span style="color: #95e454;">".org"</span>))))
(<span style="color: #8ac6f2; font-weight: bold;">with-current-buffer</span> (get-buffer-create filename)
(insert <span style="color: #95e454;">"#+SETUPFILE: ../setup/xtreme-simple-theme\n"</span>)
(insert (format <span style="color: #95e454;">"#+TITLE: %s\n"</span> title))
(insert (format <span style="color: #95e454;">"#+DATE: %s\n"</span> date))
(insert (format <span style="color: #95e454;">"#+AUTHOR: %s\n"</span> author))
(insert (format <span style="color: #95e454;">"#+EMAIL: %s\n"</span> email))
(insert (format <span style="color: #95e454;">"#+DESCRIPTION: %s\n"</span> description))
(insert (format <span style="color: #95e454;">"#+KEYWORDS: %s\n"</span> keywords))
(insert <span style="color: #95e454;">"#+LANGUAGE: pt_BR\n"</span>)
(insert <span style="color: #95e454;">"#+OPTIONS: num:nil\n"</span>)
(write-file filename))))
(<span style="color: #8ac6f2; font-weight: bold;">provide</span> '<span style="color: #e5786d;">website-publish</span>)
<span style="color: #99968b;">;;; </span><span style="color: #99968b;">website-publish.el ends here</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf8400c5" class="outline-2">
<h2 id="orgf8400c5">Referencia</h2>
<div class="outline-text-2" id="text-orgf8400c5">
<ul class="org-ul">
<li><a href="http://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html">Publishing Org-mode files to html</a></li>
<li>[Dale] <a href="http://dale.io/blog/automated-org-publishing.html">Automated Publishing Pipeline with Org Mode</a></li>
<li>[Petton] <a href="https://nicolas.petton.fr/blog/blogging-with-org-mode.html#org77b6e84">Blogging with org-mode</a></li>
<li>[jgkamat] <a href="https://jgkamat.github.io/blog/website1.html">Creating a blog in Org Mode</a></li>
</ul>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Data: 05/09/2017</p>
<p class="author">Autor: Ildenir Barbosa</p>
<p class="date">Criado em: 2024-04-08 seg 21:12</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>