├── .gitignore ├── LICENSE ├── README.md ├── generate.el ├── sample.exs ├── sample.rb └── templates ├── layout.html └── theme.html /.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | deploy.sh 3 | index.html 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Rob Merrell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spacemacs theme gallery 2 | http://themegallery.robdor.com/ 3 | 4 | A theme gallery for themes bundled with Spacemacs 5 | 6 | To generate the gallery open a file that you would like to use as the theme sample code and invoke: (generate-theme-gallery) 7 | 8 | A new buffer will be created with the contents of the theme gallery's html. 9 | -------------------------------------------------------------------------------- /generate.el: -------------------------------------------------------------------------------- 1 | ;; requires s.el to be available and loaded 2 | (require 's) 3 | (require 'cl-lib) 4 | (require 'helm-themes) 5 | (require 'htmlize) 6 | 7 | ;; requires to keep htmlize happy about font faces 8 | (require 'outline) 9 | 10 | ;; themes that cause errors. These are generally themes with a dark and light version 11 | ;; but no default version. For example hemisu has no deftheme, but hemisu-dark and 12 | ;; hemisu-light do 13 | (setq bad-themes '("apropospriate" "hemisu" "solarized" "zonokai")) 14 | 15 | ;; utility functions 16 | 17 | (defun get-string-from-file (filePath) 18 | "Read a file and return the contents as a string" 19 | (with-temp-buffer 20 | (insert-file-contents filePath) 21 | (buffer-string))) 22 | 23 | (defun write-string-to-file (filePath contents) 24 | (with-temp-buffer 25 | (insert contents) 26 | (write-file filePath))) 27 | 28 | (defun sub-lists (list1 list2) 29 | "Subtract list2 from list1" 30 | (cl-reduce 31 | (lambda (acc x) (remove x acc)) list2 :initial-value list1)) 32 | 33 | (defun sorted-helm-themes () 34 | "Sort and remove known bad themes from the lists" 35 | (sub-lists 36 | (cl-sort (mapcar 'symbol-name (helm-themes--candidates)) 'string-lessp :key 'downcase) 37 | bad-themes)) 38 | 39 | (defun mark-and-htmlize-buffer () 40 | "Mark the entire current buffer and htmlize it" 41 | (progn 42 | (mark-whole-buffer) 43 | (htmlize-region-for-paste (region-beginning) (region-end)))) 44 | 45 | 46 | ;; HTML generation 47 | 48 | (defun generate-index-html (tpl themes-html) 49 | "Create the index.html file" 50 | (s-format tpl 'elt (list spacemacs-version themes-html))) 51 | 52 | (defun generate-theme-div (tpl theme) 53 | "Generate the div for a single theme" 54 | (helm-themes--load-theme theme) 55 | (let* ((buffer-faces (htmlize-faces-in-buffer)) 56 | (face-map (htmlize-make-face-map (adjoin 'default buffer-faces))) 57 | (style (mapconcat #'identity (htmlize-css-specs (gethash 'default face-map)) " "))) 58 | (s-format tpl 'elt (list theme style (mark-and-htmlize-buffer))))) 59 | 60 | (defun generate-and-join-all-theme-divs (tpl themes) 61 | "Generate the divs containing the themed content that is embedded inside of the index.html layout" 62 | (s-join "" (mapcar (lambda (theme) (generate-theme-div tpl theme)) themes))) 63 | 64 | (defun generate-theme-gallery () 65 | "Generate all of the html needed for the theme gallery and place it's contents in a buffer called theme-gallery" 66 | (interactive) 67 | (rainbow-delimiters-mode-disable) 68 | (let* ((layout-tpl (get-string-from-file "./templates/layout.html")) 69 | (theme-tpl (get-string-from-file "./templates/theme.html")) 70 | (themes-html (generate-and-join-all-theme-divs theme-tpl (sorted-helm-themes)))) 71 | (set-buffer (get-buffer-create "theme-gallery")) 72 | (insert (generate-index-html layout-tpl themes-html))) 73 | (rainbow-delimiters-mode-enable) 74 | (switch-to-buffer (current-buffer))) 75 | 76 | -------------------------------------------------------------------------------- /sample.exs: -------------------------------------------------------------------------------- 1 | # This is a comment 2 | defmodule Math do 3 | def sum(a, b), do: a + b 4 | 5 | @doc """ 6 | Sum a list of numbers 7 | """ 8 | def sum_list(list) do 9 | Enum.reduce list, &Kernel.+/2 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /sample.rb: -------------------------------------------------------------------------------- 1 | # Sample highlightable code with keywords, 2 | # operators, strings, numbers, etc. 3 | module MyMath 4 | def self.sum_array(arr) 5 | arr.reduce(0) { |acc, x| x + acc } 6 | end 7 | end 8 | 9 | puts "Sum is: #{MyMath.sum_array([1, 2, 3])}" 10 | -------------------------------------------------------------------------------- /templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spacemacs theme gallery 5 | 6 | 7 | 8 | 9 | 68 | 69 | 70 | 71 |

Spacemacs Themes

72 |

v. $0

73 | 74 |
75 |
76 |
77 |

load themes on start up


78 | (setq-default dotspacemacs-themes '(list-themes-here)) 79 |
80 | 81 |
82 |

switch themes


83 | <SPC> T h 84 |
85 |
86 |
87 | 88 |
89 |
90 | $1 91 |
92 |
93 |

github.com/robmerrell/spacemacs_theme_gallery

94 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /templates/theme.html: -------------------------------------------------------------------------------- 1 |
2 |
$0
3 |
$2
4 |
5 | --------------------------------------------------------------------------------