Skip to content

Commit

Permalink
basic css
Browse files Browse the repository at this point in the history
  • Loading branch information
warycat committed Dec 18, 2020
1 parent 9ab34d0 commit c252dea
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 38 deletions.
2 changes: 1 addition & 1 deletion infra/rustgym-nginx.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
server_name rustgym.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
Expand Down
27 changes: 8 additions & 19 deletions infra/vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
name: nginx
state: latest
become: yes
- name: stop nginx
service:
name: nginx
state: stopped
become: yes
- name: copy nginx config
copy:
src: rustgym-nginx.cfg
Expand All @@ -32,26 +27,16 @@
- name: start nginx
service:
name: nginx
state: started
state: restarted
become: yes
- name: create version dir
file:
path: '/home/rustgym/{{TAG}}'
state: directory
mode: '0755'
- name: download rustgym sqlite
get_url:
url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym.sqlite'
dest: /home/rustgym/rustgym.sqlite
- name: download rustgym archive
get_url:
url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym.tar.gz'
dest: /home/rustgym/rustgym.tar.gz
- name: unarchive rustgym
unarchive:
src: /home/rustgym/rustgym.tar.gz
dest: '/home/rustgym/{{TAG}}'
remote_src: yes
url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym-server'
dest: /home/rustgym/rustgym-server
- name: Get running processes list from remote host
ignore_errors: yes
shell: "ps -few | grep rustgym-server | awk '{print $2}'"
Expand All @@ -70,6 +55,10 @@
ignore_errors: yes
shell: "kill -9 {{ item }}"
with_items: "{{ rustgym_processes.results | select('failed') | map(attribute='item') | list }}"
- name: Add permition
file:
path: '/home/rustgym/rustgym-server'
mode: a+x
- name: start rustgym
shell: 'TAG={{TAG}} /home/rustgym/{{TAG}}/target/release/rustgym-server >> /home/rustgym/rustgym.log &>> /home/rustgym/rustgym.error.log &'
shell: 'TAG={{TAG}} /home/rustgym/rustgym-server >> /home/rustgym/rustgym.log &>> /home/rustgym/rustgym.error.log &'

2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::env;
async fn main() -> std::io::Result<()> {
let pool = db::init_pool(DATABASE_URL).expect("Failed to create pool");
let tag = env::var("TAG").unwrap_or_default();
let title = "RustGym".to_string();
let title = "RUST_GYM".to_string();
println!("rustgym server {}", tag);
HttpServer::new(move || {
App::new()
Expand Down
16 changes: 16 additions & 0 deletions server/templates/base.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/base.min.css" />
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/components.min.css" />
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/[email protected]/dist/typography.min.css"/>
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^1.5/dist/utilities.min.css" />
{% block head %}{% endblock %}
</head>
<body>
<div id="content" class="sm:container sm:mx-auto prose" >
{% block content %}{% endblock %}
</div>
</body>
</html>
12 changes: 10 additions & 2 deletions server/templates/home.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<h1>{{app.title}} {{app.tag}}</h1>
{% extends "base.j2" %}

{% block title %}
{{app.title}}
{% endblock %}

{% block content %}
<h1><a href="/">{{app.title}} {{app.tag}}</a></h1>
<div><a href="https://github.com/warycat/rustgym">Github</a></div>
<div><a href="leetcode/">Leetcode</a></div>
<div><a href="https://github.com/warycat/rustgym">Github</a></div>
{% endblock %}
42 changes: 27 additions & 15 deletions server/templates/leetcode-index.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<h1><a href="/">{{app.title}} {{app.tag}}</a></h1>
<div>Leetcode</div>
<div><a href="https://github.com/warycat/rustgym">Github</a></div>
<table>
{% for row in rows %}
<tr>
<td>
{{row.qid}}
</td>
<td>
<a href="{{row.qid}}"> {{row.title}}</a>
</td>
</tr>
{% endfor %}
</table>
{% extends "home.j2" %}

{% block content %}
<h1><a href="/">{{app.title}} {{app.tag}}</a></h1>
<div><a href="https://github.com/warycat/rustgym">Github</a></div>
<div>Leetcode</div>
<table class="table-auto border-collapse border border-black-800">
<tbody>
<thead>
<tr>
<th class="border border-black-600 text-center">id</th>
<th class="border border-black-600">Leetcode</th>
</tr>
</thead>
{% for row in rows %}
<tr>
<td class="border border-black-600 text-center">
{{row.qid}}
</td>
<td class="border border-black-600">
<a href="{{row.qid}}"> {{row.title}}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

0 comments on commit c252dea

Please sign in to comment.