Migrate projects to the new site generator

This commit is contained in:
Sami Samhuri 2019-12-03 08:45:56 -08:00
parent 4e9c53a2f4
commit 27df7f899d
24 changed files with 140 additions and 167 deletions

View file

@ -43,13 +43,13 @@ Execution, trying TDD for the first time:
- [x] check and delete _data.json
- [ ] Migrate projects to the new site generator
- [x] Migrate projects to the new site generator
- [ ] Migrate projects page
- [x] Migrate projects page
- [ ] Migrate project page
- [x] Migrate project page
- [ ] Check and delete _data.json
- [x] Check and delete _data.json
- [ ] Migrate posts to markdown with headers somehow

60
projects.json Normal file
View file

@ -0,0 +1,60 @@
{
"projects": [
{
"title": "bin",
"description": "my collection of scripts in ~/bin"
},
{
"title": "config",
"description": "important dot files (zsh, emacs, vim, screen)"
},
{
"title": "compiler",
"description": "a compiler targeting x86 in Ruby"
},
{
"title": "lake",
"description": "a simple implementation of Scheme in C"
},
{
"title": "strftime",
"description": "strftime for JavaScript"
},
{
"title": "format",
"description": "printf for JavaScript"
},
{
"title": "gitter",
"description": "a GitHub client for Node (v3 API)"
},
{
"title": "mojo.el",
"description": "turn emacs into a sweet mojo editor"
},
{
"title": "ThePusher",
"description": "Github post-receive hook router"
},
{
"title": "NorthWatcher",
"description": "cron for filesystem changes"
},
{
"title": "repl-edit",
"description": "edit Node repl commands with your text editor"
},
{
"title": "cheat.el",
"description": "cheat from emacs"
},
{
"title": "batteries",
"description": "a general purpose node library"
},
{
"title": "samhuri.net",
"description": "this site"
}
]
}

View file

@ -354,10 +354,13 @@ ul.archive {
.project-listing {
margin-bottom: 1rem;
h4, p {
margin: 0.5rem 0;
h4 {
margin: 0.5rem 0 1rem;
}
p {
margin: 0.5rem 0 2rem;
}
}
.project-stats {
@ -370,10 +373,8 @@ ul.archive {
}
body.projects:not(.index) .container {
/* FIXME: find out where this is used and do it differently ... this selector sucks */
body { background-color: red; }
h2, h4 {
article.project {
h1, h4 {
text-align: center;
}
}

View file

@ -1,12 +1,14 @@
;(function() {
if (SJS.projectName) {
SJS.ready(initProject)
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', initProject, false)
} else if (window.attachEvent) {
window.attachEvent('onload', initProject)
}
function initProject() {
var data = createObjectStore(SJS.projectName)
var projectName = document.getElementById('project').dataset.title
var data = createObjectStore(projectName)
function html(id, h) {
document.getElementById(id).innerHTML = h
@ -63,11 +65,10 @@
var Months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ')
var t = data.get('t-' + SJS.projectName)
var t = data.get('t-' + projectName)
if (!t || +new Date() - t > 3600 * 1000) {
console.log('stale ' + String(t))
data.set('t-' + SJS.projectName, +new Date())
var repo = GITR.repo('samsonjs', SJS.projectName)
data.set('t-' + projectName, +new Date())
var repo = GITR.repo('samsonjs', projectName)
repo
.fetch(function(err, repo) {
if (err) {
@ -102,13 +103,13 @@
})
} else {
try {
updateBranches(SJS.projectName, data.get('branches'))
updateBranches(projectName, data.get('branches'))
updateLangs(data.get('langs'))
updateContributors(data.get('contributors'))
updateStars(data.get('stars').length)
updateN('fork', data.get('forks').length)
} catch (e) {
data.set('t-' + SJS.projectName, null)
data.set('t-' + projectName, null)
initProject()
}
}

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1,82 +0,0 @@
{
"_scripts": [
"https://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js",
"/js/gitter.js",
"/js/store.js",
"/js/projects.js"
],
"index": {
"title": "Projects"
},
"strftime": {
"title": "strftime",
"description": "strftime for JavaScript"
},
"bin": {
"title": "bin",
"description": "~/bin"
},
"compiler": {
"title": "compiler",
"description": "a compiler targeting x86 in Ruby"
},
"config": {
"title": "config",
"description": "important dot files (zsh, emacs, vim, screen)"
},
"format": {
"title": "format",
"description": "printf for JavaScript"
},
"gitter": {
"title": "gitter",
"description": "a GitHub client for Node (v3 API)"
},
"samhuri.net": {
"title": "samhuri.net",
"description": "this site"
},
"samhuri": {
"hidden": true,
"title": "samhuri.net",
"description": "this site"
},
"ThePusher": {
"title": "ThePusher",
"description": "Github post-receive hook router"
},
"lake": {
"title": "lake",
"description": "A simple implementation of Scheme in C"
},
"mojo.el": {
"title": "mojo.el",
"description": "turn emacs into a sweet mojo editor"
},
"mojo": {
"hidden": true,
"title": "mojo.el",
"description": "turn emacs into a sweet mojo editor"
},
"NorthWatcher": {
"title": "NorthWatcher",
"description": "cron for filesystem changes"
},
"batteries": {
"title": "batteries",
"description": "a general purpose node library"
},
"repl-edit": {
"title": "repl-edit",
"description": "edit Node repl commands with your text editor"
},
"cheat.el": {
"title": "cheat.el",
"description": "cheat from emacs"
},
"cheat": {
"hidden": true,
"title": "cheat.el",
"description": "cheat from emacs"
}
}

View file

@ -1,31 +0,0 @@
<h4><%= description %></h4>
<div class="project-stats">
<p>
<a href="https://github.com/samsonjs/<%= title %>">GitHub</a>
&bull;
<a id="nstar" href="https://github.com/samsonjs/<%= title %>/stargazers"></a>
&bull;
<a id="nfork" href="https://github.com/samsonjs/<%= title %>/network/members"></a>
</p>
<p>
Last updated on <span id="updated"></span>
</p>
</div>
<div class="project-info row clearfix">
<div class="column half">
<h3>Contributors</h3>
<div id="contributors"></div>
</div>
<div class="column half">
<h3>Languages</h3>
<div id="langs"></div>
</div>
</div>
<script>
SJS.projectName = '<%= title %>'
</script>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1,8 +0,0 @@
<% for (var name in public.projects._data) { %>
<% var project = public.projects._data[name] %>
<% if (name == 'index' || name[0] == '_' || project.hidden) continue %>
<div class="project-listing">
<h4><a href="/projects/<%= name %>"><%= name %></a></h4>
<p class="description"><%= project.description %></p>
</div>
<% } %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

View file

@ -1 +0,0 @@
<%- partial('_project') %>

42
templates/project.html Normal file
View file

@ -0,0 +1,42 @@
{% extends "samhuri.net.html" %}
{% block body %}
<article class="container project">
<!-- projects.js picks up this data-title attribute and uses it to render all the Github stuff -->
<h1 id="project" data-title="{{ project.title }}">{{ project.title }}</h1>
<h4>{{ project.description }}</h4>
<div class="project-stats">
<p>
<a href="https://github.com/samsonjs/{{ project.title }}">GitHub</a>
&bull;
<a id="nstar" href="https://github.com/samsonjs/{{ project.title }}/stargazers"></a>
&bull;
<a id="nfork" href="https://github.com/samsonjs/{{ project.title }}/network/members"></a>
</p>
<p>
Last updated on <span id="updated"></span>
</p>
</div>
<div class="project-info row clearfix">
<div class="column half">
<h3>Contributors</h3>
<div id="contributors"></div>
</div>
<div class="column half">
<h3>Languages</h3>
<div id="langs"></div>
</div>
</div>
</article>
<div class="row clearfix">
<p class="fin"><i class="fa fa-code"></i></p>
</div>
<script defer src="https://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script>
<script defer src="/js/gitter.js"></script>
<script defer src="/js/store.js"></script>
<script defer src="/js/projects.js"></script>
{% endblock %}

16
templates/projects.html Normal file
View file

@ -0,0 +1,16 @@
{% extends "samhuri.net.html" %}
{% block body %}
<article class="container">
<h1>Projects</h1>
{% for project in projects %}
<div class="project-listing">
<h4><a href="{{ project.path }}">{{ project.title }}</a></h4>
<p class="description">{{ project.description }}</p>
</div>
{% endfor %}
</article>
<div class="row clearfix">
<p class="fin"><i class="fa fa-code"></i></p>
</div>
{% endblock %}

View file

@ -29,18 +29,6 @@
<link rel="dns-prefetch" href="https://use.typekit.net">
<script src="https://use.typekit.net/tcm1whv.js" crossorigin="anonymous"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<script>
window.SJS = {
ready: function(fn) {
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fn, false)
} else if (window.attachEvent) {
window.attachEvent('onload', fn)
}
}
}
</script>
</head>
{% if bodyClassNames %}