Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IndexPage.csp Fixed indentation and remove excessive lines. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions backend/templates/IndexPage.csp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
<p>
Run your application anywhere, knowing it is as fast as it could be.
</p>

<p>
<el-button type="success" onclick=" window.open('https://github.com/drogonframework/drogon/releases','_blank')">View releases</el-button>
<el-button type="primary" onclick=" window.open('https://github.com/drogonframework/drogon','_blank')">On GitHub</el-button>
</p>
</section>
</el-col>
</el-row>

<main>
<section class="features_secion">
<div class="exclusive-line">
Expand Down Expand Up @@ -97,48 +97,48 @@
</el-row>
</div>
</section>

<section>
<div class="exclusive-line">
<h2>Code snippets</h2>
<h3>Hello World</h3>
<pre><code class="c++">using Callback = std::function&lt;void (const HttpResponsePtr &)&gt; ;

app().registerHandler("/", [](const HttpRequestPtr& req, Callback &&callback)
{
app().registerHandler("/", [](const HttpRequestPtr& req, Callback &&callback)
{
auto resp = HttpResponse::newHttpResponse();
resp->setBody("Hello World");
callback(resp);
});</code></pre>
});</code></pre>
Comment on lines 105 to +112
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albaropereyra22 This lack of space is intended. These are C++ shown within a <pre> block. Which does not perform space collapsing. When added, theses indents will also show up in the web page.

Please revert the changes within pre blocks.

<div class="exclusive-line" style="min-height: 2em"></div>
<h3>File upload</h3>
<pre><code class="c++">app().registerHandler("/upload", [](const HttpRequestPtr& req, Callback &&callback))
{
{
MultiPartParser fileUpload;
if (fileUpload.parse(req) != 0 || fileUpload.getFiles().size() == 0) {
// The framework handles an exception by logging it, and
// by responding to the client with an HTTP 500 status code.
throw std::runtime_error("Something went wrong");
}

auto &file = fileUpload.getFiles()[0];
file.save();
callback(HttpResponse::newHttpResponse());
});</code></pre>
});</code></pre>
<div class="exclusive-line" style="min-height: 2em"></div>
<h3>DB with coroutines</h3>
<pre><code class="c++">app().registerHandler("/get_num_users", [](HttpRequestPtr req) -&gt; Task&lt;HttpResponsePtr&gt;
{
{
auto client = app().getDbClient();
auto result = co_await client->execSqlCoro("SELECT COUNT(*) FROM users;");

auto resp = HttpResponse::newHttpResponse();
resp->setBody(std::to_string(result[0][0].as&lt;size_t&gt;()));
co_return resp;
});</code></pre>
});</code></pre>
<div>
</section>

<section>
<div class="exclusive-line">
<h2>Join Us</h2>
Expand All @@ -164,12 +164,12 @@ app().registerHandler("/", [](const HttpRequestPtr& req, Callback &&callback)
</div>
<el-col>
</el-row>

<p>We also want to thank everyone whom contributed to the project:</p>
<img v-for="link in contributor_avatar_link" v-bind:src="link" class="contributor-icon">
</section>
</main>

<footer>
<el-row>
<el-col>
Expand Down Expand Up @@ -200,6 +200,5 @@ app().registerHandler("/", [](const HttpRequestPtr& req, Callback &&callback)
app.mount("#app");
hljs.highlightAll();
</script>
</body>
</body>
</html>