- Use a plain HTML flask template for the main links page - Move password and port to environment variables - Relative paths for AJAX requests - Add a simple build scriptmerge-requests/30/merge
parent
2fabf06e94
commit
82a726ec60
@ -0,0 +1,15 @@ |
||||
### Steps to Deploy |
||||
- move contents of frontend/ to /srv/www-csc-links/ |
||||
- create a `.env` file in backend/ with following contents: |
||||
``` |
||||
PASSWORD=... |
||||
PORT=... |
||||
``` |
||||
- run the following in backend/: |
||||
``` |
||||
python3 -m venv venv |
||||
source venv/bin/activate |
||||
pip install -r requirements.txt |
||||
``` |
||||
- run python app in backend/ (with the virtual env activated) |
||||
- edit the `.htaccess` file in /srv/www-csc-links/ to point to the running python application |
@ -0,0 +1,48 @@ |
||||
<html> |
||||
<head> |
||||
<meta name="viewport" content="width=device-width"/> |
||||
<meta charSet="utf-8"/> |
||||
<title>@uwcsclub | LinkList</title> |
||||
<link rel="preconnect" href="https://fonts.gstatic.com"> |
||||
<link href="https://fonts.googleapis.com/css2?family=Karla:wght@700&display=swap" rel="stylesheet"> |
||||
<link href="index.out.css" rel="stylesheet"> |
||||
<script> |
||||
const handleClick = function(name, url) { |
||||
fetch("api/clicks", { |
||||
method: "POST", |
||||
headers: { |
||||
"Content-Type": "application/json", |
||||
}, |
||||
body: JSON.stringify({ name, url }), |
||||
}) |
||||
return true; |
||||
} |
||||
</script> |
||||
</head> |
||||
|
||||
<body> |
||||
<div id="__next"> |
||||
<div class="text-s flex flex-col items-center w-full top-6 font-karla"> |
||||
<img class="mb-3" src="images/csc-logo.png" alt="CSC Logo" width="100px" /> |
||||
<h1 class="font-bold">@uwcsclub</h1> |
||||
<ul class="flex flex-col my-6 w-full"> |
||||
{% for link in links_list %} |
||||
<li class="w-full flex justify-center"> |
||||
<a |
||||
class="btn bg-gray-450 p-3 text-white font-karla font-bold text-center self-center my-1.5 |
||||
hover:bg-white hover:text-black border-2 border-gray-800 transition duration-300 ease-in-out |
||||
w-11/12 sm:w-4/12 min-h-link" |
||||
href="{{ link['url'] }}" |
||||
target="_blank" |
||||
rel="noreferrer" |
||||
onclick="return handleClick("{{ link['name'] }}", "{{ link['url'] }}")" |
||||
> |
||||
{{ link["name"] }} |
||||
</a> |
||||
</li> |
||||
{% endfor %} |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,22 @@ |
||||
#!/usr/bin/env bash |
||||
rm -rf build |
||||
mkdir build |
||||
|
||||
# Build Frontend |
||||
cd frontend/public |
||||
NODE_ENV=production npx tailwindcss-cli@latest build index.in.css -o index.out.css |
||||
cd .. |
||||
npm run build && npm run export |
||||
cd .. |
||||
mv frontend/out build/frontend |
||||
|
||||
# Backend |
||||
cd backend |
||||
source venv/bin/activate |
||||
if [ ! -f links.db ]; then |
||||
python3 setup_db.py |
||||
fi |
||||
cd .. |
||||
rsync -ax --exclude venv backend/ build/backend |
||||
|
||||
cp README-deploy.md build |
@ -1,23 +0,0 @@ |
||||
import React from "react"; |
||||
import { GetStaticProps } from "next"; |
||||
import { Link, Links } from "components/Links"; |
||||
|
||||
export const getStaticProps: GetStaticProps<Props> = async () => { |
||||
const res = await fetch(`${process.env.DEV_URL}/links`); |
||||
const links = await res.json(); |
||||
|
||||
return { |
||||
props: { links }, |
||||
revalidate: 60, |
||||
}; |
||||
}; |
||||
|
||||
interface Props { |
||||
links: Link[]; |
||||
} |
||||
|
||||
const Home: React.FC<Props> = ({ links }) => { |
||||
return <Links links={links} logClicks={true} />; |
||||
}; |
||||
|
||||
export default Home; |
@ -0,0 +1,5 @@ |
||||
RewriteEngine On |
||||
|
||||
RewriteCond %{SCRIPT_FILENAME} !-d |
||||
RewriteCond %{SCRIPT_FILENAME} !-f |
||||
RewriteRule "^api/(.*)$" "http://corn-syrup:5730/$1" [P] |
Before Width: | Height: | Size: 15 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
@ -0,0 +1,17 @@ |
||||
@tailwind base; |
||||
@tailwind components; |
||||
@tailwind utilities; |
||||
|
||||
input, |
||||
button { |
||||
outline: none; |
||||
} |
||||
|
||||
/* NextJS reset styles https://gist.github.com/dmurawsky/d45f068097d181c733a53687edce1919 */ |
||||
html, |
||||
body, |
||||
body > div:first-child, |
||||
div#__next, |
||||
div#__next > div { |
||||
height: 100%; |
||||
} |
@ -0,0 +1,58 @@ |
||||
// eslint-disable-next-line no-undef
|
||||
module.exports = { |
||||
purge: { |
||||
content: [ |
||||
"../../backend/templates/template.html", |
||||
], |
||||
// These options are passed through directly to PurgeCSS
|
||||
options: { |
||||
keyframes: true, |
||||
fontFace: true, |
||||
}, |
||||
}, |
||||
darkMode: false, // or 'media' or 'class'
|
||||
theme: { |
||||
fontFamily: { |
||||
body: ["Karla", "sans-serif"], |
||||
}, |
||||
extend: { |
||||
colors: { |
||||
analytics: { |
||||
"view-icon": "#39e09b", |
||||
"click-icon": "#8a86e5", |
||||
}, |
||||
gray: { |
||||
450: "#3d3b3c", |
||||
}, |
||||
}, |
||||
fontFamily: { |
||||
sans: ["Karla", "Helvetica", "Ubuntu", "sans-serif"], |
||||
karla: ["Karla", "Verdana", "sans-serif"], |
||||
}, |
||||
fontSize: { |
||||
s: ".82rem", |
||||
}, |
||||
screens: { |
||||
"lt-lg": "992px", |
||||
}, |
||||
flex: { |
||||
analytics: "1 0 0", |
||||
chevron: "0 0 16px", |
||||
}, |
||||
borderRadius: { |
||||
preview: "3.2rem", |
||||
}, |
||||
borderWidth: { |
||||
preview: "0.75rem", |
||||
}, |
||||
minHeight: { |
||||
link: "48px", |
||||
}, |
||||
}, |
||||
}, |
||||
variants: { |
||||
extend: { |
||||
opacity: ["disabled"], |
||||
}, |
||||
}, |
||||
}; |
Before Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in new issue