mirror of
https://github.com/hkalexling/Mango.git
synced 2026-03-20 00:00:48 -04:00
Merge branch 'cover' into dev
This commit is contained in:
16
src/util.cr
16
src/util.cr
@@ -1,6 +1,7 @@
|
||||
require "big"
|
||||
|
||||
IMGS_PER_PAGE = 5
|
||||
IMGS_PER_PAGE = 5
|
||||
UPLOAD_URL_PREFIX = "/uploads"
|
||||
|
||||
macro layout(name)
|
||||
begin
|
||||
@@ -12,7 +13,8 @@ macro layout(name)
|
||||
render "src/views/#{{{name}}}.ecr", "src/views/layout.ecr"
|
||||
rescue e
|
||||
message = e.to_s
|
||||
render "message"
|
||||
@context.error message
|
||||
render "src/views/message.ecr", "src/views/layout.ecr"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,9 +29,9 @@ macro get_username(env)
|
||||
(@context.storage.verify_token cookie.value).not_nil!
|
||||
end
|
||||
|
||||
macro send_json(env, json)
|
||||
{{env}}.response.content_type = "application/json"
|
||||
{{json}}
|
||||
def send_json(env, json)
|
||||
env.response.content_type = "application/json"
|
||||
env.response.print json
|
||||
end
|
||||
|
||||
def hash_to_query(hash)
|
||||
@@ -93,3 +95,7 @@ def validate_zip(path : String) : Exception?
|
||||
rescue e
|
||||
e
|
||||
end
|
||||
|
||||
def random_str
|
||||
UUID.random.to_s.gsub "-", ""
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user