Browse files

Removed iframes, just use inline HTML for all themes now

  • Loading branch information...
robmerrell committed Jul 28, 2015
1 parent 636d3f7 commit caddbb11e815d6487c25e958759abfa38d7ee4f4
Showing with 65 additions and 52 deletions.
  1. +40 −28 generate.el
  2. +8 −12 sample.exs
  3. +9 −0 sample.rb
  4. +7 −3 templates/layout.html
  5. +0 −8 templates/lazyload.min.js
  6. +1 −1 templates/{iframe.html → theme.html}
@@ -3,6 +3,7 @@
(require 's)
(require 'cl-lib)
(require 'helm-themes)
(require 'htmlize)
;; requires to keep htmlize happy about font faces
(require 'outline)
@@ -12,12 +13,19 @@
;; hemisu-light do
(setq bad-themes '("apropospriate" "hemisu" "solarized" "zonokai"))
;; utility functions
(defun get-string-from-file (filePath)
"Read a file and return the contents as a string"
(insert-file-contents filePath)
(defun write-string-to-file (filePath contents)
(insert contents)
(write-file filePath)))
(defun sub-lists (list1 list2)
"Subtract list2 from list1"
@@ -29,36 +37,40 @@
(cl-sort (mapcar 'symbol-name (helm-themes--candidates)) 'string-lessp :key 'downcase)
(defun generate-theme-files ()
"Create HTML files for all available themes in the 'html' subdirectory"
(lambda (theme)
(helm-themes--load-theme theme)
(htmlize-file "./sample.exs" (concat "./html/" theme ".html")))
(defun mark-and-htmlize-buffer ()
"Mark the entire current buffer and htmlize it"
(htmlize-region-for-paste (region-beginning) (region-end))))
(defun generate-index-html (tpl iframes-html)
;; HTML generation
(defun generate-index-html (tpl themes-html)
"Create the index.html file"
(s-format tpl 'elt (list spacemacs-version iframes-html)))
(s-format tpl 'elt (list spacemacs-version themes-html)))
(defun generate-theme-div (tpl theme)
"Generate the div for a single theme"
(helm-themes--load-theme theme)
(let* ((buffer-faces (htmlize-faces-in-buffer))
(face-map (htmlize-make-face-map (adjoin 'default buffer-faces)))
(style (mapconcat #'identity (htmlize-css-specs (gethash 'default face-map)) " ")))
(s-format tpl 'elt (list theme style (mark-and-htmlize-buffer)))))
(defun generate-iframes-html (tpl themes)
"Generate the HTML that is embedded inside of the index.html layout"
(s-join ""
(lambda (theme)
(s-format tpl 'elt (list theme)))
(defun generate-and-join-all-theme-divs (tpl themes)
"Generate the divs containing the themed content that is embedded inside of the index.html layout"
(s-join "" (mapcar (lambda (theme) (generate-theme-div tpl theme)) themes)))
(defun generate-site-files ()
"The one function to rule them all that generates all of the files in one go. You probably want to call this function."
(if (file-exists-p "./html")
(delete-directory "./html" t))
(mkdir "./html")
(copy-file "./templates/lazyload.min.js" "./html/lazyload.min.js")
(generate-index-html (get-string-from-file "./templates/layout.html")
(generate-iframes-html(get-string-from-file "./templates/iframe.html") (sorted-helm-themes)))
nil "./html/index.html"))
(defun generate-theme-gallery ()
"Generate all of the html needed for the theme gallery and place it's contents in a buffer called theme-gallery"
(let* ((layout-tpl (get-string-from-file "./templates/layout.html"))
(theme-tpl (get-string-from-file "./templates/theme.html"))
(themes-html (generate-and-join-all-theme-divs theme-tpl (sorted-helm-themes))))
(set-buffer (get-buffer-create "theme-gallery"))
(insert (generate-index-html layout-tpl themes-html)))
(switch-to-buffer (current-buffer)))
@@ -1,15 +1,11 @@
defmodule KV do
def start_link do
Task.start_link(fn -> loop(%{}) end)
# This is a comment
defmodule Math do
def sum(a, b), do: a + b
defp loop(map) do
receive do
{:get, key, caller} ->
send caller, Map.get(map, key)
{:put, key, value} ->
loop(Map.put(map, key, value))
@doc """
Sum a list of numbers
def sum_list(list) do
Enum.reduce list, &Kernel.+/2
@@ -0,0 +1,9 @@
# Sample highlightable code with keywords,
# operators, strings, numbers, etc.
module MyMath
def self.sum_array(arr)
arr.reduce(0) { |acc, x| x + acc }
puts "Sum is: #{MyMath.sum_array([1, 2, 3])}"
@@ -28,6 +28,10 @@
text-align: center;
pre {
font-size: 0.8em;
#instructions {
background-color: #e7e7e7;
border-bottom: 1px solid #b7b7b7;
@@ -46,10 +50,10 @@
padding: 10px;
.source-frame {
.theme-content {
border: 1px solid black;
height: 300px;
width: 400px;
height: 225px;
width: 375px;
.theme {

This file was deleted.

Oops, something went wrong.
@@ -1,4 +1,4 @@
<div class="pure-u-1 pure-u-md-1-2 pure-u-lg-1-3 theme">
<div class="theme-title">$0</div>
<iframe data-src="$0.html" src="about:blank" onload="lzld(this)" class="source-frame"></iframe>
<div style="$1" class="theme-content">$2</div>

0 comments on commit caddbb1

Please sign in to comment.