1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-10-08 00:33:12 +02:00
This commit is contained in:
Matthias Kretschmann 2018-08-29 00:14:58 +02:00
parent 366f9c5ea4
commit f13982c623
Signed by: m
GPG Key ID: 606EEEF3C479A91F
19 changed files with 30 additions and 472 deletions

5
.codeclimate.yml Normal file
View File

@ -0,0 +1,5 @@
version: '2'
checks:
method-lines:
config:
threshold: 50 # Gatsby's StaticQuery makes render functions pretty long

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2008-2017 Matthias Kretschmann
Copyright (c) 2008-2018 Matthias Kretschmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,5 +1,3 @@
All post content under `_src/_posts` is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
License.
All post content under `./content/posts` is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
http://creativecommons.org/licenses/by-nc-sa/4.0/.

View File

@ -1,7 +1,6 @@
All photos & image assets under `_src/_media`, `_src/assets/img`, and
`assets sheet.psd` are plain ol' copyright.
All photos & image assets under `./content/media`, `./src/images`, and `assets sheet.psd` are plain ol' copyright.
Copyright (c) 20082017 Matthias Kretschmann
Copyright (c) 20082018 Matthias Kretschmann
Don't care if you fork & play with it, but you're not allowed to publish
anything from it as a whole without my written permission.

View File

@ -1,15 +1,18 @@
# blog
> [kremalicious.com](http://kremalicious.com) built with [Gatsby](http://gatsbyjs.org). Neat.
> My blog [kremalicious.com](http://kremalicious.com) built with [Gatsby](http://gatsbyjs.org). Neat.
[![Build Status](https://travis-ci.com/kremalicious/kremalicious3.svg?branch=master)](https://travis-ci.com/kremalicious/kremalicious3)
[![Maintainability](https://api.codeclimate.com/v1/badges/1b7f317ccca9a430ee59/maintainability)](https://codeclimate.com/github/kremalicious/kremalicious3/maintainability)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/22716f4e00d14df8991af76384193953)](https://www.codacy.com/app/kremalicious/kremalicious3)
[![Greenkeeper badge](https://badges.greenkeeper.io/kremalicious/kremalicious3.svg)](https://greenkeeper.io/)
## Requirements
You need to have the following tools installed on your development machine before moving on:
- [Node.js](http://nodejs.org/) & [npm](https://npmjs.org/)
- [Node.js](http://nodejs.org/)
- [npm](https://npmjs.org/)
## Get up and running
@ -18,7 +21,7 @@ You need to have the following tools installed on your development machine befor
Run the following command from the repository's root folder to install all dependencies.
```bash
npm install
npm i
```
### Development server
@ -35,21 +38,22 @@ npm run build
## Licenses
The MIT License (MIT)
except for:
### Posts
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0;" src="https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png" />
</a><br />
All post content under `_src/_posts` is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
</a>
All post content under `./content/posts` is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
### Photos & images
All photos & image assets under `_src/_media`, `_src/assets/img`, and `assets sheet.psd` are plain ol' copyright.
All photos & image assets under `./content/media`, `./src/images`, and `assets sheet.psd` are plain ol' copyright.
Copyright (c) 20082018 Matthias Kretschmann
Don't care if you fork & play with it, but you're not allowed to publish anything from it as a whole without my written permission.
### Everything else
The MIT License (MIT)

View File

@ -1,32 +0,0 @@
/* exported krlcMenu */
const krlcMenu = (() => { // eslint-disable-line no-unused-vars
const _config = {
thesite: document.getElementsByClassName('site')[0],
thelink: document.getElementsByClassName('menu-btn')[0],
thepop: document.getElementsByClassName('nav-popover')[0]
}
const _private = {
toggleMenu() {
_config.thelink.addEventListener('click', e => {
e.preventDefault()
// Toggle menu
_config.thesite.classList.toggle('has-menu-open')
// Dont close thepop when you click on thepop
_config.thepop.addEventListener('click', e => {
e.stopPropagation()
})
// And dont close thepop now
e.stopPropagation()
})
}
}
return {
init: _private.toggleMenu
}
})(); // eslint-disable-line semi

View File

@ -1,99 +0,0 @@
//
// Vex modals
//
/* global vex, fetch, ClipboardJS, QRious */
/* exported krlcModals */
/* eslint-disable spaced-comment */
//=require vex-js/dist/js/vex.combined.js
//=require clipboard/dist/clipboard.js
//=require qrious/dist/qrious.js
/* eslint-enable spaced-comment */
const krlcModals = (() => { // eslint-disable-line no-unused-vars
const _config = {
btcVexTriggers: document.querySelectorAll('.js-vex-btc')
}
let btcAddress
let ethAddress
const _private = {
getBtcAddress() {
const url = '/api/site.json'
fetch(url)
.then(res => res.json())
.then(data_ => {
btcAddress = data_[0].author.bitcoin
ethAddress = data_[0].author.ether
})
.catch(err => console.error(err))
return { btcAddress, ethAddress }
},
vexBtc() {
_config.btcVexTriggers.forEach(el => {
el.addEventListener('click', e => {
e.preventDefault()
vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin'
vex.dialog.buttons.YES.text = 'Close'
vex.open({ unsafeContent: `
<h3 class="vex__title">Say thanks</h3>
<div class="grid grid--full grid-medium--half grid--gutters">
<div class="grid__col">
<h4>Bitcoin</h4>
<canvas class="qr" id="qr-btc"></canvas>
<pre class="highlight"><code id="btcAddress" class="btcAddress nt" value="${btcAddress}">${btcAddress}</code><button class="btn" data-clipboard-target="#btcAddress" title="Copy to clipboard"><svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"><path d="M16 8v8H8v4h12V8h-4zm0-2h6v16H6v-6H0V0h16v6zM2 2v12h12V2H2z"></path></svg></button></pre>
</div>
<div class="grid__col">
<h4>Ethereum</h4>
<canvas class="qr" id="qr-eth"></canvas>
<pre class="highlight"><code id="ethAddress" class="ethAddress nt" value="${ethAddress}">${ethAddress}</code><button class="btn" data-clipboard-target="#ethAddress" title="Copy to clipboard"><svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22"><path d="M16 8v8H8v4h12V8h-4zm0-2h6v16H6v-6H0V0h16v6zM2 2v12h12V2H2z"></path></svg></button></pre>
</div>
</div>
`
})
// Generate QR codes
const qrBtc = new QRious({
element: document.getElementById('qr-btc'),
value: btcAddress
})
const qrEth = new QRious({
element: document.getElementById('qr-eth'),
value: ethAddress
})
const qrOptions = {
backgroundAlpha: 0,
foreground: '#6b7f88',
size: 160
}
qrBtc.set(qrOptions)
qrEth.set(qrOptions)
// Clipboard button
const clipboard = new ClipboardJS('.btn')
clipboard.on('success', e => {
e.trigger.classList.add('success')
e.clearSelection()
})
})
})
}
}
return {
init() {
_private.getBtcAddress()
_private.vexBtc()
}
}
})(); // eslint-disable-line semi

View File

@ -1,90 +0,0 @@
/* global SimpleJekyllSearch */
/* exported krlcSearch */
/* eslint-disable spaced-comment */
//=require simple-jekyll-search/dest/simple-jekyll-search.js
/* eslint-enable spaced-comment */
const krlcSearch = (() => { // eslint-disable-line no-unused-vars
const _config = {
searchlink: document.getElementsByClassName('search-btn')[0],
searcharea: document.getElementsByClassName('search-area')[0],
searchclose: document.getElementsByClassName('search-close')[0],
searchfield: document.getElementById('search-input'),
searchpop: document.getElementById('search-popover'),
searchresults: document.getElementById('search-results')
}
const _private = {
searchHide() {
// Revert all search elements
_config.searcharea.classList.remove('animation-slidedown')
_config.searcharea.classList.add('animation-bounceOutUp')
_config.searchpop.classList.add('hide')
document.body.classList.remove('has-search-open')
},
searchClose() {
_config.searchclose.addEventListener('click', e => {
e.preventDefault()
_private.searchHide()
// Empty search field
_config.searchfield.value = ''
_config.searchfield.blur()
})
},
searchShow() {
_config.searchlink.addEventListener('click', e => {
e.preventDefault()
// Show search field
_config.searcharea.classList.remove('is-ready', 'animation-bounceOutUp')
_config.searcharea.classList.add('is-ready', 'animation-slidedown')
document.body.classList.add('has-search-open')
_config.searchfield.focus()
SimpleJekyllSearch({ // eslint-disable-line new-cap
searchInput: _config.searchfield,
resultsContainer: _config.searchresults,
json: '/api/search.json',
searchResultTemplate: '<a class="search-link" href="{url}">{title}</a>',
fuzzy: false
})
// Hide menu too just in case
if (document.body.classList.contains('has-menu-open')) {
document.body.classList.remove('has-menu-open')
}
// Dont close thepop when click on thepop
_config.searchpop.addEventListener('click', e => {
e.stopPropagation()
})
// Dont close thepop when click on search field
_config.searchfield.addEventListener('click', e => {
e.stopPropagation()
})
// And dont close thepop now
e.stopPropagation()
})
// Show popup upon first keypress
_config.searchfield.addEventListener('keyup', () => {
_config.searchpop.classList.remove('hide')
})
// Listen for close icon
_private.searchClose()
}
}
return {
init: _private.searchShow
}
})(); // eslint-disable-line semi

View File

@ -1,82 +0,0 @@
const krlcAnalytics = (() => { // eslint-disable-line no-unused-vars
//
// Track Responsive Breakpoints
//
// stolen & adapted from
// http://philipwalton.com/articles/measuring-your-sites-responsive-breakpoint-usage/
//
const gaBreakpoints = () => {
// Do nothing in browsers that don't support `window.matchMedia`.
if (!window.matchMedia) {
return
}
// Prevent rapid breakpoint changes for all firing at once.
let timeout
const breakpoints = {
xxs: '(max-width: 479px)',
xs: '(min-width: 480px) and (max-width: 767px)',
sm: '(min-width: 768px) and (max-width: 991px)',
md: '(min-width: 992px) and (max-width: 1199px)',
lg: '(min-width: 1200px) and (max-width: 1599px)',
hg: '(min-width: 1600px)'
}
Object.keys(breakpoints).forEach(breakpoint => {
const mql = window.matchMedia(breakpoints[breakpoint])
// Set the initial breakpoint on page load.
if (mql.matches) {
window.ga('set', 'dimension1', breakpoint)
}
// Update the breakpoint as the matched media changes
mql.addListener(() => {
if (mql.matches) {
clearTimeout(timeout)
timeout = setTimeout(() => {
window.ga('set', 'dimension1', breakpoint)
}, 1000)
}
})
})
}
//
// Track Viewport
//
const gaViewport = () => {
const width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
const height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
const dimensions = width + 'x' + height
window.ga('set', 'dimension2', dimensions)
}
//
// Track Pixel Density
//
const gaPixelDensity = () => {
// Heads up!
// window.devicePixelRatio doesn't work correctly in IE but whatever
const pixeldensity = window.devicePixelRatio
window.ga('set', 'dimension3', pixeldensity)
}
return {
init() {
const dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack
if (dnt !== 'yes' && dnt !== '1') {
gaBreakpoints()
gaViewport()
gaPixelDensity()
}
}
}
})(); // eslint-disable-line semi

View File

@ -1,17 +0,0 @@
/* global krlcMenu, krlcSearch, krlcModals */
/* eslint-disable spaced-comment */
//=require @webcomponents/webcomponentsjs/webcomponents-bundle.js
//=require time-elements/dist/time-elements.js
//=include _menu.js
//=include _search.js
//=include _modals.js
/* eslint-enable spaced-comment */
//
// Init js modules
//
krlcSearch.init()
krlcMenu.init()
krlcModals.init()

View File

@ -1,14 +0,0 @@
- name: brand-dark
hex: '015565'
- name: brand-light
hex: 'e7eef4'
- name: brand-cyan
hex: '3a9085'
- name: brand-grey
hex: '6b7f88'
- name: brand-grey-light
hex: '96a6ad'
- name: brand-grey-dimmed
hex: 'D8E0E5'

View File

@ -1,23 +0,0 @@
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : {{ post.title | titlecase | jsonify }},
"excerpt" : {{ post.excerpt | jsonify }},
"category" : "{{ post.categories | join: ', ' }}",
"tag" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.url }}{{ post.url }}",
"date" : "{{ post.date }}",
"content" : {{ post.content | jsonify }},
"image" : "{{ post.image }}",
"author" : "{{ post.author }}",
"layout" : "{{ post.layout }}",
"id" : "{{ post.id }}",
"path" : "{{ post.path }}",
"download" : "{{ post.download }}",
"linkurl" : "{{ post.linkurl }}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]

View File

@ -1,18 +0,0 @@
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : "{{ post.title | strip_html | strip_newlines | titlecase }}",
"excerpt" : "{{ post.excerpt | strip_html | strip_newlines }}",
"category" : "{{ post.categories | join: ', ' }}",
"tag" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.url }}{{ post.url }}",
"date" : "{{ post.date }}",
"image" : "{{ post.image }}",
"content" : "{{ post.content | strip_html | strip_newlines | xml_escape }}",
"linkurl" : "{{ post.linkurl }}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]

View File

@ -1,13 +0,0 @@
---
---
[
{
"name" : "{{ site.name }}",
"description" : "{{ site.description | xml_escape }}",
"url" : "{{ site.url }}",
"author" : {
{% for item in site.author %}"{{ item[0] }}": "{{ item[1] }}"{% unless forloop.last %},{% endunless %}
{% endfor %}
}
}
]

View File

@ -1,30 +0,0 @@
---
layout: base
front_page: true
redirect_from:
- /blog/
- /topics/howto-and-tutorial/
- /howto-and-tutorial/
- /most-popular-stuff-on-kremaliciouscom-in-2008/
- /canon-eos-50d-officially-announced-and-new-lens/
---
{% if paginator.next_page == 2 %}
{% include featured.html %}
{% endif %}
<section role="main" id="main">
{% if paginator.previous_page %}
<h1 class="paginator-title">Page {{ paginator.page }}</h1>
{% endif %}
{% for post in paginator.posts %}
{% include articles.html %}
{% endfor %}
</section>
{% include paginator.html %}

View File

@ -1,24 +0,0 @@
---
layout: base
title: tags
---
<section role="main" id="main" class="page-single">
<article class="hentry">
<h1 class="page-title">Tags</h1>
<section class="tagcloud">
{% for tag in site.tags %}
<span style="font-size: {{ tag | last | size | times: 500 | divided_by: site.tags.size | plus: 70 }}%">
<a class="tagcloud__tag" href="/tag/{{ tag | first | slugize }}/">
{{ tag | first }}
</a>
</span>
{% endfor %}
</section>
</article>
</section>

View File

@ -1,6 +1,4 @@
exports.onInitialClientRender = () => {
require('./src/styles/base.scss')
}
require('./src/styles/global.scss')
exports.onClientEntry = () => {
// IntersectionObserver polyfill for gatsby-image (Safari, IE)

View File

@ -22,13 +22,11 @@
"last 3 versions"
],
"dependencies": {
"clipboard": "^2.0.1",
"exif-js": "^2.3.0",
"gatsby": "^2.0.0-rc.0",
"gatsby-image": "^2.0.0-rc.0",
"gatsby-plugin-catch-links": "^2.0.2-rc.0",
"gatsby-plugin-lunr": "^1.1.0",
"gatsby-plugin-matomo": "^0.4.1",
"gatsby-plugin-matomo": "^0.5.0",
"gatsby-plugin-react-helmet": "^3.0.0-rc.0",
"gatsby-plugin-sass": "^2.0.0-rc.0",
"gatsby-plugin-sharp": "^2.0.0-rc.0",
@ -44,10 +42,9 @@
"gatsby-transformer-yaml": "^2.1.1-rc.0",
"graphql": "^0.13.2",
"intersection-observer": "^0.5.0",
"node-sass": "^4.9.2",
"node-sass": "^4.9.3",
"nord": "^0.2.1",
"prismjs": "^1.15.0",
"qrious": "^4.0.2",
"react": "^16.4.2",
"react-clipboard.js": "^2.0.0",
"react-dom": "^16.4.2",
@ -56,19 +53,18 @@
"react-qr-svg": "^2.1.0",
"react-time": "^4.3.0",
"react-transition-group": "^2.4.0",
"slugify": "^1.3.1",
"vex-js": "^4.1.0"
"slugify": "^1.3.1"
},
"devDependencies": {
"@svgr/cli": "^2.2.0",
"babel-eslint": "^8.2.6",
"babel-eslint": "^9.0.0",
"eslint": "^5.4.0",
"eslint-config-prettier": "^2.10.0",
"eslint-config-prettier": "^3.0.1",
"eslint-loader": "^2.1.0",
"eslint-plugin-graphql": "^2.1.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-react": "^7.11.1",
"prettier": "^1.14.1",
"prettier": "^1.14.2",
"prettier-stylelint": "^0.4.2",
"stylelint": "^9.5.0",
"stylelint-config-css-modules": "^1.3.0",