File tree 13 files changed +94
-104
lines changed
13 files changed +94
-104
lines changed Original file line number Diff line number Diff line change 32
32
just dev-server &
33
33
pid2=$!
34
34
trap " kill $pid1 $pid2" EXIT
35
- wait $pid1 $pid2
35
+ wait $pid1 $pid2
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ pub async fn blog_by_slug(
82
82
State ( state) : State < Arc < AppState > > ,
83
83
Extension ( current_user) : Extension < Option < User > > ,
84
84
) -> Result < Html < String > , StatusCode > {
85
- let template = format ! ( "articles/{}/body.html " , slug) ;
85
+ let template = format ! ( "articles/{}/body.md " , slug) ;
86
86
87
87
match state. tera . get_template ( & template) {
88
88
Ok ( _) => {
Original file line number Diff line number Diff line change @@ -11,18 +11,16 @@ use serde::{Deserialize, Serialize};
11
11
use tera:: Context ;
12
12
use tokio_stream:: wrappers:: ReceiverStream ; // This brings the necessary stream combinators into scope
13
13
14
- use std:: { sync:: Arc } ;
14
+ use std:: sync:: Arc ;
15
15
16
16
use crate :: {
17
17
ai:: stream:: { generate_sse_stream, list_engines, GenerationEvent } ,
18
- data:: model:: { ChatMessagePair } ,
18
+ data:: model:: ChatMessagePair ,
19
19
AppState , User ,
20
20
} ;
21
21
22
-
23
22
use tokio_stream:: StreamExt as TokioStreamExt ;
24
23
25
-
26
24
pub enum ChatError {
27
25
Other ,
28
26
InvalidAPIKey ,
@@ -275,8 +273,6 @@ pub async fn chat_generate(
275
273
}
276
274
GenerationEvent :: End ( text) => {
277
275
println ! ( "accumulated: {:?}" , accumulated) ;
278
- println ! ( "accumulated: {:?}" , accumulated) ;
279
- println ! ( "accumulated: {:?}" , accumulated) ;
280
276
281
277
state_clone
282
278
. chat_repo
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ pub fn app_router(state: Arc<AppState>) -> Router {
32
32
. layer ( axum:: middleware:: from_fn ( valid_openai_api_key) )
33
33
. layer ( axum:: middleware:: from_fn ( auth) ) ;
34
34
35
+ let settings_router = Router :: new ( )
36
+ . route ( "/" , get ( settings) . post ( settings_openai_api_key) )
37
+ . layer ( axum:: middleware:: from_fn ( auth) ) ;
38
+
35
39
Router :: new ( )
36
40
. route ( "/" , get ( app) )
37
41
. route ( "/error" , get ( error) )
@@ -40,7 +44,7 @@ pub fn app_router(state: Arc<AppState>) -> Router {
40
44
. route ( "/logout" , get ( logout) )
41
45
. route ( "/blog" , get ( blog) )
42
46
. route ( "/blog/:slug" , get ( blog_by_slug) )
43
- . route ( "/settings" , get ( settings) . post ( settings_openai_api_key) )
44
47
. nest ( "/chat" , chat_router)
48
+ . nest ( "/settings" , settings_router)
45
49
. with_state ( state. clone ( ) )
46
50
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # Test rendering markdown server side with Rust and Comrak
2
+
3
+ Just a simple test to render markdown articles to build a simple blogging system on a website.
4
+
5
+ ## Section 1
6
+
7
+ This is section 1.
8
+
9
+ ## Section 2
10
+
11
+ Here is a list:
12
+
13
+ - Item 1
14
+ - Item 2
15
+ - Item 3
Original file line number Diff line number Diff line change 1
- {% macro feature_card(title, points) %}
1
+ {% import "components/icon.html" as macros %}
2
+
3
+ {% macro feature_card(title, points, icon_name) %}
2
4
< div class ="relative pl-16 ">
3
5
< dt class ="text-base font-semibold leading-7 text-gray-900 ">
4
- < div class ="absolute left-0 top-0 flex h-10 w-10 items-center justify-center rounded-lg bg-indigo-600 ">
5
- < svg class ="h-6 w-6 text-white " fill ="none " viewBox ="0 0 24 24 " stroke-width ="1.5 " stroke ="currentColor "
6
- aria-hidden ="true ">
7
- < path stroke-linecap ="round " stroke-linejoin ="round "
8
- d ="M12 16.5V9.75m0 0l3 3m-3-3l-3 3M6.75 19.5a4.5 4.5 0 01-1.41-8.775 5.25 5.25 0 0110.233-2.33 3 3 0 013.758 3.848A3.752 3.752 0 0118 19.5H6.75z " />
9
- </ svg >
6
+ < div
7
+ class ="text-white absolute left-0 top-0 flex h-10 w-10 items-center justify-center rounded-lg bg-indigo-600 ">
8
+ {{ macros::icon(name=icon_name, size="32")}}
10
9
</ div >
11
10
{{ title }}
12
11
</ dt >
Original file line number Diff line number Diff line change 1
1
<!-- a fixed header bar in tailwind -->
2
2
< header class ="z-50 fixed h-[60px] w-full text-white bg-indigo-600 t-0 l-0 flex items-center justify-between px-8 ">
3
- < a class ="w-1/3 " href ="/ "> RustGPT</ a >
3
+ < div class ="flex items-center gap-4 w-1/3 ">
4
+ < a class ="mr-8 font-bold " href ="/ "> RustGPT</ a >
5
+
6
+ < div class ="flex gap-4 items-center " title ="GitHub Repository ">
7
+ < a class ="flex gap-2 items-center text-sm hover:underline " href ="https://github.com/bitswired/RustGPT "
8
+ target ="_blank ">
9
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="24 " height ="24 " viewBox ="0 0 32 32 ">
10
+ < path fill ="currentColor " fill-rule ="evenodd "
11
+ d ="M16 2a14 14 0 0 0-4.43 27.28c.7.13 1-.3 1-.67v-2.38c-3.89.84-4.71-1.88-4.71-1.88a3.71 3.71 0 0 0-1.62-2.05c-1.27-.86.1-.85.1-.85a2.94 2.94 0 0 1 2.14 1.45a3 3 0 0 0 4.08 1.16a2.93 2.93 0 0 1 .88-1.87c-3.1-.36-6.37-1.56-6.37-6.92a5.4 5.4 0 0 1 1.44-3.76a5 5 0 0 1 .14-3.7s1.17-.38 3.85 1.43a13.3 13.3 0 0 1 7 0c2.67-1.81 3.84-1.43 3.84-1.43a5 5 0 0 1 .14 3.7a5.4 5.4 0 0 1 1.44 3.76c0 5.38-3.27 6.56-6.39 6.91a3.33 3.33 0 0 1 .95 2.59v3.84c0 .46.25.81 1 .67A14 14 0 0 0 16 2Z " />
12
+ </ svg >
13
+ < p >
14
+ GitHub
15
+ </ p >
16
+ </ a >
17
+
18
+ < a class ="flex gap-2 items-center text-sm hover:underline " href ="https://discord.gg/MqG5Vh8s "
19
+ target ="_blank ">
20
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="24 " height ="24 " viewBox ="0 0 32 32 ">
21
+ < path fill ="currentColor "
22
+ d ="M25.7 7.1C23.9 6.3 22 5.7 20 5.3h-.1c-.2.4-.5 1-.7 1.5c-2.2-.3-4.3-.3-6.4 0c-.2-.5-.5-1-.7-1.5H12c-2 .3-3.9.9-5.7 1.8C2.7 12.5 1.7 17.8 2.2 23v.1c2.4 1.8 4.7 2.8 7 3.5h.1c.5-.7 1-1.5 1.4-2.3v-.1c-.8-.3-1.5-.6-2.2-1c-.1 0-.1-.1 0-.1c.1-.1.3-.2.4-.3H9c4.6 2.1 9.5 2.1 14.1 0h.1c.1.1.3.2.4.3c.1 0 0 .1 0 .1c-.7.4-1.4.8-2.2 1c0 0-.1.1 0 .1c.4.8.9 1.6 1.4 2.3h.1c2.3-.7 4.6-1.8 7-3.5V23c.6-6-1-11.2-4.2-15.9zM11.4 19.9c-1.4 0-2.5-1.3-2.5-2.8s1.1-2.8 2.5-2.8s2.5 1.3 2.5 2.8c0 1.5-1.1 2.8-2.5 2.8zm9.3 0c-1.4 0-2.5-1.3-2.5-2.8s1.1-2.8 2.5-2.8s2.5 1.3 2.5 2.8c0 1.5-1.1 2.8-2.5 2.8z " />
23
+ </ svg >
24
+ < p >
25
+ Discord
26
+ </ p >
27
+ </ a >
28
+ </ div >
29
+ </ div >
4
30
5
31
< nav class ="w-1/3 flex items-center justify-center p-6 lg:px-8 " aria-label ="Global ">
6
32
14
40
15
41
< div class ="w-1/3 ml-auto flex justify-end items-center ">
16
42
43
+
17
44
{% if current_user and current_user.email %}
18
45
< div >
19
46
{{ current_user.email }}
Original file line number Diff line number Diff line change
1
+ {% macro icon(name, size) %}
2
+
3
+ {% if name == "rust" %}
4
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="{{ size }} " height ="{{ size }} " viewBox ="0 0 32 32 ">
5
+ < path fill ="currentColor "
6
+ d ="m31.584 15.615l-1.329-.823a6.54 6.54 0 0 0-.036-.385l1.141-1.063a.463.463 0 0 0-.152-.765l-1.459-.543a8.832 8.832 0 0 0-.113-.38l.905-1.26a.454.454 0 0 0-.296-.719l-1.537-.251c-.057-.115-.12-.229-.181-.344l.645-1.416a.45.45 0 0 0-.036-.443a.464.464 0 0 0-.396-.203l-1.563.057a6.608 6.608 0 0 0-.245-.303l.36-1.516a.46.46 0 0 0-.552-.552l-1.516.36a5.584 5.584 0 0 0-.303-.245l.057-1.563a.455.455 0 0 0-.645-.432l-1.416.645c-.115-.061-.229-.124-.349-.181l-.251-1.537a.458.458 0 0 0-.719-.296l-1.26.905c-.125-.041-.251-.077-.375-.113L19.415.796a.458.458 0 0 0-.76-.157l-1.063 1.147a7.186 7.186 0 0 0-.391-.041L16.384.421a.454.454 0 0 0-.776 0l-.823 1.324c-.131.009-.26.025-.385.041L13.337.639a.46.46 0 0 0-.765.157l-.543 1.453c-.129.036-.249.077-.38.113l-1.26-.905a.458.458 0 0 0-.719.296L9.419 3.29c-.115.057-.228.12-.343.181l-1.417-.645a.455.455 0 0 0-.645.432l.052 1.563c-.099.079-.199.161-.297.245l-1.52-.36a.458.458 0 0 0-.548.552l.355 1.516c-.084.099-.161.197-.245.303L3.254 7.02a.456.456 0 0 0-.432.645l.647 1.416l-.188.344l-1.536.251a.46.46 0 0 0-.297.719l.912 1.26a8.585 8.585 0 0 0-.115.38l-1.459.543a.46.46 0 0 0-.151.765l1.14 1.063a6.621 6.621 0 0 0-.036.385l-1.328.823a.449.449 0 0 0 0 .771l1.328.823c.009.131.02.261.036.385l-1.14 1.068a.454.454 0 0 0 .151.76l1.459.548c.036.124.072.249.115.375l-.912 1.26a.458.458 0 0 0 .301.719l1.537.251c.057.115.12.229.183.344l-.647 1.416a.456.456 0 0 0 .432.645l1.557-.052c.084.1.161.199.251.297l-.36 1.521a.456.456 0 0 0 .548.547l1.52-.355c.099.084.199.161.303.245l-.057 1.557a.453.453 0 0 0 .645.432l1.417-.645c.115.061.228.124.343.187l.256 1.537a.455.455 0 0 0 .713.296l1.265-.911c.125.041.251.077.375.113l.548 1.459a.452.452 0 0 0 .76.152l1.063-1.141c.129.016.255.032.385.041l.823 1.328a.457.457 0 0 0 .776 0l.823-1.328c.131-.009.256-.025.385-.041l1.063 1.141a.456.456 0 0 0 .76-.152l.548-1.459c.124-.036.249-.072.375-.113l1.26.911a.456.456 0 0 0 .719-.296l.251-1.537c.12-.063.235-.125.349-.187l1.416.645a.457.457 0 0 0 .645-.432l-.057-1.557c.105-.084.204-.161.297-.245l1.521.355a.46.46 0 0 0 .552-.547l-.36-1.521c.084-.099.167-.197.245-.297l1.563.052a.455.455 0 0 0 .432-.645l-.645-1.416c.061-.115.124-.229.181-.344l1.537-.251a.458.458 0 0 0 .296-.719l-.905-1.26l.113-.375l1.453-.548a.455.455 0 0 0 .157-.76l-1.141-1.068c.011-.124.027-.255.036-.385l1.329-.823a.45.45 0 0 0 0-.771zm-8.881 11c-1.224-.26-.833-2.099.396-1.839a.94.94 0 0 1-.396 1.839zm-.448-3.047a.853.853 0 0 0-1.015.661l-.475 2.192A11.485 11.485 0 0 1 16 27.453a11.52 11.52 0 0 1-4.864-1.073l-.475-2.197a.848.848 0 0 0-1.016-.656l-1.937.411a10.809 10.809 0 0 1-1.005-1.183h9.443c.105 0 .177-.015.177-.115v-3.337c0-.1-.072-.115-.177-.115h-2.765v-2.12h2.989c.271 0 1.459.077 1.833 1.593c.12.464.381 1.979.557 2.464c.177.547.901 1.629 1.672 1.629h4.704a.98.98 0 0 0 .171-.015a11.09 11.09 0 0 1-1.067 1.255zM9.197 26.573a.95.95 0 0 1-1.119-.724a.933.933 0 0 1 .724-1.115a.94.94 0 0 1 .395 1.839zM5.615 12.047a.945.945 0 0 1-.464 1.271a.948.948 0 0 1-1.255-.505c-.459-1.124 1.192-1.859 1.719-.765zm-1.099 2.609l2.02-.896c.433-.192.625-.697.433-1.129l-.417-.943h1.641v7.38H4.89a11.572 11.572 0 0 1-.375-4.412zm8.869-.713v-2.177h3.896c.203 0 1.421.235 1.421 1.147c0 .76-.937 1.031-1.703 1.031zm14.167 1.958c0 .287-.011.572-.031.853h-1.188c-.12 0-.167.079-.167.199v.541c0 1.281-.719 1.557-1.355 1.631c-.604.068-1.271-.251-1.353-.62c-.355-2-.948-2.427-1.885-3.167c1.161-.74 2.369-1.823 2.369-3.281c0-1.573-1.079-2.563-1.812-3.047c-1.032-.683-2.172-.817-2.48-.817H7.395a11.55 11.55 0 0 1 6.459-3.652l1.448 1.521a.854.854 0 0 0 1.208.025l1.615-1.547a11.55 11.55 0 0 1 7.911 5.631l-1.109 2.5a.863.863 0 0 0 .437 1.131l2.131.947c.036.381.052.761.052 1.152zM15.303 3.255c.905-.864 2.203.495 1.296 1.36c-.901.781-2.115-.495-1.296-1.36zm10.984 8.838a.937.937 0 0 1 1.235-.479c.771.339.744 1.437-.037 1.74c-.787.301-1.541-.495-1.197-1.261z " />
7
+ </ svg >
8
+
9
+ {% elif name == "code-diamond" %}
10
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="{{ size }} " height ="{{ size }} " viewBox ="0 0 256 256 ">
11
+ < path fill ="currentColor "
12
+ d ="M128 152a8 8 0 0 1-8 8h-8v48a8 8 0 0 1-16 0v-48h-8a8 8 0 0 1 0-16h32a8 8 0 0 1 8 8Zm-64-8a8 8 0 0 0-8 8v20H40v-20a8 8 0 0 0-16 0v56a8 8 0 0 0 16 0v-20h16v20a8 8 0 0 0 16 0v-56a8 8 0 0 0-8-8Zm176 56h-12v-48a8 8 0 0 0-16 0v56a8 8 0 0 0 8 8h20a8 8 0 0 0 0-16Zm-45.86-55.71a8 8 0 0 0-9 3.59L168 176.45l-17.14-28.57A8 8 0 0 0 136 152v56a8 8 0 0 0 16 0v-27.12l9.14 15.24a8 8 0 0 0 13.72 0l9.14-15.24V208a8 8 0 0 0 16 0v-56a8 8 0 0 0-5.86-7.71ZM208 120a8 8 0 0 1-8-8V96h-48a8 8 0 0 1-8-8V40H56v72a8 8 0 0 1-16 0V40a16 16 0 0 1 16-16h96a8 8 0 0 1 5.66 2.34l56 56A8 8 0 0 1 216 88v24a8 8 0 0 1-8 8Zm-19.31-40L160 51.31V80Z " />
13
+ </ svg >
14
+ {% elif name == "tailwind" %}
15
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="{{ size }} " height ="{{ size }} " viewBox ="0 0 24 24 ">
16
+ < path fill ="currentColor "
17
+ d ="M12 6c-2.67 0-4.33 1.33-5 4c1-1.33 2.17-1.83 3.5-1.5c.76.19 1.31.74 1.91 1.35c.98 1 2.09 2.15 4.59 2.15c2.67 0 4.33-1.33 5-4c-1 1.33-2.17 1.83-3.5 1.5c-.76-.19-1.3-.74-1.91-1.35C15.61 7.15 14.5 6 12 6m-5 6c-2.67 0-4.33 1.33-5 4c1-1.33 2.17-1.83 3.5-1.5c.76.19 1.3.74 1.91 1.35C8.39 16.85 9.5 18 12 18c2.67 0 4.33-1.33 5-4c-1 1.33-2.17 1.83-3.5 1.5c-.76-.19-1.3-.74-1.91-1.35C10.61 13.15 9.5 12 7 12Z " />
18
+ </ svg >
19
+ {% elif name == "just" %}
20
+ < svg xmlns ="http://www.w3.org/2000/svg " width ="{{ size }} " height ="{{ size }} " viewBox ="0 0 24 24 ">
21
+ < path fill ="currentColor "
22
+ d ="M5 9h2.31l.32-3h2l-.32 3h2l.32-3h2l-.32 3H15v2h-1.9l-.2 2H15v2h-2.31l-.32 3h-2l.32-3h-2l-.32 3h-2l.32-3H5v-2h1.9l.2-2H5V9m4.1 2l-.2 2h2l.2-2M19 6h-2v8h2m0 2h-2v2h2Z " />
23
+ </ svg >
24
+
25
+ {% endif %}
26
+
27
+ {% endmacro input %}
You can’t perform that action at this time.
0 commit comments