Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mail Mod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Nerlich
Mail Mod
Commits
f018f623
Commit
f018f623
authored
4 years ago
by
Peter Nerlich
Browse files
Options
Downloads
Patches
Plain Diff
display date/time passed in message view/inbox
parent
41a78b1e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
gui.lua
+12
-7
12 additions, 7 deletions
gui.lua
util/misc.lua
+56
-0
56 additions, 0 deletions
util/misc.lua
with
68 additions
and
7 deletions
gui.lua
+
12
−
7
View file @
f018f623
...
@@ -28,8 +28,8 @@ mail.inbox_formspec = "size[8,9;]" .. theme .. [[
...
@@ -28,8 +28,8 @@ mail.inbox_formspec = "size[8,9;]" .. theme .. [[
button[6,7.40;2,0.5;about;About]
button[6,7.40;2,0.5;about;About]
button_exit[6,8.45;2,0.5;quit;Close]
button_exit[6,8.45;2,0.5;quit;Close]
tablecolumns[color;text;text]
tablecolumns[color;text;text
;text
]
table[0,0;5.75,9;messages;#999,From,Subject]]
table[0,0;5.75,9;messages;#999,
,
From,Subject]]
mail
.
contacts_formspec
=
"size[8,9;]"
..
theme
..
[[
mail
.
contacts_formspec
=
"size[8,9;]"
..
theme
..
[[
button[6,0.10;2,0.5;new;New]
button[6,0.10;2,0.5;new;New]
...
@@ -75,6 +75,7 @@ end
...
@@ -75,6 +75,7 @@ end
function
mail
.
show_inbox
(
name
)
function
mail
.
show_inbox
(
name
)
local
formspec
=
{
mail
.
inbox_formspec
}
local
formspec
=
{
mail
.
inbox_formspec
}
local
messages
=
mail
.
getMessages
(
name
)
local
messages
=
mail
.
getMessages
(
name
)
local
now
=
os.time
()
message_drafts
[
name
]
=
nil
message_drafts
[
name
]
=
nil
...
@@ -95,6 +96,8 @@ function mail.show_inbox(name)
...
@@ -95,6 +96,8 @@ function mail.show_inbox(name)
end
end
end
end
formspec
[
#
formspec
+
1
]
=
","
formspec
[
#
formspec
+
1
]
=
","
formspec
[
#
formspec
+
1
]
=
minetest
.
formspec_escape
(
mail
.
pretty_duration
(
now
-
message
.
time
))
formspec
[
#
formspec
+
1
]
=
","
formspec
[
#
formspec
+
1
]
=
minetest
.
formspec_escape
(
message
.
sender
)
formspec
[
#
formspec
+
1
]
=
minetest
.
formspec_escape
(
message
.
sender
)
formspec
[
#
formspec
+
1
]
=
","
formspec
[
#
formspec
+
1
]
=
","
if
message
.
subject
~=
""
then
if
message
.
subject
~=
""
then
...
@@ -291,6 +294,7 @@ function mail.show_message(name, msgnumber)
...
@@ -291,6 +294,7 @@ function mail.show_message(name, msgnumber)
label[0,0;From: %s]
label[0,0;From: %s]
label[0,0.4;To: %s]
label[0,0.4;To: %s]
label[0,0.8;CC: %s]
label[0,0.8;CC: %s]
label[3,0;Date: %s]
label[0,1.3;Subject: %s]
label[0,1.3;Subject: %s]
textarea[0.25,1.8;8,7.8;body;;%s]
textarea[0.25,1.8;8,7.8;body;;%s]
button[0,8.5;2,1;reply;Reply]
button[0,8.5;2,1;reply;Reply]
...
@@ -302,9 +306,10 @@ function mail.show_message(name, msgnumber)
...
@@ -302,9 +306,10 @@ function mail.show_message(name, msgnumber)
local
from
=
minetest
.
formspec_escape
(
message
.
sender
)
local
from
=
minetest
.
formspec_escape
(
message
.
sender
)
local
to
=
minetest
.
formspec_escape
(
message
.
to
)
local
to
=
minetest
.
formspec_escape
(
message
.
to
)
local
cc
=
minetest
.
formspec_escape
(
message
.
cc
)
local
cc
=
minetest
.
formspec_escape
(
message
.
cc
)
local
date
=
minetest
.
formspec_escape
(
mail
.
pretty_date
(
message
.
time
,
true
))
local
subject
=
minetest
.
formspec_escape
(
message
.
subject
)
local
subject
=
minetest
.
formspec_escape
(
message
.
subject
)
local
body
=
minetest
.
formspec_escape
(
message
.
body
)
local
body
=
minetest
.
formspec_escape
(
message
.
body
)
formspec
=
string.format
(
formspec
,
from
,
to
,
cc
,
subject
,
body
)
formspec
=
string.format
(
formspec
,
from
,
to
,
cc
,
date
,
subject
,
body
)
if
message
.
unread
then
if
message
.
unread
then
message
.
unread
=
false
message
.
unread
=
false
...
...
This diff is collapsed.
Click to expand it.
util/misc.lua
+
56
−
0
View file @
f018f623
...
@@ -60,6 +60,62 @@ function mail.calculate_frequent_contacts(name, only_show_contacts)
...
@@ -60,6 +60,62 @@ function mail.calculate_frequent_contacts(name, only_show_contacts)
return
out
return
out
end
end
function
mail
.
pretty_date
(
timestamp
,
trim_if_recent
)
-- convert timestamp to table in local time
local
ts_tab
=
os.date
(
"*t"
,
timestamp
)
if
trim_if_recent
then
local
ago
=
os.time
()
-
timestamp
timestamp
=
os.time
(
ts_tab
)
-- make display local time for os.date()
if
ago
>=
0
then
local
now_tab
=
os.date
(
"*t"
)
now_tab
.
sec
=
0
now_tab
.
min
=
0
now_tab
.
hour
=
0
if
timestamp
>=
os.time
(
now_tab
)
then
return
os.date
(
"%H:%M"
,
timestamp
)
else
now_tab
.
day
=
1
now_tab
.
month
=
1
if
timestamp
>=
os.time
(
now_tab
)
then
return
os.date
(
"%d.%m. %H:%M"
,
timestamp
)
end
end
end
end
return
os.date
(
"%d.%m.%Y %H:%M:%S"
,
timestamp
)
end
function
mail
.
pretty_duration
(
seconds
)
if
seconds
<
60
then
return
seconds
..
" sec"
elseif
seconds
<
60
*
60
then
return
math.floor
(
0
.
5
+
seconds
/
60
)
..
" min"
elseif
seconds
<
60
*
60
*
2
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
)
..
" hour"
elseif
seconds
<
60
*
60
*
24
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
)
..
" hrs"
elseif
seconds
<
60
*
60
*
24
*
2
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
)
..
" day"
elseif
seconds
<
60
*
60
*
24
*
30
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
)
..
" days"
elseif
seconds
<
60
*
60
*
24
*
30
*
2
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
/
30
)
..
" month"
elseif
seconds
<
60
*
60
*
24
*
30
*
12
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
/
30
)
..
" months"
elseif
seconds
<
60
*
60
*
24
*
30
*
12
*
2
then
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
/
30
/
12
)
..
" year"
else
return
math.floor
(
0
.
5
+
seconds
/
60
/
60
/
24
/
30
/
12
)
..
" yrs"
end
end
function
pairsByKeys
(
t
,
f
)
function
pairsByKeys
(
t
,
f
)
-- http://www.lua.org/pil/19.3.html
-- http://www.lua.org/pil/19.3.html
local
a
=
{}
local
a
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment