Parcourir la Source

Add gfycat plugin.

Brit Butler il y a 10 ans
Parent
commit
3490af0287
3 fichiers modifiés avec 33 ajouts et 0 suppressions
  1. 2 0
      NEWS.md
  2. 6 0
      docs/plugin-use.md
  3. 25 0
      plugins/gfycat.lisp

+ 2 - 0
NEWS.md

@@ -12,6 +12,8 @@ Legend:
12 12
 * Coleslaw now handles **deploy-dir**, **repo**, and **staging-dir**
13 13
   config options more gracefully. Previously, various errors could be
14 14
   encountered if directory options lacked a trailing slash.
15
+* **New Plugin**: Support for [embedded gfycats][http://gfycat.com/] has been added.
16
+
15 17
 
16 18
 ## Changes for 0.9.6 (2014-09-27):
17 19
 

+ 6 - 0
docs/plugin-use.md

@@ -21,6 +21,12 @@
21 21
 
22 22
 **Example**: `(disqus :shortname "disqus-provided-unique-id")`
23 23
 
24
+## HTML5 Gifs via Gfycat
25
+
26
+**Description**: Provides support for embedding [gfycat](http://gfycat.com/) gifs.
27
+
28
+**Example**: `(gfycat)`
29
+
24 30
 ## Hosting via Github Pages
25 31
 
26 32
 **Description**: Allows hosting with CNAMEs via

+ 25 - 0
plugins/gfycat.lisp

@@ -0,0 +1,25 @@
1
+(defpackage :coleslaw-gfycat
2
+  (:use :cl)
3
+  (:export #:enable)
4
+  (:import-from :coleslaw #:add-injection
5
+                          #:content
6
+                          #:tag-p))
7
+
8
+(in-package :coleslaw-gfycat)
9
+
10
+(defvar *gfycat-header*
11
+  "<script>
12
+ (function(d, t) {
13
+    var g = d.createElement(t),
14
+        s = d.getElementsByTagName(t)[0];
15
+    g.src = 'http://assets.gfycat.com/js/gfyajax-0.517d.js';
16
+    s.parentNode.insertBefore(g, s);
17
+}(document, 'script'));
18
+</script>")
19
+
20
+(defun enable ()
21
+  (flet ((inject-p (x)
22
+           (when (and (typep x 'content)
23
+                      (tag-p "gfycat" x))
24
+             *gfycat-header*)))
25
+    (add-injection #'inject-p :head)))