Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Erick Hitter
eth-landing-page
Commits
557aeb70
Verified
Commit
557aeb70
authored
Dec 25, 2016
by
Erick Hitter
Browse files
Insert render latest post into document
parent
1fc35843
Changes
6
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
557aeb70
...
...
@@ -25,11 +25,12 @@ app.get( '/', function( req, res ) {
res
.
render
(
'
index
'
,
{
data
:
{
domains
:
domains
}
}
);
}
);
//
Get some data
//
API requests require a domain
app
.
get
(
'
/api
'
,
function
(
req
,
res
)
{
res
.
status
(
400
).
json
(
{
error
:
'
Must specify a domain!
'
}
);
}
);
// Render the domain's latest post
app
.
get
(
'
/api/:domain
'
,
function
(
req
,
res
)
{
// For convenience
var
domain
=
req
.
params
.
domain
;
...
...
@@ -61,6 +62,9 @@ app.get( '/api/:domain', function( req, res ) {
}
);
}
);
// Allow access to scripts
app
.
use
(
express
.
static
(
'
public
'
)
);
// Listen on some random, unused port
// App is meant to be fronted by nginx
app
.
listen
(
5060
,
function
()
{
...
...
public/css/main.css
0 → 100644
View file @
557aeb70
.sharedaddy
{
display
:
none
;
}
public/js/main.js
0 → 100644
View file @
557aeb70
(
function
(
$
)
{
$
(
'
div.site-container
'
).
each
(
function
(
i
,
site
)
{
var
container
=
$
(
this
),
domain
=
container
.
data
(
'
domain
'
);
$
.
get
(
{
url
:
'
/api/
'
+
domain
,
success
:
function
(
data
,
status
)
{
$
(
'
.latest-post
'
,
container
).
html
(
data
);
}
}
);
}
);
}
)
(
jQuery
);
render/partials/post.handlebars
View file @
557aeb70
<h3><a
href=
"
{{
data
.
post
.
link
}}
"
>
{{
data
.
post
.
title
.
rendered
}}
</a></h3>
<h3><a
href=
"
{{
data
.
post
.
link
}}
"
>
{{
{
data
.
post
.
title
.
rendered
}}
}
</a></h3>
{{{
data
.
post
.
excerpt
.
rendered
}}}
<p><a
href=
"
{{
data
.
post
.
link
}}
"
>
Read at
{{
data
.
domain
}}
→
</a></p>
<p><a
href=
"
{{
data
.
post
.
link
}}
"
>
Read at
{{
data
.
domain
}}
→
</a></p>
render/partials/sites.handlebars
View file @
557aeb70
{{#
each
data
.
domains
}}
<div
class=
"site-container"
id=
"site-
{{
@key
}}
"
>
<div
class=
"site-container"
id=
"site-
{{
@key
}}
"
data-domain=
"
{{
@key
}}
"
>
<h2><a
href=
"
{{
this
}}
"
>
{{
this
}}
</a></h2>
<span
class=
"latest-post"
>
Loading
…
</span>
</div>
...
...
render/templates/main.handlebars
View file @
557aeb70
...
...
@@ -2,6 +2,10 @@
<html>
<head>
<title>
erick t. hitter's latest posts
</title>
<script
src=
"https://s2.e15r.co/wp-includes/js/jquery/jquery.js"
></script>
<link
rel=
"stylesheet"
href=
"css/main.css"
/>
</head>
<body>
{{{
body
}}}
...
...
@@ -10,6 +14,8 @@
{{>
sites
}}
</div>
<script
src=
"js/main.js"
></script>
{{>
analytics
}}
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment