From ae87c4f445a27d0b4322fa17daaf00118f46d843 Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 15:33:53 +0200 Subject: [PATCH 1/6] do not ask for overwrite permission -> sty-files --- mtheme.ins | 1 + 1 file changed, 1 insertion(+) diff --git a/mtheme.ins b/mtheme.ins index 8371110..dd15582 100644 --- a/mtheme.ins +++ b/mtheme.ins @@ -10,6 +10,7 @@ \input docstrip.tex \keepsilent +\askforoverwritefalse \usedir{tex/latex/mtheme} From 814896eb180e662e3637e7f33a9aeebe172fc440 Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 15:36:07 +0200 Subject: [PATCH 2/6] moved python script into separate file --- contributors.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ contributors.tex | 17 ++++++++++++ login.json | 4 +++ mtheme.dtx | 59 +----------------------------------------- 4 files changed, 89 insertions(+), 58 deletions(-) create mode 100755 contributors.py create mode 100644 contributors.tex create mode 100644 login.json diff --git a/contributors.py b/contributors.py new file mode 100755 index 0000000..8f012b2 --- /dev/null +++ b/contributors.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +import sys +import requests +import json + +LOGIN = None +try: + with open("login.json", "r") as f: + login_data = json.load(f) + if (login_data['user'] and login_data['password']): + LOGIN = (login_data['user'], + login_data['password']) +except: + print("Couldn't open file 'login.json'.") + sys.exit() + + +def apiRequestLeft(): + resp = requests.get("https://api.github.com/rate_limit", + auth=LOGIN) + if(resp.ok): + data = json.loads(resp.content) + return data['rate']['remaining'] + else: + return 0 + +if not (apiRequestLeft): + print("No API requests left to load contributors list. ") + if(LOGIN is None): + print ("To get more API requests enter your login data into " + + "'login.json'") + sys.exit() + +resp = requests.get("https://api.github.com/repos/matze/mtheme/contributors", + auth=LOGIN) + +latex_string = "\\begin{itemize}\n" +if(resp.ok): + data = json.loads(resp.content) + extracted_data = ((c['login'], c['html_url'], c['url']) for c in data) + for user_name, html_url, url in extracted_data: + resp = requests.get(url, auth=LOGIN) + if(resp.ok): + user_data = json.loads(resp.content) + try: + name = user_data['name'] + except: + name = "" + else: + if not (apiRequestLeft): + name = "Couldn't load name. API request limit exceeded." + else: + "Couldn't load name." + latex_string += str(" \\item \\href{%s}{%s} %s\n" % (html_url, + user_name, + name)) +else: + latex_string += " \\item Couldn't load contributors.\n" +latex_string += "\\end{itemize}\n" + +try: + with open("contributors.tex", "w") as f: + f.write(latex_string) + print("Successfully written data to file.") + print(latex_string) +except IOError: + print("Error writing to file.") diff --git a/contributors.tex b/contributors.tex new file mode 100644 index 0000000..d59ca63 --- /dev/null +++ b/contributors.tex @@ -0,0 +1,17 @@ +\begin{itemize} + \item \href{https://github.com/matze}{matze} Matthias Vogelgesang + \item \href{https://github.com/rchurchley}{rchurchley} Ross Churchley + \item \href{https://github.com/benjamin-weiss}{benjamin-weiss} Benjamin Weiss + \item \href{https://github.com/eddelbuettel}{eddelbuettel} Dirk Eddelbuettel + \item \href{https://github.com/ronnychevalier}{ronnychevalier} Ronny Chevalier + \item \href{https://github.com/jdahm}{jdahm} Johann Dahm + \item \href{https://github.com/Schwefelsaeure}{Schwefelsaeure} + \item \href{https://github.com/awalterschulze}{awalterschulze} Walter Schulze + \item \href{https://github.com/ehahn}{ehahn} Erik Hahn + \item \href{https://github.com/ChipmunkMath}{ChipmunkMath} + \item \href{https://github.com/timbers}{timbers} Finbarr Timbers + \item \href{https://github.com/kdungs}{kdungs} Kevin Dungs + \item \href{https://github.com/Leonidas-from-XIV}{Leonidas-from-XIV} Marek Kubica + \item \href{https://github.com/0ip}{0ip} Robin Buse + \item \href{https://github.com/cuzcomd}{cuzcomd} +\end{itemize} diff --git a/login.json b/login.json new file mode 100644 index 0000000..96415b9 --- /dev/null +++ b/login.json @@ -0,0 +1,4 @@ +{ + "user": "", + "password": "" +} diff --git a/mtheme.dtx b/mtheme.dtx index 2695d39..be83f25 100644 --- a/mtheme.dtx +++ b/mtheme.dtx @@ -26,8 +26,6 @@ \setmonofont{Fira Mono} \defaultfontfeatures{Ligatures=TeX} -\usepackage{pythontex} - \usepackage{enumitem} \setlist[itemize]{noitemsep} \setlist[enumerate]{noitemsep} @@ -122,62 +120,7 @@ To get started with the theme is very simple. The following code shows a minimal The theme itself is licensed under a \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0 International License}. This means that if you change the theme and re-distribute it, you must retain the copyright notice header and license it under the same CC-BY-SA license. This does not affect the presentation that you create with the theme. \section{Contributors} -\begin{pycode} -import sys -import requests -import json - -LOGIN = None -try: - with open('../login.json', 'r') as f: - login_data = json.load(f) - if (login_data['user'] and login_data['password']): - LOGIN = (login_data['user'], - login_data['password']) -except: - print("Couldn't load login data.") - sys.exit() - - -def apiRequestLeft(): - resp = requests.get('https://api.github.com/rate_limit', - auth=LOGIN) - if(resp.ok): - data = json.loads(resp.content) - return data['rate']['remaining'] - else: - return 0 - -if not (apiRequestLeft): - print("No API requests left to load contributors list. Do you have " + - "saved your login information in 'login.json'?") - sys.exit() - -resp = requests.get('https://api.github.com/repos/matze/mtheme/contributors', - auth=LOGIN) - -print("\\begin{itemize}") -if(resp.ok): - data = json.loads(resp.content) - extracted_data = ((c['login'], c['html_url'], c['url']) for c in data) - for user_name, html_url, url in extracted_data: - resp = requests.get(url, auth=LOGIN) - if(resp.ok): - user_data = json.loads(resp.content) - try: - name = user_data['name'] - except: - name = "" - else: - if not (apiRequestLeft): - name = "Couldn't load name. API request limit exceeded." - else: - "Couldn't load name." - print(" \\item \\href{%s}{%s} %s" % (html_url, user_name, name)) -else: - print(" \\item Couldn't load contributors.") -print("\\end{itemize}") -\end{pycode} +\input{contributors} \section{Implementation} \DocInput{beamerthemem.dtx} From dec149ccb72660066b60eab143af2334c5f5b4b2 Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 15:38:01 +0200 Subject: [PATCH 3/6] switched to latexmk instead of using XeLaTeX directly / removed old build script --- Makefile | 13 +++++++------ build_dtx.sh | 7 ------- 2 files changed, 7 insertions(+), 13 deletions(-) delete mode 100755 build_dtx.sh diff --git a/Makefile b/Makefile index 61be55a..b4cf8f8 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,13 @@ DTX = $(wildcard *.dtx) STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx)) TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME) INSTALL_DIR = $(TEXMFHOME)/tex/latex/mtheme +TEMP_DIR = .temptex DEMO_SRC = demo.tex DEMO_PDF = demo.pdf MANUAL_SRC = mtheme.dtx MANUAL_PDF = mtheme.pdf -TEXC := xelatex -shell-escape +TEXC := latexmk -xelatex -output-directory=$(TEMP_DIR) DOCKER_IMAGE = latex-image DOCKER_CONTAINER = latex-container @@ -17,19 +18,19 @@ DOCKER_CONTAINER = latex-container .PHONY: clean install manual sty docker-run docker-rm -all: demo manual +all: sty demo manual sty: $(DTX) $(INS) @latex $(INS) demo: $(STY) $(DEMO_SRC) $(TEXC) $(DEMO_SRC) + @cp $(TEMP_DIR)/$(DEMO_PDF) . + manual: $(MANUAL_SRC) - @mkdir -p .temptex - @$(TEXC) -output-directory .temptex $< - @$(TEXC) -output-directory .temptex $< - @cp .temptex/mtheme.pdf . + @$(TEXC) $(MANUAL_SRC) + @cp $(TEMP_DIR)/$(MANUAL_PDF) . clean: @git clean -xfd diff --git a/build_dtx.sh b/build_dtx.sh deleted file mode 100755 index fcc0f43..0000000 --- a/build_dtx.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mkdir -p .temptex -xelatex -shell-escape -output-directory .temptex mtheme.dtx -pythontex .temptex/mtheme.dtx -xelatex -shell-escape -output-directory .temptex mtheme.dtx -cp .temptex/mtheme.pdf ./mtheme.pdf From 1ddd0a3a246e2924f77217e486c78284eae1736c Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 15:38:29 +0200 Subject: [PATCH 4/6] new build rule contributors --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index b4cf8f8..457b560 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ INS = mtheme.ins +PYTHON_SRC = contributors.py DTX = $(wildcard *.dtx) STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx)) TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME) @@ -27,6 +28,8 @@ demo: $(STY) $(DEMO_SRC) $(TEXC) $(DEMO_SRC) @cp $(TEMP_DIR)/$(DEMO_PDF) . +contributors: $(PYTHON_SRC) + @python $(PYTHON_SRC) manual: $(MANUAL_SRC) @$(TEXC) $(MANUAL_SRC) From 3cdeac35770436445760997ee6db43f4727ecd63 Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 15:40:14 +0200 Subject: [PATCH 5/6] added login.json to .gitignore to prevent unintended committing of login data --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f2afe1f..356394c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ demo.pdf mtheme.pdf +login.json *.fls *.acn From 8393bf721ce18461061077aaddf2c2f4429b5e0b Mon Sep 17 00:00:00 2001 From: Benjamin Weiss Date: Mon, 15 Jun 2015 16:01:26 +0200 Subject: [PATCH 6/6] added contributors.tex dependency to manual --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 457b560..933f960 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ INS = mtheme.ins -PYTHON_SRC = contributors.py +CONTRIB_SRC = contributors.py +CONTRIB_TEX = contributors.tex DTX = $(wildcard *.dtx) STY = $(patsubst %.dtx,%.sty,$(wildcard beamer*.dtx)) TEXMFHOME = $(shell kpsewhich -var-value=TEXMFHOME) @@ -19,7 +20,7 @@ DOCKER_CONTAINER = latex-container .PHONY: clean install manual sty docker-run docker-rm -all: sty demo manual +all: sty demo contributors manual sty: $(DTX) $(INS) @latex $(INS) @@ -28,10 +29,10 @@ demo: $(STY) $(DEMO_SRC) $(TEXC) $(DEMO_SRC) @cp $(TEMP_DIR)/$(DEMO_PDF) . -contributors: $(PYTHON_SRC) - @python $(PYTHON_SRC) +$(CONTRIB_TEX):$(CONTRIB_SRC) + @python $(CONTRIB_SRC) -manual: $(MANUAL_SRC) +manual: $(MANUAL_SRC) $(CONTRIB_TEX) @$(TEXC) $(MANUAL_SRC) @cp $(TEMP_DIR)/$(MANUAL_PDF) .