aboutsummaryrefslogtreecommitdiff
path: root/src/guff.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff.cr')
-rw-r--r--src/guff.cr190
1 files changed, 0 insertions, 190 deletions
diff --git a/src/guff.cr b/src/guff.cr
index 3fecd10..c7e3216 100644
--- a/src/guff.cr
+++ b/src/guff.cr
@@ -1325,196 +1325,6 @@ module Guff
end
end
- module APIs
- module PostAPI
- def do_post_get_posts(params : HTTP::Params)
- @context.models.post.get_posts(
- site_id: (params["site_id"]? && params["site_id"] != "all") ? params["site_id"].to_i64 : nil,
- user_id: (params["user_id"]? && params["user_id"] != "all") ? params["user_id"].to_i64 : nil,
- state: params["state"]?,
- type: params["type"]?,
- q: params["q"]?,
- page: params["page"].to_i32,
- )
- end
- end
-
- module PageAPI
- def do_page_add(params : HTTP::Params)
- post_id = @context.models.page.add(
- site_id: params["site_id"]? ? params["site_id"].to_i64 : @context.models.site.get_default_id,
- user_id: @context.user_id.not_nil!,
- )
-
- { "post_id": post_id }
- end
-
- def do_page_set(params : HTTP::Params)
- @context.models.page.set(
- post_id: params["post_id"].to_i64,
-
- site_id: params["site_id"]? ? params["site_id"].to_i64 : nil,
- state: params["state"]?,
-
- have_posted_at: !!params["posted_at"]?,
- posted_at: params["posted_at"]? ? ISO8601.parse(params["posted_at"]) : nil,
-
- have_expires_at: !!params["expires_at"]?,
- expires_at: params["expires_at"]? ? ISO8601.parse(params["expires_at"]) : nil,
-
- slug: params["slug"]?,
- slug_lock: params["slug_lock"]? ? (params["slug_lock"] == "t") : nil,
-
- name: params["name"]?,
- body: params["body"]?,
-
- layout: params["layout"]?,
- )
-
- nil
- end
-
- def do_page_get(params : HTTP::Params)
- @context.models.page.get(
- post_id: params["post_id"].to_i64
- ).reduce({} of String => String) do |r, kv|
- r[kv[0]] = kv[1].to_s
- r
- end
- end
- end
-
- module ProjectAPI
- def do_project_add(params : HTTP::Params)
- post_id = @context.models.project.add(
- site_id: params["site_id"]? ? params["site_id"].to_i64 : @context.models.site.get_default_id,
- user_id: @context.user_id.not_nil!,
- )
-
- { "post_id": post_id }
- end
-
- def do_project_set(params : HTTP::Params)
- @context.models.project.set(
- post_id: params["post_id"].to_i64,
-
- site_id: params["site_id"]? ? params["site_id"].to_i64 : nil,
- state: params["state"]?,
-
- have_posted_at: !!params["posted_at"]?,
- posted_at: params["posted_at"]? ? ISO8601.parse(params["posted_at"]) : nil,
-
- have_expires_at: !!params["expires_at"]?,
- expires_at: params["expires_at"]? ? ISO8601.parse(params["expires_at"]) : nil,
-
- slug: params["slug"]?,
- slug_lock: params["slug_lock"]? ? (params["slug_lock"] == "t") : nil,
-
- name: params["name"]?,
- body: params["body"]?,
-
- repo_url: params["repo_url"]?,
- )
-
- nil
- end
-
- def do_project_get(params : HTTP::Params)
- @context.models.project.get(
- post_id: params["post_id"].to_i64
- ).reduce({} of String => String) do |r, kv|
- r[kv[0]] = kv[1].to_s
- r
- end
- end
- end
-
- module BlogAPI
- def do_blog_add(params : HTTP::Params)
- post_id = @context.models.blog.add(
- site_id: params["site_id"]? ? params["site_id"].to_i64 : @context.models.site.get_default_id,
- user_id: @context.user_id.not_nil!,
- )
-
- { "post_id": post_id }
- end
-
- def do_blog_set(params : HTTP::Params)
- @context.models.blog.set(
- post_id: params["post_id"].to_i64,
-
- site_id: params["site_id"]? ? params["site_id"].to_i64 : nil,
- state: params["state"]?,
-
- have_posted_at: !!params["posted_at"]?,
- posted_at: params["posted_at"]? ? ISO8601.parse(params["posted_at"]) : nil,
-
- have_expires_at: !!params["expires_at"]?,
- expires_at: params["expires_at"]? ? ISO8601.parse(params["expires_at"]) : nil,
-
- slug: params["slug"]?,
- slug_lock: params["slug_lock"]? ? (params["slug_lock"] == "t") : nil,
-
- name: params["name"]?,
- body: params["body"]?,
- )
-
- nil
- end
-
- def do_blog_get(params : HTTP::Params)
- @context.models.blog.get(
- post_id: params["post_id"].to_i64
- ).reduce({} of String => String) do |r, kv|
- r[kv[0]] = kv[1].to_s
- r
- end
- end
- end
-
- module UserAPI
- def do_user_add(params : HTTP::Params)
- user_id = @context.models.user.add(
- name: params["name"],
- email: params["email"],
- password: params["password"],
- active: (params["active"] == "t"),
- role: params["role"],
- )
-
- { "user_id": user_id }
- end
-
- def do_user_get(params : HTTP::Params)
- @context.models.user.get(params["user_id"].to_i64)
- end
-
-
- def do_user_set(params : HTTP::Params)
- @context.models.user.set(
- user_id: params["user_id"].to_i64,
- name: params["name"]?,
- email: params["email"]?,
- password: (params["password"]? && params["password"].size > 0) ? params["password"] : nil,
- active: params["active"]? ? (params["active"] == "t") : nil,
- role: params["role"]?,
- )
-
- nil
- end
-
- def do_user_get_users(params : HTTP::Params)
- @context.models.user.get_users
- end
- end
-
- module SiteAPI
- def do_site_get_sites(params : HTTP::Params)
- @context.models.site.get_sites
- end
- end
- end
-
module Views
abstract class View
def initialize(@context : Context)