Deploying to gh-pages from @ 6ef941f73d 🚀

This commit is contained in:
realaravinth
2021-08-13 13:40:13 +00:00
parent 38349faa10
commit 2a43ab6933
78 changed files with 240 additions and 217 deletions

View File

@@ -188,7 +188,7 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">handle_embedded_file</span>(<span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="ident">Asset::get</span>(<span class="ident">path</span>) {
<span class="prelude-val">Some</span>(<span class="ident">content</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span>.<span class="ident">data</span> {
<span class="ident">Cow::Borrowed</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
<span class="ident">Cow::Owned</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
};

View File

@@ -106,6 +106,18 @@
<span id="104">104</span>
<span id="105">105</span>
<span id="106">106</span>
<span id="107">107</span>
<span id="108">108</span>
<span id="109">109</span>
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
<span id="113">113</span>
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
</pre><pre class="rust">
<span class="comment">/*
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
@@ -165,24 +177,36 @@
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">TemplateOnce</span>, <span class="ident">Clone</span>)]</span>
<span class="attribute">#[<span class="ident">template</span>(<span class="ident">path</span> <span class="op">=</span> <span class="string">&quot;panel/settings/index.html&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">IndexPage</span> {
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">IndexPage</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span><span class="op">&gt;</span> {
<span class="ident">email</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
<span class="ident">secret</span>: <span class="ident">String</span>,
<span class="ident">username</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="ident">str</span>,
}
<span class="attribute">#[<span class="ident">my_codegen::get</span>(<span class="ident">path</span> <span class="op">=</span> <span class="string">&quot;crate::PAGES.panel.settings.home&quot;</span>, <span class="ident">wrap</span> <span class="op">=</span> <span class="string">&quot;crate::CheckLogin&quot;</span>)]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">settings</span>(<span class="ident">data</span>: <span class="ident">AppData</span>, <span class="ident">id</span>: <span class="ident">Identity</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">PageResult</span><span class="op">&lt;</span><span class="kw">impl</span> <span class="ident">Responder</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">username</span> <span class="op">=</span> <span class="ident">id</span>.<span class="ident">identity</span>().<span class="ident">unwrap</span>();
<span class="kw">struct</span> <span class="ident">DBResult</span> {
<span class="ident">email</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>,
<span class="ident">secret</span>: <span class="ident">String</span>,
}
<span class="kw">let</span> <span class="ident">details</span> <span class="op">=</span> <span class="macro">sqlx::query_as!</span>(
<span class="ident">IndexPage</span>,
<span class="ident">DBResult</span>,
<span class="string">r#&quot;SELECT email, secret FROM mcaptcha_users WHERE name = ($1)&quot;#</span>,
<span class="kw-2">&amp;</span><span class="ident">username</span>,
)
.<span class="ident">fetch_one</span>(<span class="kw-2">&amp;</span><span class="ident">data</span>.<span class="ident">db</span>)
.<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">details</span>.<span class="ident">render_once</span>().<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="ident">IndexPage</span> {
<span class="ident">email</span>: <span class="ident">details</span>.<span class="ident">email</span>,
<span class="ident">secret</span>: <span class="ident">details</span>.<span class="ident">secret</span>,
<span class="ident">username</span>: <span class="kw-2">&amp;</span><span class="ident">username</span>,
};
<span class="kw">let</span> <span class="ident">body</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">render_once</span>().<span class="ident">unwrap</span>();
<span class="prelude-val">Ok</span>(<span class="ident">HttpResponse::Ok</span>()
.<span class="ident">content_type</span>(<span class="string">&quot;text/html; charset=utf-8&quot;</span>)
.<span class="ident">body</span>(<span class="ident">body</span>))

View File

@@ -48,21 +48,21 @@
<span id="46">46</span>
</pre><pre class="rust">
<span class="comment">/*
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
<span class="kw">use</span> <span class="ident">cache_buster::Files</span>;
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">FileMap</span> {

View File

@@ -25,25 +25,23 @@
<span id="23">23</span>
<span id="24">24</span>
<span id="25">25</span>
<span id="26">26</span>
</pre><pre class="rust">
<span class="comment">/*
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">filemap</span>;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">static_files</span>;

View File

@@ -206,21 +206,21 @@
<span id="204">204</span>
</pre><pre class="rust">
<span class="comment">/*
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
* Copyright (C) 2021 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">actix_web::body::Body</span>;
@@ -289,7 +289,7 @@
<span class="kw">fn</span> <span class="ident">handle_assets</span>(<span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="ident">Asset::get</span>(<span class="ident">path</span>) {
<span class="prelude-val">Some</span>(<span class="ident">content</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span>.<span class="ident">data</span> {
<span class="ident">Cow::Borrowed</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
<span class="ident">Cow::Owned</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
};
@@ -319,7 +319,7 @@
<span class="kw">fn</span> <span class="ident">handle_favicons</span>(<span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="ident">Favicons::get</span>(<span class="ident">path</span>) {
<span class="prelude-val">Some</span>(<span class="ident">content</span>) <span class="op">=</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span> {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">Body</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span>.<span class="ident">data</span> {
<span class="ident">Cow::Borrowed</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
<span class="ident">Cow::Owned</span>(<span class="ident">bytes</span>) <span class="op">=</span><span class="op">&gt;</span> <span class="ident">bytes</span>.<span class="ident">into</span>(),
};