From 36323c593f3742937c48c9ab2b341c0016d1bccb Mon Sep 17 00:00:00 2001 From: serkan Date: Tue, 25 Dec 2018 18:16:13 +0300 Subject: [PATCH] Use a temp file to restore data when not connected to github (#3) * save-load file to restore when not connected * added white & blue color schemes * personal changes --- index.js | 8 ++++---- run.sh | 4 ++-- src/generate.js | 43 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 6ea6edb..68de4d3 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,14 @@ -command: `./github-activity.widget/run.sh`, +command: `./GithubActivity/run.sh`, refreshFrequency: 3600000, style: "\ #github-activity {\ position: absolute;\ left: 50%;\ - top: 50%;\ - transform: translateX(-50%) translateY(-50%);\ + bottom: 20px;\ + transform: translateX(-50%);\ }", render: () => { - return ""; + return ""; }, update: (output, domEl) => { domEl.innerHTML += output; diff --git a/run.sh b/run.sh index 2288654..a6a3132 100755 --- a/run.sh +++ b/run.sh @@ -2,8 +2,8 @@ if [ -f /usr/local/bin/node ]; then # If node is installed via Homebrew, use it - /usr/local/bin/node ./github-activity.widget/src/generate.js + /usr/local/bin/node ./GithubActivity/src/generate.js else # Fallback to normal - node ./github-activity.widget/src/generate.js + node ./GithubActivity/src/generate.js fi diff --git a/src/generate.js b/src/generate.js index 8b8fa83..a70c827 100644 --- a/src/generate.js +++ b/src/generate.js @@ -1,12 +1,12 @@ // For documentation on these options, see the README at https://github.com/shadowfacts/uebersicht-github-activity/ const options = { - user: "shadowfacts", - size: 44, - incrAmount: 6, + user: "serkakres", + size: 26, + incrAmount: 4, margin: 2, vary: ["size", "color"], shape: "circle", - theme: "red", + theme: "blue", colors: { overrides: { none: [null, null], @@ -28,18 +28,51 @@ const options = { two: ["#8cc665", "#d6e685"], three: ["#44a340", "#8cc665"], max: ["#1e6823", "#44a340"] + }, + greenish: { + none: ["#", "#"], + one: ["#d6e685", "#"], + two: ["#8cc665", "#"], + three: ["#44a340", "#"], + max: ["#1e6823", "#"] + }, + white: { + none: ["#000", "#000"], + one: ["#444", "#222"], + two: ["#777", "#444"], + three: ["#aaa", "#777"], + max: ["#eee", "#aaa"] + }, + blue: { + none: ["#", "#"], + one: ["#0723b2", "#041469"], + two: ["#0244b2", "#0723b2"], + three: ["#006ec9", "#0244b2"], + max: ["#4baffc", "#006ec9"] } } }; const axios = require("axios"); const cheerio = require("cheerio"); +const fs = require('fs'); axios.get(`https://github.com/${options.user}`) .then(generate) - .catch(() => {}); + .catch(() => { + generate(null) + }); function generate(res) { + if(res !== null){ + let data = JSON.stringify(res.data); + fs.writeFileSync('github-activity.json', data); + } + else { + let rawdata = fs.readFileSync('github-activity.json'); + res = {'data': JSON.parse(rawdata)}; + } + console.log(``); const $ = cheerio.load(res.data);