Compare commits

...

10 Commits

Author SHA1 Message Date
Paul Liverman III
aa98c4c478 correct api definition errors 2018-03-16 17:15:38 -07:00
Paul Liverman III
b2a31cc045 trying to stop form submission 2018-03-16 17:10:22 -07:00
Paul Liverman III
30f3fb516a derped on reserved words in JS 2018-03-16 17:07:31 -07:00
Paul Liverman III
47869e2047 some more invalid data... 2018-03-16 17:02:24 -07:00
Paul Liverman III
203a276cdf err in creating new keys leading to infinite loop.. actually fixed 2018-03-16 17:01:02 -07:00
Paul Liverman III
083bfbb427 err in creating new keys leading to infinite loop 2018-03-16 17:00:14 -07:00
Paul Liverman III
548758abf5 attempting to correct automatic key generation 2018-03-16 16:57:52 -07:00
Paul Liverman III
1b55d56b43 daemon on! 2018-03-16 16:51:12 -07:00
Paul Liverman III
c3438cd38f another typo 2018-03-16 16:45:22 -07:00
Paul Liverman III
3c825ad645 typo 2018-03-16 16:42:35 -07:00
7 changed files with 77 additions and 81 deletions

View File

@ -17,8 +17,8 @@ class extends Application
@keys = Keys\find user_id: @user.id
@tasks = Tasks\find user_id: @user.id -- TODO convert to paginated
unless #@keys > 0
table.insert @keys, Keys\create user_id: @user.id
unless @keys and #@keys > 0
@keys = {Keys\create user_id: @user.id}
return render: "index.logged_in"

View File

@ -34,8 +34,7 @@ get_task = =>
class extends Application
-- api_key AND text
[new: "/new"]: capture_errors_json =>
json_params =>
[new: "/new"]: capture_errors_json json_params =>
key = get_key(@)
yield_error "Task text not specified." unless @params.text and @params.text\len! > 0
@ -47,8 +46,7 @@ class extends Application
return json: { success: true, :task }
-- api_key AND id
[do: "/do"]: capture_errors_json =>
json_params =>
[do: "/do"]: capture_errors_json json_params =>
if task = get_task(@)
task = assert_error task\update { done: true }
return json: { success: true, :task }
@ -56,8 +54,7 @@ class extends Application
return standard_err!
-- api_key AND id
[undo: "/undo"]: capture_errors_json =>
json_params =>
[undo: "/undo"]: capture_errors_json json_params =>
if task = get_task(@)
task = assert_error task\update { done: false }
return json: { success: true, :task }
@ -65,8 +62,7 @@ class extends Application
return standard_err!
-- api_key AND (id OR (done true/false/nil AND/OR page))
[fetch: "/fetch"]: capture_errors_json =>
json_params =>
[fetch: "/fetch"]: capture_errors_json json_params =>
if @params.id
if task = get_task(@)
return json: { success: true, :task }
@ -86,8 +82,7 @@ class extends Application
return json: { success: true, :tasks }
-- api_key AND done true/false/nil
[random: "/fetch/random"]: capture_errors_json =>
json_params =>
[random: "/fetch/random"]: capture_errors_json json_params =>
key = get_key(@)
local tasks
@ -104,8 +99,7 @@ class extends Application
return standard_err!
-- api_key AND done true/false/nil AND/OR case true
[search: "/search"]: capture_errors_json =>
json_params =>
[search: "/search"]: capture_errors_json json_params =>
key = get_key(@)
like = @params.case and "ILIKE" or "LIKE"

View File

@ -1,4 +1,4 @@
import create_table, types from require "lapis.db.schema"
import create_table, types, create_index from require "lapis.db.schema"
import make_migrations, autoload from require "locator"
import settings from autoload "utility"
@ -14,7 +14,7 @@ make_migrations {
{"updated_at", types.time}
}
create_table "keys", {
{"user_id", types.foreign_key primary_key: true}
{"user_id", types.foreign_key}
{"uuid", types.varchar unique: true}
{"created_at", types.time}

View File

@ -17,6 +17,6 @@ class Keys extends Model
@create: (values, opts) =>
while true
values.uuid = uuid!
if Keys\find uuid: values.uuid
unless Keys\find uuid: values.uuid
break
super values, opts

View File

@ -1,6 +1,6 @@
worker_processes ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;
daemon on;
pid logs/nginx.pid;
events {

View File

@ -28,7 +28,7 @@ function check(id) {
}
}
function new() {
function new_task() {
var text = document.getElementById("new-task");
console.log(text); // TEMPORARY
var xhr = request("/new");

View File

@ -6,6 +6,7 @@ class extends Widget
script src: "/static/index.js"
p "API Keys:"
ul ->
if @keys
for key in *@keys
li key.uuid
-- li ->
@ -13,13 +14,14 @@ class extends Widget
p "Tasks:"
ul ->
if @tasks
for task in *@tasks
li ->
input type: "checkbox", id: "task-#{task.id}", onchange: "check(#{task.id})" checked: task.done
input type: "checkbox", id: "task-#{task.id}", onchange: "check(#{task.id});", checked: task.done
text " #{task.text}"
li ->
form {
onsubmit: "new()"
onsubmit: "return new_task();"
}, ->
input type: "text", id: "new-task", placeholder: "new task"
input type: "submit", value: "add task"