Browse Source

It works??? PUBLISHING AND ALL

Ryan Rix 3 years ago
parent
commit
00928ece13
6 changed files with 205 additions and 39 deletions
  1. 69 33
      arcology.el
  2. 0 3
      mfblog.el
  3. 1 1
      templates/default.html
  4. 133 0
      templates/index.html
  5. 1 1
      templates/note.html
  6. 1 1
      templates/photo.html

+ 69 - 33
arcology.el

@@ -92,7 +92,7 @@
   :group 'arcology)
 
 ;;;###autoload
-(defcustom arcology-index-template-file "/home/rrix/Projects/notes/templates/default.html"
+(defcustom arcology-index-template-file "/home/rrix/Projects/notes/templates/index.html"
   "Template file to use for the site index"
   :group 'arcology)
 
@@ -101,11 +101,6 @@
   "The title of your site"
   :group 'arcology)
 
-;;;###autoload
-(defcustom arcology-temporary-directory "/var/tmp/mfblog"
-  "The location which Arcology will render the blog"
-  :group 'arcology)
-
 (defvar arcology-entry-cache nil)
 (defvar arcology-full-postlist nil)
 
@@ -123,22 +118,38 @@ cache."
       (arcology-index-entries config))
     (arcology-generate-modified-entries config)
     (arcology-generate-index config :index (lambda (metadata) nil))
-    ;; Create a list of post types in use
-    (let ((post-types-to-index (reduce (lambda (last current)
-                                         (if (member (elt current 0) last)
-                                             last
-                                           (append last (list (elt current 0)))))
-                                       arcology-full-postlist
-                                       :initial-value '())))
-      (mapc (lambda (post-type)
-              (arcology-generate-index config post-type
-                                       (lambda (metadata)
-                                         (not (eq (elt metadata 0) post-type)))))
-            post-types-to-index))))
+    (mapc (lambda (post-type)
+            (arcology-generate-index config post-type
+                                     (lambda (metadata)
+                                       (not (eq (elt metadata 0) post-type)))))
+          (arcology-post-types-from-list arcology-full-postlist)))
+  (arcology-publish))
+
+(defun arcology-publish ()
+  "Publish an already-rendered Arcology site"
+  (interactive)
+  (let* ((config (arcology-make-config))
+         (org-publish-project-alist
+          (list (append '("notes_other")
+                        (mfblog:plist-merge '(:base-extension "JPG\\|js\\|html\\|jpg\\|gif\\|png" :publishing-function (org-publish-attachment))
+                                            arcology-publish-config
+                                            config)))))
+    (copy-file "~/Projects/notes/webmention.js" "/var/tmp/mfblog/webmention.js" t)
+    (copy-file "~/Projects/notes/go.png" "/var/tmp/mfblog/go.png" t)
+    (copy-file "~/Projects/notes/favicon.gif" "/var/tmp/mfblog/favicon.gif" t)
+    (org-publish "notes_other")))
+
+(defun arcology-post-types-from-list (postlist)
+  (reduce (lambda (last current)
+            (if (member (elt current 0) last)
+                last
+              (append last (list (elt current 0)))))
+          postlist
+          :initial-value '()))
 
 (defun arcology-make-config (&optional base)
   (let (plist (list))
-    (append (list :site-root arcology-site-root)
+    (append (list :base-directory arcology-site-root)
             (list :site-tag arcology-site-tag)
             (when base
               base))))
@@ -160,7 +171,7 @@ cache."
 
 (defun arcology-generate-index (config type filterfun)
   (arcology-write-template
-   (format "%s/%s.html" arcology-temporary-directory
+   (format "%s/%s.html" arcology-site-root
            (replace-regexp-in-string ":" "" (prin1-to-string type)))
    arcology-index-template-file
    :content (format
@@ -172,12 +183,15 @@ cache."
                                                         entry-type))
                                  (entry (lax-plist-get entry-list
                                                        key)))
-                            (format "<li>%s <a href=\"%s\">Permalink</a></lio>"
+                            (format "<li class=\"h-entry\"><time class=\"dt-published\" datetime=\"%s\">@%s</time> <span class=\"p-name\">%s</span> <a class=\"u-url\" href=\"%s\">Permalink</a></li>"
+                                    (elt metadata 4)
+                                    (elt metadata 4)
                                     (plist-get entry :title-html)
                                     (elt metadata 3))))
                         (cl-remove-if filterfun (reverse arcology-full-postlist)) "\n"))
    :title arcology-index-title
-   :url (plist-get config :site-root)))
+   :title-html arcology-index-title
+   :url (plist-get config :base-directory)))
 
 (defun arcology-plist-mapc (fun plist)
   (cl-loop for (k v) on plist by 'cddr
@@ -203,13 +217,14 @@ cache."
        (save-window-excursion
          (with-current-buffer (plist-get entry :buffer)
            (goto-char (plist-get entry :point))
-           (unless (file-exists-p arcology-temporary-directory)
-             (make-directory arcology-temporary-directory))
+           (unless (file-exists-p arcology-site-root)
+             (make-directory arcology-site-root))
            (let* ((pubdate (arcology-alist-get "CLOSED" (plist-get entry :properties)))
                   (pubdate (org-time-string-to-seconds pubdate))
                   (filename (format "%s-note.html" pubdate))
-                  (fullpath (format "%s/%s" arcology-temporary-directory filename))
-                  (title (plist-get entry :title-html))
+                  (fullpath (format "%s/%s" arcology-site-root filename))
+                  (title (plist-get entry :title))
+                  (title-html (plist-get entry :title-html))
                   (content (funcall ,content-generator entry))
                   (base-url (plist-get arcology-publish-config :html-link-home))
                   (full-url (concat base-url "/" filename))
@@ -227,11 +242,12 @@ cache."
              (arcology-write-template fullpath ,template-file-var
                                       :content content
                                       :title title
+                                      :title-html title-html
                                       :url full-url
                                       :twitter syn-twitter-href
                                       :facebook syn-facebook-href)
              (add-to-ordered-list 'arcology-full-postlist
-                                  (list ,type-as-symbol key fullpath full-url)
+                                  (list ,type-as-symbol key fullpath full-url (truncate pubdate))
                                   pubdate)))))))
 
 (defun arcology-write-template (fullpath template-file &rest template-args)
@@ -239,19 +255,22 @@ cache."
     (erase-buffer)
     (insert-file template-file)
     (goto-char (point-min))
-    (replace-regexp "{{content}}" (or (lax-plist-get template-args :content)
+    (replace-regexp "{{content}}" (or (plist-get template-args :content)
                                       ""))
     (goto-char (point-min))
-    (replace-regexp "{{title}}" (or (lax-plist-get template-args :title)
+    (replace-regexp "{{title}}" (or (plist-get template-args :title)
                                     ""))
     (goto-char (point-min))
-    (replace-regexp "{{url}}" (or (lax-plist-get template-args :url)
+    (replace-regexp "{{title-html}}" (or (plist-get template-args :title-html)
+                                         ""))
+    (goto-char (point-min))
+    (replace-regexp "{{url}}" (or (plist-get template-args :url)
                                   ""))
     (goto-char (point-min))
-    (replace-regexp "<a href=\"{{twitter}}\">On Twitter</a>" (or (lax-plist-get template-args :twitter)
+    (replace-regexp "<a href=\"{{twitter}}\">On Twitter</a>" (or (plist-get template-args :twitter)
                                                                  ""))
     (goto-char (point-min))
-    (replace-regexp "<a href=\"{{facebook}}\">On Facebook</a>" (or (lax-plist-get template-args :facebook)
+    (replace-regexp "<a href=\"{{facebook}}\">On Facebook</a>" (or (plist-get template-args :facebook)
                                                                    ""))
     (write-file fullpath)
     (kill-buffer (current-buffer))))
@@ -349,13 +368,25 @@ inferring the post type of a given entry."
     (with-current-buffer (org-html-export-as-html nil t nil t)
       (dolist (file file-list)
         (let ((file- (concat attach-dir "/" file))
-              (newfile (concat arcology-temporary-directory "/" id "-" file)))
+              (newfile (concat arcology-site-root "/" id "-" file)))
           (unless (file-exists-p newfile)
             (copy-file file- newfile)
             (set-file-modes newfile 420))
           (insert "<img style=\"width: 100%\" src=\"" id "-" file "\" class=\"u-photo\"/><br/>")))
       (buffer-string))))
 
+(defun arcology-plist-merge (&rest plists)
+  "Merge a bunch of PLISTS together."
+  (if plists
+      (let ((result (copy-sequence (car plists))))
+        (while (setq plists (cdr plists))
+          (let ((plist (car plists)))
+            (while plist
+              (setq result (plist-put result (car plist) (car (cdr plist)))
+                    plist (cdr (cdr plist))))))
+        result)
+    nil))
+
 (def-arcology-entry-generator note (lambda (entry) ""))
 (def-arcology-entry-generator read
   #'arcology-get-default-content)
@@ -364,3 +395,8 @@ inferring the post type of a given entry."
 (def-arcology-entry-generator photo
   #'arcology-add-image-content)
 
+(add-to-list 'org-capture-templates '("_" "Published shortnote" entry (file "/home/rrix/Projects/notes/index.org")
+                                      "* %? :EXPORT:\n%U\n%a\n" :prepend t))
+
+(provide 'arcology)
+;;; arcology.el ends here

+ 0 - 3
mfblog.el

@@ -260,8 +260,5 @@ href=\"http://notes.whatthefuck.computer/index.xml\">RSS</a>.</p>"
       (replace-regexp "{{title}}" "Ryan's Shortnotes")
       (write-file "/var/tmp/mfblog/index.html"))))
 
-(add-to-list 'org-capture-templates '("_" "Published shortnote" entry (file "/home/rrix/Projects/notes/index.org")
-                                      "* %? :EXPORT:\n%U\n%a\n" :prepend t))
-
 (provide 'mfblog)
 ;;; mfblog.el ends here

+ 1 - 1
templates/default.html

@@ -142,7 +142,7 @@ ul.webmentions li > a {   width: 350px;
     </head>
     <body class="h-entry">
         <div class="e-content">
-            <h1 class="p-name title">{{title}}</h1>
+            <h1 class="p-name title">{{title-html}}</h1>
             {{content}}
         </div>
         <p>

+ 133 - 0
templates/index.html

@@ -0,0 +1,133 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+    <head>
+        <!-- 2015-12-30 Wed 02:40 -->
+        <meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
+        <meta  name="viewport" content="width=device-width, initial-scale=1" />
+        <title>{{title}}</title>
+        <meta  name="generator" content="Org-mode" />
+        <meta  name="author" content="Ryan Rix" />
+        <style type="text/css">
+         <!--/*--><![CDATA[/*><!--*/
+         ul.webmentions li { display: flex; align-items: center; }
+         ul.webmentions li img { border-radius: 50%; }
+         ul.webmentions li div { flex: auto; }
+         ul.webmentions li > a {   width: 350px; 
+             height: 75px;
+             width: 75px;
+             background: url("/go.png");
+             background-size: 100%;
+             text-indent: -9999px;
+         }
+         time { font-size: 0.6em; }
+         .tag    { display: none; }
+         .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; }
+         p.verse { margin-left: 3%; }
+         pre {
+             border: 1px solid #ccc;
+             box-shadow: 3px 3px 3px #eee;
+             padding: 8pt;
+             font-family: monospace;
+             overflow: auto;
+             margin: 1.2em;
+         }
+         pre.src {
+             position: relative;
+             overflow: visible;
+             padding-top: 1.2em;
+         }
+         pre.src:before {
+             display: none;
+             position: absolute;
+             background-color: white;
+             top: -10px;
+             right: 10px;
+             padding: 3px;
+             border: 1px solid black;
+         }
+         pre.src:hover:before { display: inline;}
+         pre.src-sh:before    { content: 'sh'; }
+         pre.src-bash:before  { content: 'sh'; }
+         pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
+         pre.src-R:before     { content: 'R'; }
+         pre.src-perl:before  { content: 'Perl'; }
+         pre.src-java:before  { content: 'Java'; }
+         pre.src-sql:before   { content: 'SQL'; }
+
+         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; }
+         .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; }
+         /*]]>*/-->
+        </style>
+        <link rel="stylesheet" href="http://whatthefuck.computer/media/css/main.css" />
+        <link rel="pingback" href="https://webmention.io/notes.whatthefuck.computer/xmlrpc" />
+    </head>
+    <body>
+        <div class="h-feed">
+            <h1 class="p-name title">{{title}}</h1>
+            <p>
+                I'm <a href="./images/headshot_bw.jpg">Ryan Rix</a>, computer infrastructure wonk, public infrastructure wonk-wannabe, engineer at <a href="http://uber.com/">Uber</a>,
+                community engineer and breaker of hardware living in the <del>gray</del> bay area.
+            </p>
+            <p>
+                I build decentralized infrastructure in my free time. I build stupid Emacs libraries
+                and applications. I take public transit. I <a href="http://computeranonymous.org/">computer :(</a>. Some may say that I <a href="http://fedoraproject.org/wiki/User:Rrix">open source</a>,
+                too. I buy stupid domains and use them for bad jokes. My dirty secret is that all of my
+                other jokes are based on old <a href="http://youtu.be/pbKVLhhflEI">Liam Lynch videos</a>.
+            </p>
+            <p>
+                In past lives, I've been a <a href="http://doc.rix.si/work/storehouse.html">storer of stories</a> <a href="http://doc.rix.si/projects/heatsynclabs">hackerspace board member</a>,
+                javascript nerd and <a href="http://doc.rix.si/work/madesolid.html">3D printer botmaster</a>. I am still some of these things.
+            </p>
+            <p>
+                I post various post types: <a href="/photo.html">photos</a>, <a href="/checkin.html">Check-ins</a>, <a href="/read.html">things I've read</a>, <a href="/note.html">Twitter-style notes</a>, and <a href="/article.html">long-form articles</a>. I'm going to be adding more and more post types as I integrate them in to <a href="http://doc.rix.si/projects/arcology.html">Arcology</a> my self-sufficient media platform.
+            </p>
+            
+            {{content}}
+            <div id="postamble" class="status">
+                <div class="h-card p-author">
+                    <div style="display: inline-block; width: 20%">
+                        <img style="width: 100%;" class="u-photo" src="http://notes.whatthefuck.computer/~rrix/25ZLKRlf.jpg"/>
+                    </div>
+                    <div style="display: inline-block; width: 75%" class="p-note">
+                        <span class="p-name">Ryan Rix</span> is a computer infrastructure fanboy who dabbles in decentralized systems. Reach him on <a href="http://twitter.com/rrrrrrrix" rel="me" class="u-url">twitter as @rrrrrrrix</a>, via email to <a href="mailto:ryan@whatthefuck.computer" class="u-email" rel="me">ryan@whatthefuck.computer</a> or on <a rel="me" href="https://facebook.com/rjrix">Facebook</a> or on Matrix as <span rel="me" class="u-uid">@rrix:whatthefuck.computer</span>.
+                    </div>
+                </div>
+            </div>
+        </div>
+        <a href="https://brid.gy/publish/facebook"></a>
+        <a href="https://brid.gy/publish/twitter"></a>
+        <script src="/webmention.js"></script>
+    </body>
+</html>

+ 1 - 1
templates/note.html

@@ -156,7 +156,7 @@ ul.webmentions li > a {   width: 350px;
     </head>
     <body class="h-entry">
         <div class="e-content">
-            <h1 class="p-name title">{{title}}</h1>
+            <h1 class="p-name title">{{title-html}}</h1>
             {{content}}
         </div>
         <p>

+ 1 - 1
templates/photo.html

@@ -156,7 +156,7 @@ ul.webmentions li > a {   width: 350px;
     </head>
     <body class="h-entry">
         <div class="e-content">
-            <h1 class="p-name title">{{title}}</h1>
+            <h1 class="p-name title">{{title-html}}</h1>
             {{content}}
         </div>
         <p>