23 changed files with 441 additions and 36 deletions
@ -0,0 +1,6 @@ |
|||||
|
import requests |
||||
|
|
||||
|
from json import loads |
||||
|
|
||||
|
def getProjects(): |
||||
|
return loads(requests.get("https://api.github.com/users/nisstyre56/repos?sort=updated&direction=desc").content) |
@ -0,0 +1,90 @@ |
|||||
|
<app> |
||||
|
<ul class="navigate tab tab-block"> |
||||
|
<li class={"tab-item animated fadeIn " + (this.active.projects ? "active" : "")}> |
||||
|
<a onclick={to("projects")} href="#">Projects</a> |
||||
|
</li> |
||||
|
<li class={"tab-item " + (this.active.posts ? "active" : "")}> |
||||
|
<a onclick={to("posts")} href="#">Posts</a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
<div class="content"> |
||||
|
<loading if={!this.state.loaded}></loading> |
||||
|
<projectsview |
||||
|
if={this.active.projects} |
||||
|
state={this.state} |
||||
|
ref="projectsview" |
||||
|
> |
||||
|
</projectsview> |
||||
|
<postsview |
||||
|
if={this.active.posts} |
||||
|
ref="postsview" |
||||
|
> |
||||
|
</postsview> |
||||
|
</div> |
||||
|
<script> |
||||
|
import './projectsview.tag'; |
||||
|
import './postsview.tag'; |
||||
|
import './loading.tag'; |
||||
|
import Z from './zipper.js'; |
||||
|
|
||||
|
import route from 'riot-route'; |
||||
|
this.route = route; |
||||
|
this.riot = riot; |
||||
|
|
||||
|
this.state = { |
||||
|
"projects" : Z.empty, |
||||
|
"loaded" : false |
||||
|
}; |
||||
|
|
||||
|
this.active = { |
||||
|
"projects" : false, |
||||
|
"posts" : false |
||||
|
}; |
||||
|
|
||||
|
var self = this; |
||||
|
|
||||
|
this.route("posts", |
||||
|
function() { |
||||
|
self.active.posts = true; |
||||
|
self.active.projects = false; |
||||
|
self.update(); |
||||
|
}); |
||||
|
|
||||
|
this.route("projects", |
||||
|
function() { |
||||
|
self.active.projects = true; |
||||
|
self.active.posts = false; |
||||
|
self.update(); |
||||
|
}); |
||||
|
|
||||
|
to(name) { |
||||
|
return (function(e) { |
||||
|
e.preventDefault(); |
||||
|
this.route(name); |
||||
|
return; |
||||
|
}).bind(this); |
||||
|
} |
||||
|
|
||||
|
this.on("mount", () => { |
||||
|
route("/", () => { route("/post/1") }); |
||||
|
route("/post/*", this.setPost); |
||||
|
route.start(true); |
||||
|
}); |
||||
|
|
||||
|
function loaduser() { |
||||
|
/* https://api.github.com/users/${self.username}/repos?sort=updated&direction=desc */ |
||||
|
axios.get(`/blog/projects`) |
||||
|
.then(function(resp) { |
||||
|
self.state.projects = Z.fromList(resp.data); |
||||
|
self.state.loaded = true; |
||||
|
if (!self.active.posts) { |
||||
|
self.active.projects = true; |
||||
|
} |
||||
|
self.update(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
this.on("mount", loaduser); |
||||
|
|
||||
|
</script> |
||||
|
</app> |
@ -0,0 +1,5 @@ |
|||||
|
<column> |
||||
|
<div class={"column " + this.opts.width}> |
||||
|
<yield/> |
||||
|
</div> |
||||
|
</column> |
@ -0,0 +1,15 @@ |
|||||
|
import './grid.tag'; |
||||
|
import './row.tag'; |
||||
|
import './column.tag'; |
||||
|
import { default as R } from 'ramda'; |
||||
|
|
||||
|
function chunk(n, xs) { |
||||
|
/* Chunk a list into groups of n size */ |
||||
|
return R.unfold( |
||||
|
(xs) => { |
||||
|
if (R.length(xs) > 0) { |
||||
|
return [{"row" : R.take(n, xs)}, R.drop(n, xs)]; |
||||
|
} |
||||
|
return false; |
||||
|
}, xs); |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<grid> |
||||
|
<div class="container"> |
||||
|
<yield/> |
||||
|
</div> |
||||
|
</grid> |
@ -0,0 +1,3 @@ |
|||||
|
<loading> |
||||
|
<div class="loading"></div> |
||||
|
</loading> |
@ -0,0 +1,7 @@ |
|||||
|
<post-content> |
||||
|
<h4>{ this.opts.title }</h4> |
||||
|
<h5>Posted by { this.opts.author }</h5> |
||||
|
<p class="post-content centered text-break"> |
||||
|
{ this.opts.content } |
||||
|
</p> |
||||
|
</post-content> |
@ -0,0 +1,5 @@ |
|||||
|
<postsview> |
||||
|
<posts> |
||||
|
<post pid={1}></post> |
||||
|
</posts> |
||||
|
</postsview> |
@ -0,0 +1,99 @@ |
|||||
|
<projects> |
||||
|
<div class="content-box"> |
||||
|
<h3>Projects for { this.username }</h3> |
||||
|
<div |
||||
|
class="text-break" |
||||
|
> |
||||
|
<div if={this.swipe} class={`card animated ${this.transition}`}> |
||||
|
<div class="card-header"> |
||||
|
<h4 class="card-title">{ this.project().name }</h4> |
||||
|
</div> |
||||
|
<div class="card-body"> |
||||
|
<a |
||||
|
target="_blank" |
||||
|
href={this.project().html_url}> |
||||
|
See on github |
||||
|
</a> |
||||
|
<p>{ this.project().description }</p> |
||||
|
<p>{ this.project().language }</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="controls container"> |
||||
|
<div class="columns"> |
||||
|
<div class="column col-6"> |
||||
|
<button |
||||
|
onclick={this.prev} |
||||
|
class="btn btn-lg nav-button float-right" |
||||
|
> |
||||
|
<i class="fa fa-arrow-left" aria-hidden="true"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
<div class="column col-6"> |
||||
|
<button |
||||
|
onclick={this.next} |
||||
|
class="btn btn-lg nav-button float-left" |
||||
|
> |
||||
|
<i class="fa fa-arrow-right" aria-hidden="true"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<script> |
||||
|
import Z from './zipper.js'; |
||||
|
|
||||
|
var cycle_timeout = 12; |
||||
|
|
||||
|
this.username = "Wes"; |
||||
|
|
||||
|
var self = this; |
||||
|
|
||||
|
self.transition = ""; |
||||
|
self.swipe = true; |
||||
|
|
||||
|
var empty_project = { |
||||
|
"name" : "", |
||||
|
"html_url": "", |
||||
|
"description" : "", |
||||
|
"language": "" |
||||
|
}; |
||||
|
|
||||
|
project() { |
||||
|
return Z.focus(self.opts.state.projects, empty_project); |
||||
|
} |
||||
|
|
||||
|
next() { |
||||
|
self.update({"swipe" : false}); |
||||
|
self.opts.state.projects = Z.goRight(self.opts.state.projects); |
||||
|
self.update( |
||||
|
{ |
||||
|
"transition" : "fadeInRight", |
||||
|
"swipe" : true |
||||
|
} |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
prev() { |
||||
|
self.update({"swipe" : false}); |
||||
|
self.opts.state.projects = Z.goLeft(self.opts.state.projects); |
||||
|
self.update( |
||||
|
{ |
||||
|
"transition" : "fadeInLeft", |
||||
|
"swipe" : true |
||||
|
} |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
function loopProjects() { |
||||
|
if (self.opts.state.projects) { |
||||
|
self.next(); |
||||
|
} |
||||
|
window.setTimeout(loopProjects, cycle_timeout*1000); |
||||
|
} |
||||
|
|
||||
|
/* window.setTimeout(loopProjects, cycle_timeout*1000); */ |
||||
|
|
||||
|
</script> |
||||
|
</projects> |
@ -0,0 +1,3 @@ |
|||||
|
<projectsview> |
||||
|
<projects state={this.opts.state}></projects> |
||||
|
</projectsview> |
@ -0,0 +1,5 @@ |
|||||
|
<row> |
||||
|
<div class="columns"> |
||||
|
<yield/> |
||||
|
</div> |
||||
|
</row> |
@ -0,0 +1,55 @@ |
|||||
|
import im from 'immutable'; |
||||
|
|
||||
|
function Zipper(left, right) { |
||||
|
return { |
||||
|
"left" : left, |
||||
|
"right" : right |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
function fromList(xs) { |
||||
|
return Zipper(im.Stack(), im.Stack(xs)); |
||||
|
} |
||||
|
|
||||
|
function focus(z, def_val) { |
||||
|
var head = z.right.first(); |
||||
|
if (head) { |
||||
|
return head; |
||||
|
} |
||||
|
return def_val; |
||||
|
} |
||||
|
|
||||
|
function reset(z) { |
||||
|
return Zipper(im.Stack(), z.left.reverse().concat(z.right)); |
||||
|
} |
||||
|
|
||||
|
function swap(z) { |
||||
|
return Zipper(im.Stack(z.right.reverse().shift()), im.Stack([z.right.last()])); |
||||
|
} |
||||
|
|
||||
|
function goRight(z) { |
||||
|
if (z.right.size == 1) { |
||||
|
return reset(z); |
||||
|
} |
||||
|
return Zipper(z.left.unshift(z.right.first()), |
||||
|
z.right.shift()); |
||||
|
} |
||||
|
|
||||
|
function goLeft(z) { |
||||
|
if (z.left.size == 0) { |
||||
|
return swap(z); |
||||
|
} |
||||
|
return Zipper(z.left.shift(), |
||||
|
z.right.unshift(z.left.first())); |
||||
|
} |
||||
|
|
||||
|
var empty = fromList([]); |
||||
|
|
||||
|
export default { |
||||
|
"Zipper" : fromList, |
||||
|
"focus" : focus, |
||||
|
"goRight" : goRight, |
||||
|
"goLeft" : goLeft, |
||||
|
"empty" : empty, |
||||
|
"fromList" : fromList |
||||
|
}; |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@ |
|||||
|
.projects { |
||||
|
margin: 0 auto !important; |
||||
|
} |
||||
|
|
||||
|
.center { |
||||
|
margin: 0 auto !important; |
||||
|
} |
||||
|
|
||||
|
.title { |
||||
|
margin: 0 auto !important; |
||||
|
} |
||||
|
|
||||
|
.gh-username { |
||||
|
margin: 0 auto !important; |
||||
|
max-width: 75%; |
||||
|
} |
||||
|
|
||||
|
.controls { |
||||
|
margin: 0 auto !important; |
||||
|
} |
||||
|
|
||||
|
.nav-button { |
||||
|
margin: 0 auto; |
||||
|
display: block; |
||||
|
} |
File diff suppressed because one or more lines are too long
@ -1,21 +1,26 @@ |
|||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
<head> |
||||
|
<link rel="stylesheet" href="/blog/styles/spectre.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/riotblog.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/projects.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/animate.min.css"> |
||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
</head> |
||||
<header class="text-center nav navbar"> |
<header class="text-center nav navbar"> |
||||
<section class="centered page-top navbar-section"> |
<section class="centered page-top navbar-section"> |
||||
<h1 class="blog-title">yes</h1> |
<h1 class="blog-title">WK</h1> |
||||
</section> |
</section> |
||||
</header> |
</header> |
||||
|
|
||||
<html> |
<html> |
||||
<body> |
<body> |
||||
<posts> |
<app></app> |
||||
<post></post> |
|
||||
</posts> |
|
||||
<footer class="footer"> |
<footer class="footer"> |
||||
</footer> |
</footer> |
||||
|
|
||||
<link rel="stylesheet" href="/blog/styles/spectre.min.css"> |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
||||
<link rel="stylesheet" href="/blog/styles/riotblog.min.css"> |
|
||||
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script> |
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
|
@ -0,0 +1,26 @@ |
|||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
||||
|
<head> |
||||
|
<link rel="stylesheet" href="/blog/styles/spectre.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/riotblog.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/projects.min.css"> |
||||
|
<link rel="stylesheet" href="/blog/styles/animate.min.css"> |
||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
</head> |
||||
|
<header class="text-center nav navbar"> |
||||
|
<section class="centered page-top navbar-section"> |
||||
|
<h1 class="blog-title">hmmm</h1> |
||||
|
</section> |
||||
|
</header> |
||||
|
|
||||
|
<html> |
||||
|
<body> |
||||
|
<projects> |
||||
|
</projects> |
||||
|
<footer class="footer"> |
||||
|
</footer> |
||||
|
|
||||
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
||||
|
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script> |
||||
|
</body> |
||||
|
</html> |
Loading…
Reference in new issue