From 3d8ee42287aa2a5e8528857fd31179a94ca67c9f Mon Sep 17 00:00:00 2001 From: Alex Myasoedov Date: Mon, 5 Mar 2018 20:23:12 -0500 Subject: [PATCH 1/3] Add base64 favicon --- static/js/index.js | 12 ++--- static/js/save.js | 4 +- static/js/slides.js | 114 +++++++++++++++++++++---------------------- templates/index.tmpl | 1 + 4 files changed, 66 insertions(+), 65 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 3244827..56cef9f 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1,4 +1,4 @@ -$(function() { +$(function () { function slideSeparatorLines(text) { var lines = text.split('\n'); @@ -19,7 +19,7 @@ $(function() { var text = ace.edit("editor").getValue(); var separatorPositions = slideSeparatorLines(text); var slideNumber = separatorPositions.length; - separatorPositions.every(function(pos, num) { + separatorPositions.every(function (pos, num) { if (pos >= cursorLine) { slideNumber = num; return false; @@ -35,14 +35,14 @@ $(function() { editor.getSession().setMode("ace/mode/markdown"); editor.getSession().setUseWrapMode(true); editor.setShowPrintMargin(true); - $.get('/slides.md', function(data) { + $.get('/slides.md', function (data) { editor.setValue(data, -1); }); var lastSRow = -1; - ace.edit('editor').getSession().selection.on('changeCursor', function(e) { + ace.edit('editor').getSession().selection.on('changeCursor', function (e) { var cursorRow = ace.edit('editor').getCursorPosition().row; - if(lastSRow === cursorRow){ - return; // no update + if (lastSRow === cursorRow) { + return; // no update } lastSRow = cursorRow; var currentSlide = currentCursorSlide(cursorRow); diff --git a/static/js/save.js b/static/js/save.js index 4ed9d3e..11de418 100644 --- a/static/js/save.js +++ b/static/js/save.js @@ -1,11 +1,11 @@ -$(function() { +$(function () { function reloadMarkdown() { $('#slides-frame')[0].contentWindow.postMessage(JSON.stringify({ method: 'reloadMarkdown' }), window.location.origin); } - window.save = function() { + window.save = function () { var editor = ace.edit("editor"); $.ajax("/slides.md", { diff --git a/static/js/slides.js b/static/js/slides.js index a5191f8..918fe13 100644 --- a/static/js/slides.js +++ b/static/js/slides.js @@ -17,58 +17,58 @@ function initializeReveal() { // Optional reveal.js plugins dependencies: [{ - src: '/static/reveal.js/lib/js/classList.js', - condition: function() { - return !document.body.classList; - } - }, - - // Interpret Markdown in
elements - { - src: '/static/reveal.js/plugin/markdown/marked.js', - condition: function() { - return !!document.querySelector('[data-markdown]'); - } - }, { - src: '/static/reveal.js/plugin/markdown/markdown.js', - condition: function() { - return !!document.querySelector('[data-markdown]'); - } - }, - - // Syntax highlight for elements - { - src: '/static/reveal.js/plugin/highlight/highlight.js', - async: true, - callback: function() { - hljs.initHighlightingOnLoad(); - } - }, - - // Zoom in and out with Alt+click - { - src: '/static/reveal.js/plugin/zoom-js/zoom.js', - async: true - }, - - // Speaker notes - { - src: '/static/reveal.js/plugin/notes/notes.js', - async: true - }, - - // MathJax - { - src: '/static/reveal.js/plugin/math/math.js', - async: true - }, - - { - src: '/static/reveal.js/lib/js/classList.js', - condition: function() { - return !document.body.classList; - } + src: '/static/reveal.js/lib/js/classList.js', + condition: function () { + return !document.body.classList; } + }, + + // Interpret Markdown in
elements + { + src: '/static/reveal.js/plugin/markdown/marked.js', + condition: function () { + return !!document.querySelector('[data-markdown]'); + } + }, { + src: '/static/reveal.js/plugin/markdown/markdown.js', + condition: function () { + return !!document.querySelector('[data-markdown]'); + } + }, + + // Syntax highlight for elements + { + src: '/static/reveal.js/plugin/highlight/highlight.js', + async: true, + callback: function () { + hljs.initHighlightingOnLoad(); + } + }, + + // Zoom in and out with Alt+click + { + src: '/static/reveal.js/plugin/zoom-js/zoom.js', + async: true + }, + + // Speaker notes + { + src: '/static/reveal.js/plugin/notes/notes.js', + async: true + }, + + // MathJax + { + src: '/static/reveal.js/plugin/math/math.js', + async: true + }, + + { + src: '/static/reveal.js/lib/js/classList.js', + condition: function () { + return !document.body.classList; + } + } ] }); @@ -76,8 +76,8 @@ function initializeReveal() { } function highlightAnyCodeBlocks() { - $(document).ready(function() { - $('pre code').each(function(i, block) { + $(document).ready(function () { + $('pre code').each(function (i, block) { hljs.highlightBlock(block); }); }); @@ -108,7 +108,7 @@ function reloadMarkdown() { } function externalLinksInNewWindow() { - $(document.links).filter(function() { + $(document.links).filter(function () { return this.hostname != window.location.hostname; }).attr('target', '_blank'); } @@ -119,7 +119,7 @@ initializeReveal(); function themesCtrl() { var defaultTheme = "black.css", currentTheme = localStorage.getItem('theme?') || - defaultTheme; + defaultTheme; function setTheme(theme) { cssEl = $("#theme"); @@ -145,12 +145,12 @@ function themesCtrl() { "white.css", ]; themeEl = $("#themes"); - availableThemes.forEach(function(theme) { + availableThemes.forEach(function (theme) { elem = $(""); themeEl.append(elem); }) themeEl.val(currentTheme); - themeEl.change(function() { + themeEl.change(function () { val = themeEl.val() setTheme(val); }); diff --git a/templates/index.tmpl b/templates/index.tmpl index 325967e..cec05fd 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -9,6 +9,7 @@ Hacker Slides + From c6b9f67933afe92d044f2e0b8404bd0a3a55801a Mon Sep 17 00:00:00 2001 From: Alex Myasoedov Date: Mon, 5 Mar 2018 20:24:43 -0500 Subject: [PATCH 2/3] Fix typo. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7a6b603..ffff00a 100644 --- a/main.go +++ b/main.go @@ -73,7 +73,7 @@ func NewApp() *gin.Engine { mustHaveSession := func(c *gin.Context) (string, error) { session := sessions.Default(c) val := session.Get("name") - emptySession := errors.New("Emtpy session") + emptySession := errors.New("Empty session") if val == nil { c.String(400, "No context") return "", emptySession From 7f1d9619bc1ad9b7013c60b71194e37062eabc25 Mon Sep 17 00:00:00 2001 From: Alex Myasoedov Date: Mon, 5 Mar 2018 20:29:19 -0500 Subject: [PATCH 3/3] Update makefile. --- Makefile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c87bace..015e99f 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,23 @@ GIT_SUMMARY := $(shell git describe --tags --dirty --always) REPO=msoedov/hacker-slides - +DOCKER_IMAGE := $(REPO):$(GIT_SUMMARY) default: repo repo: - @echo $(REPO):$(GIT_SUMMARY) + @echo $(DOCKER_IMAGE) build: @GOOS=linux CGO_ENABLE=0 go build main.go - @docker build -t $(REPO):$(GIT_SUMMARY) . - @docker tag $(REPO):$(GIT_SUMMARY) $(REPO) + @docker build -t $(DOCKER_IMAGE) . + @docker tag $(DOCKER_IMAGE) $(REPO) push: - @docker push $(REPO):$(GIT_SUMMARY) + @docker push $(DOCKER_IMAGE) @docker push $(REPO) r: - @docker run -it -p 8080:8080 $(REPO):$(GIT_SUMMARY) + @docker run -it -p 8080:8080 $(DOCKER_IMAGE) + +release: + @build + @push