From 34d2bbe2079d1084601789b8c7bb42d8f0819502 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 12 Feb 2016 02:29:04 -0800 Subject: [PATCH] Show user list in TXT format: /users.txt --- src/twtxtlist.nim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/twtxtlist.nim b/src/twtxtlist.nim index a451c97..094c2f3 100644 --- a/src/twtxtlist.nim +++ b/src/twtxtlist.nim @@ -1,4 +1,4 @@ -import asyncdispatch, db_sqlite, httpclient, jester, moustachu, os, shorturl, +import asyncdispatch, db_sqlite, httpclient, jester, json, moustachu, os, shorturl, strutils, tables, templates/all, times, tweet/parse, twtxt, typetraits let @@ -122,6 +122,20 @@ routes: renderMustache "users", usersTemplate, ctx + get "/users.txt": + let + headers = { + "Content-Type": "text/plain" + } + users = db.getAllRows(sql"select username, url from users order by username") + + var outBuf = "" + + for user in users.items(): + outBuf &= "twtxt follow " & user[0] & " " & user[1] & "\r\n" + + resp Http200, headers, outBuf + get "/users/@name/@page": try: var