Sfoglia il codice sorgente

Add more context for authenticated_account

front-end/userside-improvements
Toromino 5 mesi fa
parent
commit
a6cd25fcdb

+ 3
- 3
src/raito_fe/api_controller.rs Vedi File

@@ -108,7 +108,7 @@ pub fn home_timeline(token: &str) -> Result<Vec<Status>, ()> {
108 108
                 None,
109 109
                 None,
110 110
                 None,
111
-                None,
111
+                Some(40),
112 112
                 AuthorizationHeader(token.to_string()),
113 113
             )
114 114
             .to_string(),
@@ -124,7 +124,7 @@ pub fn home_timeline(token: &str) -> Result<Vec<Status>, ()> {
124 124
 pub fn get_public_timeline(local: bool) -> Result<Vec<Status>, ()> {
125 125
     if unsafe { BYPASS_API } == &true {
126 126
         match serde_json::from_str(
127
-            &routes::public_timeline(Some(local), None, None, None, None, None).to_string(),
127
+            &routes::public_timeline(Some(local), None, None, None, None, Some(40)).to_string(),
128 128
         ) {
129 129
             Ok(timeline) => Ok(timeline),
130 130
             Err(_) => Err(()),
@@ -155,7 +155,7 @@ pub fn get_user_timeline(id: String) -> Result<Vec<Status>, ()> {
155 155
                 None,
156 156
                 None,
157 157
                 None,
158
-                None,
158
+                Some(40),
159 159
                 None,
160 160
             )
161 161
             .to_string(),

+ 24
- 2
src/raito_fe/renderer.rs Vedi File

@@ -18,9 +18,16 @@ pub fn about(configuration: LocalConfiguration, authentication: Authentication)
18 18
     context.extend(configuration);
19 19
     context.extend(prepare_authentication_context(&authentication));
20 20
     context.insert("stylesheet".to_string(), raito_fe::get_stylesheet());
21
-    context.insert("content".to_string(), fs::read_to_string("static/raito_fe/html/about.html").unwrap_or_else(|_| String::from("<h2>About this node</h2>
21
+    context.insert(
22
+        "content".to_string(),
23
+        fs::read_to_string("static/raito_fe/html/about.html").unwrap_or_else(|_| {
24
+            String::from(
25
+                "<h2>About this node</h2>
22 26
 This is a placeholder text, it can be edited in \"static/raito_fe/html/about.html\"
23
-")));
27
+",
28
+            )
29
+        }),
30
+    );
24 31
     return Template::render("raito_fe/about", context);
25 32
 }
26 33
 
@@ -573,6 +580,14 @@ fn prepare_authentication_context(authentication: &Authentication) -> HashMap<St
573 580
                 String::from("authenticated_account_display_name"),
574 581
                 (*account.display_name).to_string(),
575 582
             );
583
+            context.insert(
584
+                String::from("authenticated_account_avatar"),
585
+                (*account.avatar).to_string(),
586
+            );
587
+            context.insert(
588
+                String::from("authenticated_account_id"),
589
+                (*account.id).to_string(),
590
+            );
576 591
         }
577 592
         None => {
578 593
             context.insert(String::from("authenticated_account"), false.to_string());
@@ -580,6 +595,11 @@ fn prepare_authentication_context(authentication: &Authentication) -> HashMap<St
580 595
                 String::from("authenticated_account_display_name"),
581 596
                 String::from("Guest"),
582 597
             );
598
+            context.insert(
599
+                String::from("authenticated_account_avatar"),
600
+                String::from("/static/assets/default_avatar.png"),
601
+            );
602
+            context.insert(String::from("authenticated_account_id"), String::from(""));
583 603
         }
584 604
     }
585 605
 
@@ -650,6 +670,7 @@ fn prepare_status_context(status: Status) -> HashMap<String, String> {
650 670
         Some(reblog_status) => {
651 671
             let reblog: Status = serde_json::from_value(reblog_status).unwrap();
652 672
             context.insert(String::from("reblog_account_acct"), reblog.account.acct);
673
+            context.insert(String::from("reblog_account_avatar"), reblog.account.avatar);
653 674
             context.insert(
654 675
                 String::from("reblog_account_url"),
655 676
                 format!("/account/{}", reblog.id),
@@ -658,6 +679,7 @@ fn prepare_status_context(status: Status) -> HashMap<String, String> {
658 679
         }
659 680
         None => {
660 681
             context.insert(String::from("reblog_account_acct"), String::from(""));
682
+            context.insert(String::from("reblog_account_avatar"), String::from(""));
661 683
             context.insert(String::from("reblog_account_url"), String::from(""));
662 684
             context.insert(String::from("reblog_content"), String::from(""));
663 685
         }

+ 1
- 1
static/raito_fe/themes/raito_light.css Vedi File

@@ -213,7 +213,7 @@ textarea {
213 213
 
214 214
 #account-timeline {
215 215
 	margin-top: 10px;
216
-	height: 60vh;
216
+	height: 55vh;
217 217
 }
218 218
 
219 219
 #registration-form {

+ 1
- 1
templates/raito_fe/components/status.html.tera Vedi File

@@ -11,7 +11,7 @@
11 11
     <div class="status-content">
12 12
     {% if status_reblog == "true" %}
13 13
     <span class="status-reblog-divider"><img class="inner-icon" src="/static/raito_fe/fonts/open-iconic/svg/loop-circular.svg">has shared</span>
14
-    <img src="/static/assets/default_avatar.png" class="status-reblog-avatar">
14
+    <img src="{{reblog_account_avatar}}" class="status-reblog-avatar">
15 15
     <a href="{{reblog_account_url}}" class="status-reblog-username">{{reblog_account_acct}}</a>
16 16
     <br />
17 17
     <p class="status-reblog-content">{{reblog_content | safe}}</p>

+ 4
- 3
templates/raito_fe/index.html.tera Vedi File

@@ -10,10 +10,11 @@
10 10
             <ul>
11 11
                 <li class="dropdown" style="float: right;">
12 12
 		    {% if authenticated_account == "true" %}
13
-		    <img class="account-avatar-small" src="/static/assets/default_avatar.png">
14
-		    <span style="margin-right: 5px;">{{authenticated_account_display_name}}</span> <i class="icon-arrow-down"></i>
13
+		    <img class="account-avatar-small" src="{{authenticated_account_avatar}}">
14
+		    <span style="margin-right: 5px;">{{authenticated_account_display_name}}</span> 
15
+		    <img class="inner-icon" src="/static/raito_fe/fonts/open-iconic/svg/caret-bottom.svg">
15 16
 		    <ul>
16
-            <li><a href="/account/1">Profile</a></li>
17
+            <li><a href="/account/{{authenticated_account_id}}">Profile</a></li>
17 18
             <li><a href="/logout">Logout</a></li>
18 19
             </ul>
19 20
 		    {% else %}

Loading…
Annulla
Salva