Added UUIDs to timestamps, refactored the build process
* Added UUIDs to `ts_entry` records. Updated `ts_json:construct_record` to respond to `uuid` member properties if present. UUIDs are not required by the strict parsing functions in `ts_json` because the client will make a request with no UUID if it is a purely new timestamp. IN fact, this is the normal case. The UUID is only present when another tool is syncing its copy of this timeline wand adding entries that it has created and assigned UUIDs to. * `ts_entry:new` will create a UUID for a new entry if it does not already have one. * Restructured the build process to put all build artifacts into a dedicated `build` subdirectory, instead of mising them in an amongst the source code. * Added the `uuid` module to the project. It can be found at https://gitorious.org/avtobiff/erlang-uuid * Rewrote asset URLs to use relative paths instead of absolute paths. Relative paths are correct in this case, becuase assets always live alongside the HTML pages. This change was needed to accomodate the new organization of the JDB Labs dev environment, where all projects live under subdirectories of the same virtual server instead of subdomains. * Tweaked the timestamp entry fields in the web UI to save when the field is blurred, not just when <Enter> or <Ctrl>-<Enter> is pressed (though those still work).
This commit is contained in:
@ -28,6 +28,8 @@
|
||||
|
||||
-record(ts_entry, {
|
||||
ref, % {username, timelineid, entryid}
|
||||
uuid, % UUID for this entry across all implementations and copies of
|
||||
% this timeline.
|
||||
timestamp, % gregorian seconds
|
||||
mark, % String description of entry
|
||||
notes % String with further notes about the entry
|
||||
|
@ -24,7 +24,11 @@ new(ER = #ts_entry{}, ExtData) when is_list(ExtData) ->
|
||||
do_new(ER = #ts_entry{}) ->
|
||||
{Username, TimelineId, _} = ER#ts_entry.ref,
|
||||
NextId = id_counter:next_counter(ts_entry_id),
|
||||
NewRow = ER#ts_entry{ref = {Username, TimelineId, NextId}},
|
||||
RowWithRef = ER#ts_entry{ref = {Username, TimelineId, NextId}},
|
||||
NewRow = case RowWithRef#ts_entry.uuid of
|
||||
undefined -> RowWithRef#ts_entry{uuid = uuid:uuid4()};
|
||||
_ -> RowWithRef
|
||||
end,
|
||||
ok = mnesia:write(NewRow),
|
||||
NewRow.
|
||||
|
||||
|
@ -46,6 +46,7 @@ record_to_ejson(Record=#ts_timeline{}, ExtData) ->
|
||||
% "id": "1",
|
||||
% "timestamp": "2011-01-01T14:01.000Z",
|
||||
% "mark": "Workout.",
|
||||
% "uuid": "98ed5198-0c98-47c7-96c9-52b57a2c605a",
|
||||
% "notes": "First workout after a long break."}
|
||||
|
||||
record_to_ejson(Record=#ts_entry{}, ExtData) ->
|
||||
@ -62,6 +63,7 @@ record_to_ejson(Record=#ts_entry{}, ExtData) ->
|
||||
{id, EntryId},
|
||||
{timestamp, encode_datetime(DateTime)},
|
||||
{mark, Record#ts_entry.mark},
|
||||
{uuid, uuid:to_string(Record#ts_entry.uuid)},
|
||||
{notes, Record#ts_entry.notes}] ++
|
||||
lists:map(fun ext_data_to_ejson/1, ExtData)}.
|
||||
|
||||
@ -171,6 +173,7 @@ construct_record(Entry=#ts_entry{}, [{Key, Value}|Fields], ExtData) ->
|
||||
decode_datetime(Value))},
|
||||
Fields, ExtData);
|
||||
mark -> construct_record(Entry#ts_entry{mark=Value}, Fields, ExtData);
|
||||
uuid -> construct_record(Entry#ts_entry{uuid=uuid:to_binary(Value)}, Fields, ExtData);
|
||||
notes -> construct_record(Entry#ts_entry{notes=Value}, Fields, ExtData);
|
||||
_Other ->
|
||||
ExtDataProp = ejson_to_ext_data({Key, Value}),
|
||||
|
Reference in New Issue
Block a user