060520 Theme optimization and mobile layout changes

This commit is contained in:
Daisuke
2020-05-06 11:48:21 -05:00
parent 6de44032b7
commit 9d42478acd
29 changed files with 203 additions and 5309 deletions

View File

@ -41,6 +41,7 @@ function get_urls($input) {
/* this function replaces the emoji codes in a text with the correspondent emojis
of the specified instance, returns the html code with the emojis in the specified size*/
/*
function emoji($text, $size = 30, $srv) {
$data = json_decode(file_get_contents("https://$srv/api/v1/custom_emojis") , true) [0]['url'];
$u = explode("/", $data);
@ -53,6 +54,7 @@ function emoji($text, $size = 30, $srv) {
$text = str_replace("https;", "https:", $text);
return $text;
}
*/
/* this is the same as above but is used on other places, like user bios and places where the
shortcodes and the emoji url is defined in the same place */
@ -63,7 +65,8 @@ function emojify($string, $emojis, $size = 40) {
return $string;
}
/* This function displays the emoji list of an instance based on a search
string given on $val */
function emoji_list($val){
$emojilist = api_get("/custom_emojis");
$c = 0;
@ -85,7 +88,9 @@ function emoji_list($val){
return $return;
}
/* general function to check if one strings starts with a given search */
function starts_with($string,$search){
if (substr(strtolower($string),0,strlen($search)) == strtolower($search)){
return true;
@ -93,6 +98,7 @@ function starts_with($string,$search){
return false;
}
/* general function to check if one strings contains with a given search */
function contains($string,$search){
if (is_numeric(strpos(strtolower($string),strtolower($search)))){
return true;
@ -148,25 +154,6 @@ function user_info($user) {
);
}
function api_getv2($url) {
global $srv;
global $token;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v2/" . $url);
if (!is_null($token)) {
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $token
));
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result, true);
}
/* a function to make an authenticated general GET api call to the logged-in instance */
function api_get($url) {
global $srv;
@ -185,6 +172,25 @@ function api_get($url) {
return json_decode($result, true);
}
/* same as above but used in some newer api endpoinds (v2) */
function api_getv2($url) {
global $srv;
global $token;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v2/" . $url);
if (!is_null($token)) {
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . $token
));
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result, true);
}
/* a function to make an authenticated general POST api call to the logged-in instance */
function api_post($url, $array) {
global $srv;
@ -253,6 +259,8 @@ function api_patch($url, $array) {
return json_decode($result, true);
}
/* Function to upload files to the profile of the authenticated user
$type can be 'avatar' or 'header'*/
function upload_profile($file,$type){
global $srv;
global $token;
@ -320,15 +328,15 @@ function render_reply($item) {
$reply['menu'] = "<ul>";
if ($logedin) {
$reply['menu'] .= ($item['account']['id'] == $user_settings['uid'] ? "<li><a href='?action=delete&thread=" . $item['id'] . "' onClick='return false;' class='delete fontello' id='" . $item['id'] . "'>&#xe80e; Delete Post</a></li>" : "");
$reply['menu'] .= ($item['account']['id'] == $user_settings['uid'] ? "<li><a href='?action=delete&thread=" . $item['id'] . "' onClick='return false;' class='delete fontello' id=':id:'>&#xe80e; Delete Post</a></li>" : "");
$reply['menu'] .= "<li><a href='?action=compose&quote=" . $item['id'] . "' onClick='return false;' class='quote fontello' id='" . $item['id'] . "' style='background-color:transparent;'>&#xf10e; Quote Post</a></li>";
$reply['menu'] .= ($item['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=mute&user=" . $item['account']['id'] . "' onClick='return false;' class='mute fontello' id='" . $item['account']['id'] . "' style='background-color:transparent;'>&#xe81b; Mute User</a></li>" : "");
$reply['menu'] .= ($item['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=mute&thread=" . $item['account']['id'] . "' onClick='return false;' class='muteconv fontello' id='" . $item['id'] . "' style='background-color:transparent;'>&#xf1f7; Drop Thread</a></li>" : "");
$reply['menu'] .= (isset($user_settings['pleroma']) ? "<li><a href='?action=hide&thread=" . $item['pleroma']['conversation_id'] . "' onClick='return false;' class='hide fontello' id='" . $item['pleroma']['conversation_id'] . "' style='background-color:transparent;'>&#xf1f8; Hide Thread</a></li>" : "");
$reply['menu'] .= (isset($user_settings['pleroma']) ? "<li><a href='?action=bookmark&thread=" . $item['account']['id'] . "' onClick='return false;' class='" . ($item['bookmarked'] == true ? "un" : "") . "bookmark fontello' id='" . $item['id'] . "' style='background-color:transparent;'>&#xe81e; " . ($item['bookmarked'] == true ? "Unb" : "B") . "ookmark</a></li>" : "");
$reply['menu'] .= ($item['account']['id'] != $user_settings['uid'] ? "<li><a href='?action=nsfw&user=" . $item['account']['id'] . "' onClick='return false;' class='nsfw fontello' id='" . $item['account']['id'] . "' style='background-color:transparent;'>&#xe829; User is NSFW</a></li>" : "");
}
$reply['menu'] .= "<li><a target='_blank' href='" . $item['url'] . "' class='link fontello' style='background-color:transparent;'>&#xf14c; Original Note</a></li>";
$reply['menu'] .= "<li><a target='_blank' href='" . $item['url'] . "' class='original link fontello' style='background-color:transparent;'>&#xf14c; Original Note</a></li>";
$reply['menu'] .= "</ul>";
$json['id'] = $item['id'];
@ -350,11 +358,6 @@ function render_reply($item) {
$reply['replyto'] = ($item['in_reply_to_id'] ? " <a class='fontello link preview ldr' target='_blank' id='" . $item['in_reply_to_id'] . "' href='?thread=" . $item['in_reply_to_id'] . "'>&#xf112;</a> " : "");
$reply['text'] = processText($item);
$public = "&#xe83c;";
$private = "&#xe819;";
$unlisted = "&#xe816;";
$direct = "&#xf0e0;";
$reply['date'] = "<a class='ldr postAge' id='".strtotime($item['created_at'])."' style='text-decoration:none;' target='_blank' href='?thread=" . $item['id'] . "'>" . time_elapsed_string($item['created_at']) . "</a> - <span class='fontello ".$item['visibility']."'> </span>";
$reply['media'] = "";
@ -394,7 +397,7 @@ function render_reply($item) {
$reply['buttons'] = "
" . ($logedin ? "<div class='felem'><a onClick='return false' class='replyform' href='?thread=" . $item['id'] . "' style='font-family:fontello'>&#xf112;</a></div>" : "") . "
<div class='felem'><a onClick='return false' " . ($logedin ? "class='" . ($item['favourited'] == true ? "unfav" : "fav") . "' href='?action=fav&thread=" . $item['id'] . "'" : "") . " style='font-family:fontello'>&#xe802; <span>" . $item['favourites_count'] . "</span></a></div>
<div class='felem'><a onClick='return false' " . ($logedin && $item['visibility'] == "public" ? "class='" . ($item['reblogged'] == true ? "unreblog" : "reblog") . "' href='?action=reblog&thread=" . $item['id'] . "'" : "") . " style='font-family:fontello'>&#xe83a; <span>" . $item['reblogs_count'] . "</span></a></div>
<div class='felem'><a onClick='return false' " . ($logedin && ($item['visibility'] != "private" || $item['visibility'] != "direct") ? "class='" . ($item['reblogged'] == true ? "unreblog" : "reblog") . "' href='?action=reblog&thread=" . $item['id'] . "'" : "") . " style='font-family:fontello'>&#xe83a; <span>" . $item['reblogs_count'] . "</span></a></div>
";
$result = themes("get","templates/reply.txt");