Timestamps
FossilOrigin-Name: 0712c9be1b9e6b587b15a8e795f939d99295876c1372e24ecdaef0b40db80319
This commit is contained in:
parent
113c2b2433
commit
385efb634d
6 changed files with 70 additions and 11 deletions
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ GIT ?= git
|
|||
MASTODONT_DIR = mastodont-c/
|
||||
MASTODONT = $(MASTODONT_DIR)libmastodont.a
|
||||
CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ $(shell pkg-config --cflags libcurl libcjson libpcre)
|
||||
LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcjson libcurl libpcre) -lfcgi
|
||||
LDFLAGS = -lm -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcjson libcurl libpcre) -lfcgi
|
||||
SRC = $(wildcard src/*.c)
|
||||
OBJ = $(patsubst %.c,%.o,$(SRC))
|
||||
HEADERS = $(wildcard src/*.h)
|
||||
|
|
30
dist/treebird20.css
vendored
30
dist/treebird20.css
vendored
|
@ -619,6 +619,29 @@ svg.in-reply-to-icon
|
|||
width: auto;
|
||||
}
|
||||
|
||||
.seperator
|
||||
{
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
color: #606060;
|
||||
vertical-align: middle;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.time::before
|
||||
{
|
||||
content: "•";
|
||||
padding-right: 10px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.time
|
||||
{
|
||||
color: #606060;
|
||||
vertical-align: middle;
|
||||
font-size: 15px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.status .status-info,
|
||||
.notification-info-format,
|
||||
|
@ -640,6 +663,7 @@ svg.in-reply-to-icon
|
|||
border-spacing: 0px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.status .instance-info
|
||||
|
@ -1173,6 +1197,12 @@ p}
|
|||
border: 1px solid #cacaca;
|
||||
}
|
||||
|
||||
.emoji-btn
|
||||
{
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
/* Emojo picker */
|
||||
.emoji-picker
|
||||
{
|
||||
|
|
19
src/status.c
19
src/status.c
|
@ -187,6 +187,7 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
char* favourites_count = NULL;
|
||||
char* emoji_picker_html = NULL;
|
||||
char* reactions_btn_html = NULL;
|
||||
char* time_str;
|
||||
size_t s;
|
||||
|
||||
// Emojo picker
|
||||
|
@ -211,6 +212,8 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
easprintf(&likeboost_html, data_likeboost_html,
|
||||
config_url_prefix,
|
||||
status->id);
|
||||
|
||||
time_str = reltime_to_str(status->created_at);
|
||||
|
||||
s = easprintf(&interaction_html, data_interaction_buttons_html,
|
||||
config_url_prefix,
|
||||
|
@ -231,16 +234,18 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
reactions_btn_html ? reactions_btn_html : "",
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
status->id);
|
||||
status->id,
|
||||
reltime_to_str(status->created_at));
|
||||
if (size) *size = s;
|
||||
|
||||
// Cleanup
|
||||
if (emoji_picker_html) free(emoji_picker_html);
|
||||
if (reply_count) free(reply_count);
|
||||
if (repeat_count) free(repeat_count);
|
||||
if (favourites_count) free(favourites_count);
|
||||
if (reactions_btn_html) free(reactions_btn_html);
|
||||
if (likeboost_html) free(likeboost_html);
|
||||
free(emoji_picker_html);
|
||||
free(reply_count);
|
||||
free(repeat_count);
|
||||
free(favourites_count);
|
||||
free(reactions_btn_html);
|
||||
free(likeboost_html);
|
||||
free(time_str);
|
||||
return interaction_html;
|
||||
}
|
||||
|
||||
|
|
25
src/string.c
25
src/string.c
|
@ -16,6 +16,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "easprintf.h"
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
@ -23,10 +28,26 @@
|
|||
|
||||
char* reltime_to_str(time_t stime)
|
||||
{
|
||||
char str[16];
|
||||
// Get current time
|
||||
char* str;
|
||||
// Get current time and convert it to GMT
|
||||
time_t curr_time = time(NULL);
|
||||
int since = curr_time - stime;
|
||||
|
||||
// Timezone likely off
|
||||
if (since < 60)
|
||||
easprintf(&str, "%ds", since);
|
||||
else if (since < 60 * 60)
|
||||
easprintf(&str, "%dm", since / 60);
|
||||
else if (since < 60 * 60 * 24)
|
||||
easprintf(&str, "%dh", since / (60 * 60));
|
||||
else if (since < 60 * 60 * 24 * 31) // Not truly but werks
|
||||
easprintf(&str, "%dd", since / (60 * 60 * 24));
|
||||
else if (since < 60 * 60 * 24 * 365)
|
||||
easprintf(&str, "%dmon", since / (60 * 60 * 24 * 31));
|
||||
else
|
||||
easprintf(&str, "%dyr", since / (60 * 60 * 24 * 365));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
int streql(char* cmp1, char* cmp2)
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
</label>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<span class="time">%s</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
<svg class="emoji-btn" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>
|
||||
<input class="hidden" type="submit" value="Emoji">
|
||||
</label>
|
||||
%s
|
||||
</form>
|
||||
%s
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue