-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
2,079 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::context::*; | ||
|
||
pub struct AppContext { | ||
pub title: String, | ||
pub tag: String, | ||
} | ||
|
||
impl AppContext { | ||
pub fn new(data: Data<AppData>) -> Self { | ||
let title = data.title.borrow().to_string(); | ||
let tag = data.tag.borrow().to_string(); | ||
AppContext { title, tag } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use crate::context::*; | ||
|
||
#[derive(Template, new)] | ||
#[template(path = "find.j2")] | ||
pub struct FindContext { | ||
pub app: AppContext, | ||
pub session: SessionData, | ||
pub path: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
use crate::context::*; | ||
|
||
pub struct AppContext { | ||
pub title: String, | ||
pub tag: String, | ||
} | ||
|
||
#[derive(Template, new)] | ||
#[template(path = "home.j2")] | ||
pub struct HomeContext { | ||
pub app: AppContext, | ||
pub session: SessionData, | ||
pub path: String, | ||
} | ||
|
||
impl AppContext { | ||
pub fn new(data: Data<AppData>) -> Self { | ||
let title = data.title.borrow().to_string(); | ||
let tag = data.tag.borrow().to_string(); | ||
AppContext { title, tag } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::app_data::AppData; | ||
use crate::context::*; | ||
use crate::session_data::update_session; | ||
use actix_session::Session; | ||
use actix_web::get; | ||
use actix_web::web; | ||
use actix_web::Error; | ||
use actix_web::HttpRequest; | ||
use actix_web::HttpResponse; | ||
|
||
#[get("/find")] | ||
pub async fn find( | ||
req: HttpRequest, | ||
data: web::Data<AppData>, | ||
session: Session, | ||
) -> Result<HttpResponse, Error> { | ||
let session_data = update_session(session)?; | ||
FindContext::new(AppContext::new(data), session_data, req.path().to_string()).render_wrapper() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,53 @@ | ||
{% extends "home.j2" %} | ||
{% extends "desktop.j2" %} | ||
|
||
{% block title %} | ||
{{app.title}} AdventOfCode {{description.year}} Day {{description.day}} {{description.title}} Rust Solution | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div>{{description.html|safe}}</div> | ||
<h2>Rust Solution</h2> | ||
<pre><code class="rust">{{solution.source}}</code></pre> | ||
|
||
<div class="grid grid-cols-2 flex justify-between"> | ||
<div class="flex"> | ||
<a target="_blank" href="{{description.practice_url()}}"> | ||
<button type="button" class="border border-green-500 bg-green-500 text-white rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-green-500 focus:outline-none focus:shadow-outline">Practice</button> | ||
</a> | ||
</div> | ||
|
||
<div class="flex justify-end"> | ||
<a target="_blank" href="http://twitter.com/share?text={{app.title}} AdventOfCode {{description.year}} Day {{description.day}} {{description.title}} Rust Solution&url=https://rustgym.com{{description.href()}}&hashtags=rustgym,adventofcode,rust"> | ||
<button type="button" class="border border-blue-400 bg-blue-400 text-white rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-blue-500 focus:outline-none focus:shadow-outline">Tweet</button> | ||
</a> | ||
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=rustgym.com{{description.href()}}" > | ||
<button type="button" class="border border-blue-600 bg-blue-600 text-white rounded-md px-4 py-2 m-2 transition duration-500 ease select-none hover:bg-blue-700 focus:outline-none focus:shadow-outline">Facebook</button> | ||
</a> | ||
</div> | ||
</div> | ||
<div class="component"> | ||
<div class="window" > | ||
<div class="title-bar"> | ||
<div class="title-bar-text">{{description.title}}</div> | ||
<div class="title-bar-controls"> | ||
<button aria-label="Minimize"></button> | ||
<button aria-label="Maximize"></button> | ||
<button aria-label="Close"></button> | ||
</div> | ||
</div> | ||
<div class="window-body"> | ||
<div>{{description.html|safe}}</div> | ||
<section class="field-row" style="justify-content: flex-end"> | ||
<a target="_blank" href="{{description.practice_url()}}"> | ||
<button>Practice</button> | ||
</a> | ||
<a target="_blank" href="http://twitter.com/share?text={{app.title}} AdventOfCode {{description.year}} Day {{description.day}} {{description.title}} Rust Solution&url=https://rustgym.com{{description.href()}}&hashtags=rustgym,adventofcode,rust"> | ||
<button>Tweet</button> | ||
</a> | ||
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=rustgym.com{{description.href()}}" > | ||
<button>Facebook</button> | ||
</a> | ||
<a target="_blank" href="https://github.com/warycat/rustgym/issues/new?title=AdventOfCode {{description.year}} Day {{description.day}} {{description.title}}"> | ||
<button type="button">Issue</button> | ||
</a> | ||
</section> | ||
</div> | ||
</div> | ||
|
||
<div class="window" > | ||
<div class="title-bar"> | ||
<div class="title-bar-text">{{description.title}}</div> | ||
<div class="title-bar-controls"> | ||
<button aria-label="Minimize"></button> | ||
<button aria-label="Maximize"></button> | ||
<button aria-label="Close"></button> | ||
</div> | ||
</div> | ||
<div class="window-body"> | ||
<pre><code class="rust">{{solution.source}}</code></pre> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<p>Having problems with this solution? <a href="https://github.com/warycat/rustgym/issues/new?title=AdventOfCode {{description.year}} Day {{description.day}} {{description.title}}">Click here</a> to submit an issue on github.</p> | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,47 @@ | ||
{% extends "home.j2" %} | ||
{% extends "desktop.j2" %} | ||
|
||
{% block title %} | ||
{{app.title}} AdventOfCode Rust Solutions | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<table class="table-auto"> | ||
<thead> | ||
<tr> | ||
<th>Year</th> | ||
<th>Day</th> | ||
<th>AdventOfCode {{rows.len()}} Rust Solutions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in rows %} | ||
<tr> | ||
<td> | ||
{{row.year}} | ||
</td> | ||
<td> | ||
{{row.day}} | ||
</td> | ||
<td> | ||
<a href="{{row.href()}}"> {{row.title}}</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endblock %} | ||
<div class="component"> | ||
<div class="window" > | ||
<div class="title-bar"> | ||
<div class="title-bar-text">AdventOfCode Solutions</div> | ||
<div class="title-bar-controls"> | ||
<button aria-label="Minimize"></button> | ||
<button aria-label="Maximize"></button> | ||
<button aria-label="Close"></button> | ||
</div> | ||
</div> | ||
<div class="window-body"> | ||
<table class="table-auto"> | ||
<thead> | ||
<tr> | ||
<th>Year</th> | ||
<th>Day</th> | ||
<th>AdventOfCode {{rows.len()}} Rust Solutions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in rows %} | ||
<tr> | ||
<td> | ||
{{row.year}} | ||
</td> | ||
<td> | ||
{{row.day}} | ||
</td> | ||
<td> | ||
<a href="{{row.href()}}"> {{row.title}}</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
Oops, something went wrong.