Compare commits
34 Commits
fix/modern
...
master
Author | SHA1 | Date |
---|---|---|
Cadey Ratio | 5dbc8ec9e8 | |
David Wildasin | af16ab4579 | |
David Wildasin | e6c637ea1e | |
David Wildasin | f6f09b643f | |
Cadey Ratio | 0578315e7e | |
Cadey Ratio | f360f39933 | |
David Wildasin | 723ad49e83 | |
David Wildasin | 7c7446a6d7 | |
Cadey Ratio | e25592d5d7 | |
Cadey Ratio | c27a7e6d5f | |
Cadey Ratio | 4685252143 | |
Cadey Ratio | 7972261464 | |
Cadey Ratio | f59ef1ff1f | |
Cadey Ratio | 6af4b84be6 | |
Cadey Ratio | 7adcf97746 | |
Cadey Ratio | ca8f498af4 | |
Cadey Ratio | 8ec3967a01 | |
Cadey Ratio | 884da8cc78 | |
Cadey Ratio | 36cd059810 | |
Cadey Ratio | 9cf4501c1b | |
Cadey Ratio | a020f0cede | |
Cadey Ratio | 832914c5ea | |
David Wildasin | bff074ea6a | |
Cadey Ratio | 62763a0864 | |
David Wildasin | 8aa34cd692 | |
Cadey Ratio | 163578ce8c | |
Cadey Ratio | a669ee2018 | |
Cadey Ratio | fac0d25655 | |
Toni Kaija | fbb8b7a48d | |
Cadey Ratio | 9996db4179 | |
MKody | 99738d11b1 | |
Cadey Ratio | 29430a1814 | |
MKody | 51a1fae0d3 | |
Cadey Ratio | 3a9314f8ca |
|
@ -0,0 +1,21 @@
|
||||||
|
build:
|
||||||
|
image: xena/nim:0.14.2
|
||||||
|
commands:
|
||||||
|
- nimble refresh
|
||||||
|
- yes | nimble install
|
||||||
|
- cd client/nim
|
||||||
|
- sh ./test.sh
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
git_push:
|
||||||
|
branch: master
|
||||||
|
remote: git@github.com:Xe/PonyAPI.git
|
||||||
|
|
||||||
|
ssh:
|
||||||
|
host: greedo.xeserv.us
|
||||||
|
user: xena
|
||||||
|
port: 22
|
||||||
|
commands:
|
||||||
|
- cd ~/code/ponyapi
|
||||||
|
- docker-compose build
|
||||||
|
- docker-compose up -d
|
10
Dockerfile
10
Dockerfile
|
@ -1,17 +1,15 @@
|
||||||
FROM coopernurse/docker-nim
|
FROM xena/nim:0.15.0
|
||||||
|
|
||||||
RUN apk update && apk add bash
|
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
RUN adduser -D -g '' r
|
RUN adduser -D -g '' r
|
||||||
RUN chmod a+x /opt/Nim/bin/nim
|
|
||||||
|
|
||||||
ADD . /app
|
ADD . /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN nimble update &&\
|
RUN nimble update &&\
|
||||||
|
yes | nimble build &&\
|
||||||
yes | nimble install &&\
|
yes | nimble install &&\
|
||||||
nim c -d:release --deadCodeElim:on ponyapi
|
cp ~/.nimble/bin/ponyapi /usr/bin/ponyapi
|
||||||
|
|
||||||
USER r
|
USER r
|
||||||
CMD ./ponyapi
|
CMD /usr/bin/ponyapi
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
PonyAPI
|
PonyAPI
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
[![Build Status](http://drone.greedo.xeserv.us/api/badges/xena/PonyAPI/status.svg)](http://drone.greedo.xeserv.us/xena/PonyAPI)
|
||||||
|
|
||||||
A simple API for episodes of My Little Pony: Friendship is Magic to be run
|
A simple API for episodes of My Little Pony: Friendship is Magic to be run
|
||||||
inside a container.
|
inside a container.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
ponyapi:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "6452:5000"
|
||||||
|
restart: always
|
54
fim.list
54
fim.list
|
@ -1,7 +1,7 @@
|
||||||
FIM 1286735400 1 1 Friendship is Magic Part 1
|
FIM 1286731800 1 1 Friendship is Magic Part 1
|
||||||
FIM 1287772200 1 2 Friendship is Magic Part 2
|
FIM 1287768600 1 2 Friendship is Magic Part 2
|
||||||
FIM 1288377000 1 3 The Ticket Master
|
FIM 1288373400 1 3 The Ticket Master
|
||||||
FIM 1288981800 1 4 Applebuck Season
|
FIM 1288978200 1 4 Applebuck Season
|
||||||
FIM 1289586600 1 5 Griffon the Brush Off
|
FIM 1289586600 1 5 Griffon the Brush Off
|
||||||
FIM 1290191400 1 6 Boast Busters
|
FIM 1290191400 1 6 Boast Busters
|
||||||
FIM 1290796200 1 7 Dragonshy
|
FIM 1290796200 1 7 Dragonshy
|
||||||
|
@ -17,13 +17,13 @@ FIM 1298053800 1 16 Sonic Rainboom
|
||||||
FIM 1298658600 1 17 Stare Master
|
FIM 1298658600 1 17 Stare Master
|
||||||
FIM 1299263400 1 18 The Show Stoppers
|
FIM 1299263400 1 18 The Show Stoppers
|
||||||
FIM 1299868200 1 19 A Dog and Pony Show
|
FIM 1299868200 1 19 A Dog and Pony Show
|
||||||
FIM 1300473000 1 20 Green Isn't Your Color
|
FIM 1300469400 1 20 Green Isn't Your Color
|
||||||
FIM 1301077800 1 21 Over a Barrel
|
FIM 1301074200 1 21 Over a Barrel
|
||||||
FIM 1302287400 1 22 A Bird in the Hoof
|
FIM 1302283800 1 22 A Bird in the Hoof
|
||||||
FIM 1302892200 1 23 The Cutie Mark Chronicles
|
FIM 1302888600 1 23 The Cutie Mark Chronicles
|
||||||
FIM 1303497000 1 24 Owl's Well That Ends Well
|
FIM 1303493400 1 24 Owl's Well That Ends Well
|
||||||
FIM 1304101800 1 25 Party of One
|
FIM 1304098200 1 25 Party of One
|
||||||
FIM 1304706600 1 26 The Best Night Ever
|
FIM 1304703000 1 26 The Best Night Ever
|
||||||
FIM 1316264400 2 1 The Return of Harmony Part 1
|
FIM 1316264400 2 1 The Return of Harmony Part 1
|
||||||
FIM 1316869200 2 2 The Return of Harmony Part 2
|
FIM 1316869200 2 2 The Return of Harmony Part 2
|
||||||
FIM 1318683600 2 3 Lesson Zero
|
FIM 1318683600 2 3 Lesson Zero
|
||||||
|
@ -57,10 +57,10 @@ FIM 1353771000 3 4 One Bad Apple
|
||||||
FIM 1354375800 3 5 Magic Duel
|
FIM 1354375800 3 5 Magic Duel
|
||||||
FIM 1354980600 3 6 Sleepless in Ponyville
|
FIM 1354980600 3 6 Sleepless in Ponyville
|
||||||
FIM 1355585400 3 7 Wonderbolt Academy
|
FIM 1355585400 3 7 Wonderbolt Academy
|
||||||
FIM 1356190200 3 9 Apple Family Reunion
|
FIM 1356190200 3 8 Apple Family Reunion
|
||||||
FIM 1356795000 3 10 Spike at Your Service
|
FIM 1356795000 3 9 Spike at Your Service
|
||||||
FIM 1358609400 3 11 Keep Calm and Flutter On
|
FIM 1358609400 3 10 Keep Calm and Flutter On
|
||||||
FIM 1359214200 3 8 Just for Sidekicks
|
FIM 1359214200 3 11 Just for Sidekicks
|
||||||
FIM 1360423800 3 12 Games Ponies Play
|
FIM 1360423800 3 12 Games Ponies Play
|
||||||
FIM 1361028600 3 13 Magical Mystery Cure
|
FIM 1361028600 3 13 Magical Mystery Cure
|
||||||
FIM 1385218800 4 1 Princess Twilight Sparkle - Part 1
|
FIM 1385218800 4 1 Princess Twilight Sparkle - Part 1
|
||||||
|
@ -71,8 +71,8 @@ FIM 1387035000 4 5 Flight to the Finish
|
||||||
FIM 1387639800 4 6 Power Ponies
|
FIM 1387639800 4 6 Power Ponies
|
||||||
FIM 1388244600 4 7 Bats!
|
FIM 1388244600 4 7 Bats!
|
||||||
FIM 1388849400 4 8 Rarity Takes Manehattan
|
FIM 1388849400 4 8 Rarity Takes Manehattan
|
||||||
FIM 1390059000 4 10 Rainbow Falls
|
|
||||||
FIM 1389454200 4 9 Pinkie Apple Pie
|
FIM 1389454200 4 9 Pinkie Apple Pie
|
||||||
|
FIM 1390059000 4 10 Rainbow Falls
|
||||||
FIM 1390663800 4 11 Three's a Crowd
|
FIM 1390663800 4 11 Three's a Crowd
|
||||||
FIM 1391268600 4 12 Pinkie Pride
|
FIM 1391268600 4 12 Pinkie Pride
|
||||||
FIM 1391873400 4 13 Simple Ways
|
FIM 1391873400 4 13 Simple Ways
|
||||||
|
@ -89,9 +89,9 @@ FIM 1398522600 4 23 Inspiration Manifestation
|
||||||
FIM 1399127400 4 24 Equestria Games
|
FIM 1399127400 4 24 Equestria Games
|
||||||
FIM 1399730400 4 25 Twilight's Kingdom - Part 1
|
FIM 1399730400 4 25 Twilight's Kingdom - Part 1
|
||||||
FIM 1399732200 4 26 Twilight's Kingdom - Part 2
|
FIM 1399732200 4 26 Twilight's Kingdom - Part 2
|
||||||
FIM 1428768000 5 3 Castle Sweet Castle
|
|
||||||
FIM 1428159600 5 1 The Cutie Map Part 1
|
FIM 1428159600 5 1 The Cutie Map Part 1
|
||||||
FIM 1428161400 5 2 The Cutie Map Part 2
|
FIM 1428161400 5 2 The Cutie Map Part 2
|
||||||
|
FIM 1428766200 5 3 Castle Sweet Castle
|
||||||
FIM 1429371000 5 4 Bloom and Gloom
|
FIM 1429371000 5 4 Bloom and Gloom
|
||||||
FIM 1429975800 5 5 Tanks for the Memories
|
FIM 1429975800 5 5 Tanks for the Memories
|
||||||
FIM 1430580600 5 6 Appleoosa's Most Wanted
|
FIM 1430580600 5 6 Appleoosa's Most Wanted
|
||||||
|
@ -121,6 +121,26 @@ FIM 1459611000 6 3 The Gift of the Maud Pie
|
||||||
FIM 1460215800 6 4 On Your Marks
|
FIM 1460215800 6 4 On Your Marks
|
||||||
FIM 1460820600 6 5 Gauntlet of Fire
|
FIM 1460820600 6 5 Gauntlet of Fire
|
||||||
FIM 1462030200 6 6 No Second Prances
|
FIM 1462030200 6 6 No Second Prances
|
||||||
|
FIM 1462635000 6 7 Newbie Dash
|
||||||
|
FIM 1463239800 6 8 A Hearth's Warming Tail
|
||||||
|
FIM 1463844600 6 9 The Saddle Row Review
|
||||||
|
FIM 1464449400 6 10 Applejack's "Day" Off
|
||||||
|
FIM 1465054200 6 11 Flutter Brutter
|
||||||
|
FIM 1465659000 6 12 Spice Up Your Life
|
||||||
|
FIM 1469892600 6 13 Stranger Than Fan Fiction
|
||||||
|
FIM 1470497400 6 14 The Cart Before the Ponies
|
||||||
|
FIM 1471102200 6 15 28 Pranks Later
|
||||||
|
FIM 1471707000 6 16 The Times They Are a Changeling
|
||||||
|
FIM 1472311800 6 17 Dungeons & Discords
|
||||||
|
FIM 1472916600 6 18 Buckball Season
|
||||||
|
FIM 1473521400 6 19 The Fault in Our Cutie Marks
|
||||||
|
FIM 1474126200 6 20 Viva Las Pegasus
|
||||||
|
FIM 1474731000 6 21 Every Little Thing She Does
|
||||||
|
FIM 1475335800 6 22 P.P.O.V. (Pony Point of View)
|
||||||
|
FIM 1475940600 6 23 Where the Apple Lies
|
||||||
|
FIM 1476545400 6 24 Top Bolt
|
||||||
|
FIM 1477148400 6 25 To Where and Back Again: Part 1
|
||||||
|
FIM 1477150200 6 26 To Where and Back Again: Part 2
|
||||||
FIM 1371340800 99 1 Equestria Girls
|
FIM 1371340800 99 1 Equestria Girls
|
||||||
FIM 1411862400 99 2 Equestria Girls - Rainbow Rocks
|
FIM 1411862400 99 2 Equestria Girls - Rainbow Rocks
|
||||||
FIM 1443321000 99 3 Equestria Girls - Friendship Games
|
FIM 1443321000 99 3 Equestria Girls - Friendship Games
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
# Package
|
version = "0.1.0"
|
||||||
|
author = "Christine Dodrill <xena@yolo-swag.com>"
|
||||||
version = "0.2.0"
|
|
||||||
author = "Cadey Dodrill"
|
|
||||||
description = "PonyAPI server https://github.com/Xe/PonyAPI"
|
description = "PonyAPI server https://github.com/Xe/PonyAPI"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
srcDir = "src"
|
||||||
bin = @["ponyapi"]
|
bin = @["ponyapi"]
|
||||||
|
|
||||||
# Dependencies
|
requires "nim >= 0.10.0", "jester#head", "random"
|
||||||
|
|
||||||
requires "nim >= 0.13.0", "jester#head", "random#head", "sam#head", "jsmn#head"
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
ponyapi.apps.xeserv.us {
|
|
||||||
log syslog
|
|
||||||
|
|
||||||
proxy / http://127.0.0.1:6452 {
|
|
||||||
proxy_header Host {host}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=PonyAPI Server listening on port 6452
|
|
||||||
Requires=docker.service
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStartPre=-/usr/bin/docker pull xena/ponyapi
|
|
||||||
ExecStartPre=-/usr/bin/docker rm -f ponyapi
|
|
||||||
ExecStart=/usr/bin/docker run -p 6452:5000 --name ponyapi xena/ponyapi
|
|
||||||
ExecStop=/usr/bin/docker rm -f ponyapi
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=network.target
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncdispatch
|
import asyncdispatch
|
||||||
import episode
|
import episode
|
||||||
import future
|
import future
|
||||||
|
import httpcore
|
||||||
import jester
|
import jester
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -58,16 +59,9 @@ template httpReply(code, body: expr): expr =
|
||||||
## Make things a lot simpler for replies, etc.
|
## Make things a lot simpler for replies, etc.
|
||||||
if request.headers.getOrDefault("X-API-Options") == "bare" or @"options" == "bare":
|
if request.headers.getOrDefault("X-API-Options") == "bare" or @"options" == "bare":
|
||||||
# New "bare" reply format, easier to scrape, etc.
|
# New "bare" reply format, easier to scrape, etc.
|
||||||
resp code, myHeaders, pretty(%body, 4)
|
resp code, pretty(%body, 4), "application/json"
|
||||||
else:
|
else:
|
||||||
resp code, myHeaders, pretty(%%body, 4)
|
resp code, pretty(%%body, 4), "application/json"
|
||||||
|
|
||||||
let myHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-Powered-By": "Nim and Jester",
|
|
||||||
"X-Git-Hash": getEnv("GIT_REV"),
|
|
||||||
"X-Server-Epoch": $ getTime().toSeconds().int,
|
|
||||||
}
|
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
port = 5000.Port
|
port = 5000.Port
|
||||||
|
@ -102,17 +96,19 @@ routes:
|
||||||
|
|
||||||
get "/random":
|
get "/random":
|
||||||
stats.newest.success.inc
|
stats.newest.success.inc
|
||||||
httpReply Http200, episodes.randomChoice()
|
httpReply Http200, episodes[epochTime().int mod len(episodes)]
|
||||||
|
|
||||||
get "/last_aired":
|
get "/last_aired":
|
||||||
var
|
var
|
||||||
#now = getTime()
|
now = getTime()
|
||||||
ep: Episode
|
ep: Episode
|
||||||
|
|
||||||
for epid, episode in pairs[Episode](episodes):
|
for epid, episode in pairs[Episode](episodes):
|
||||||
# XXX HACK PLEASE FIX
|
var then = times.fromSeconds(episode.air_date)
|
||||||
if episode.season == 5 and episode.episode == 26:
|
|
||||||
ep = episode
|
if now < then:
|
||||||
|
ep = episodes[epid-1]
|
||||||
|
break
|
||||||
|
|
||||||
stats.lastAired.success.inc
|
stats.lastAired.success.inc
|
||||||
httpReply Http200, ep
|
httpReply Http200, ep
|
||||||
|
@ -143,7 +139,7 @@ routes:
|
||||||
if @"format" == "irccmd":
|
if @"format" == "irccmd":
|
||||||
let
|
let
|
||||||
irccmd = "/cs episode del $1 $2\n/cs episode add $1 $2 $3 $4" % [$ep.season, $ep.episode, $ep.air_date, ep.name]
|
irccmd = "/cs episode del $1 $2\n/cs episode add $1 $2 $3 $4" % [$ep.season, $ep.episode, $ep.air_date, ep.name]
|
||||||
echo irccmd
|
halt Http200, irccmd
|
||||||
|
|
||||||
if ep.air_date == 0:
|
if ep.air_date == 0:
|
||||||
stats.episodeLookup.fails.inc
|
stats.episodeLookup.fails.inc
|
||||||
|
@ -158,7 +154,7 @@ routes:
|
||||||
|
|
||||||
if query == "":
|
if query == "":
|
||||||
stats.search.fails.inc
|
stats.search.fails.inc
|
||||||
halt Http406, myHeaders, pretty(%%"Need to specify a query", 4)
|
halt Http406, pretty(%%"Need to specify a query", 4)
|
||||||
|
|
||||||
var
|
var
|
||||||
eps: seq[Episode] =
|
eps: seq[Episode] =
|
||||||
|
@ -172,7 +168,7 @@ routes:
|
||||||
httpReply Http200, eps
|
httpReply Http200, eps
|
||||||
|
|
||||||
get "/_stats":
|
get "/_stats":
|
||||||
resp Http200, myHeaders, pretty(%*
|
resp Http200, pretty(%*
|
||||||
[
|
[
|
||||||
stats.all,
|
stats.all,
|
||||||
stats.newest,
|
stats.newest,
|
Loading…
Reference in New Issue