Added support for user, user_roles, page, blog export and import.
Added basic support for comments, for now mainly viewing comments from database (no submission forms yet). Added first simple wikitext filter (render wikitext content as xhtml). Ensure response content type is text/html with utf-8 charset.
This commit is contained in:
@@ -11,7 +11,7 @@ inherit
|
||||
|
||||
feature -- Hook
|
||||
|
||||
import_from (a_impot_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_import_ctx: CMS_IMPORT_CONTEXT; a_response: CMS_RESPONSE)
|
||||
import_from (a_import_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_import_ctx: CMS_IMPORT_CONTEXT; a_response: CMS_RESPONSE)
|
||||
-- Import data identified by `a_import_id_list',
|
||||
-- or import all data if `a_import_id_list' is Void.
|
||||
deferred
|
||||
|
||||
@@ -10,6 +10,39 @@ class
|
||||
|
||||
feature -- Access
|
||||
|
||||
json_value_from_location (a_location: PATH): detachable JSON_VALUE
|
||||
local
|
||||
f: RAW_FILE
|
||||
s: STRING
|
||||
jp: JSON_PARSER
|
||||
do
|
||||
create f.make_with_path (a_location)
|
||||
if f.exists and then f.is_access_readable then
|
||||
f.open_read
|
||||
from
|
||||
create s.make (0)
|
||||
until
|
||||
f.exhausted or f.end_of_file
|
||||
loop
|
||||
f.read_stream (1_024)
|
||||
s.append (f.last_string)
|
||||
end
|
||||
f.close
|
||||
create jp.make_with_string (s)
|
||||
jp.parse_content
|
||||
if jp.is_valid then
|
||||
Result := jp.parsed_json_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json_object_from_location (a_location: PATH): detachable JSON_OBJECT
|
||||
do
|
||||
if attached {JSON_OBJECT} json_value_from_location (a_location) as jo then
|
||||
Result := jo
|
||||
end
|
||||
end
|
||||
|
||||
json_string_item (j: JSON_OBJECT; a_name: READABLE_STRING_GENERAL): detachable STRING_32
|
||||
do
|
||||
if attached {JSON_STRING} j.item (a_name) as s then
|
||||
@@ -41,13 +74,46 @@ feature -- Access
|
||||
json_date_item (j: JSON_OBJECT; a_name: READABLE_STRING_GENERAL): detachable DATE_TIME
|
||||
local
|
||||
hd: HTTP_DATE
|
||||
i,y,m,d,h,min,sec: INTEGER
|
||||
s: STRING_8
|
||||
do
|
||||
if attached {JSON_NUMBER} j.item (a_name) as num then
|
||||
create hd.make_from_timestamp (num.integer_64_item)
|
||||
Result := hd.date_time
|
||||
elseif attached {JSON_STRING} j.item (a_name) as s then
|
||||
create hd.make_from_string (s.unescaped_string_32)
|
||||
Result := hd.date_time
|
||||
elseif attached {JSON_STRING} j.item (a_name) as js then
|
||||
s := js.unescaped_string_8
|
||||
|
||||
-- Parse yyyy-mm-dd hh:mm:ss
|
||||
-- 1234567890123456789
|
||||
i := s.index_of ('-', 1)
|
||||
if i = 5 then
|
||||
y := s.substring (1, i - 1).to_integer
|
||||
i := s.index_of ('-', i + 1)
|
||||
if i = 8 then
|
||||
m := s.substring (6, i - 1).to_integer
|
||||
i := s.index_of (' ', i + 1)
|
||||
if i = 11 then
|
||||
d := s.substring (9, i - 1).to_integer
|
||||
i := s.index_of (':', i + 1)
|
||||
if i = 14 then
|
||||
h := s.substring (12, i - 1).to_integer
|
||||
i := s.index_of (':', i + 1)
|
||||
if i = 17 then
|
||||
min := s.substring (15, i - 1).to_integer
|
||||
sec := s.substring (i + 1, s.count).to_integer
|
||||
create Result.make (y,m,d,h,min,sec)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if Result = Void then
|
||||
create hd.make_from_string (s)
|
||||
if hd.has_error then
|
||||
else
|
||||
Result := hd.date_time
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user