...
This commit is contained in:
parent
951af7dec7
commit
4a87392194
@ -1,6 +1,6 @@
|
||||
# Actix MVC App
|
||||
# Zanzibar Autonomous Zone
|
||||
|
||||
A Rust web application built with Actix Web, Tera templates, and Bootstrap 5.3.5, following the MVC (Model-View-Controller) architectural pattern.
|
||||
Convenience, Safety and Privacy
|
||||
|
||||
## Features
|
||||
|
||||
@ -42,8 +42,8 @@ actix_mvc_app/
|
||||
|
||||
1. Clone the repository:
|
||||
```
|
||||
git clone https://github.com/yourusername/actix_mvc_app.git
|
||||
cd actix_mvc_app
|
||||
git clone https://github.com/yourusername/zanzibar-autonomous-zone.git
|
||||
cd zanzibar-autonomous-zone
|
||||
```
|
||||
|
||||
2. Build the project:
|
||||
|
@ -1,14 +1,14 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}About - Actix MVC App{% endblock %}
|
||||
{% block title %}About - Zanzibar Autonomous Zone{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title">About Actix MVC App</h1>
|
||||
<p class="card-text">This is a sample application demonstrating how to build a web application using Rust with an MVC architecture.</p>
|
||||
<h1 class="card-title">About Zanzibar Autonomous Zone</h1>
|
||||
<p class="card-text">Convenience, Safety and Privacy</p>
|
||||
|
||||
<h2 class="mt-4">Technology Stack</h2>
|
||||
<div class="row">
|
||||
|
@ -3,31 +3,51 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Actix MVC App{% endblock %}</title>
|
||||
<title>{% block title %}Zanzibar Autonomous Zone{% endblock %}</title>
|
||||
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/unpoly@3.7.2/unpoly.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
||||
<style>
|
||||
/* Minimal custom CSS that can't be achieved with Bootstrap classes */
|
||||
body {
|
||||
padding-top: 50px; /* Height of the fixed header */
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 50px;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
z-index: 1030;
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.sidebar {
|
||||
width: 280px;
|
||||
width: 240px;
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
height: calc(100vh - 90px); /* Subtract header and footer height */
|
||||
top: 50px; /* Position below header */
|
||||
}
|
||||
.main-content {
|
||||
margin-left: 280px;
|
||||
margin-left: 240px;
|
||||
min-height: calc(100vh - 90px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.sidebar {
|
||||
width: 280px;
|
||||
width: 240px;
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
left: -280px;
|
||||
height: calc(100vh - 90px);
|
||||
top: 50px;
|
||||
left: -240px;
|
||||
transition: left 0.3s ease;
|
||||
z-index: 1030;
|
||||
z-index: 1020;
|
||||
}
|
||||
.sidebar.show {
|
||||
left: 0;
|
||||
@ -36,13 +56,51 @@
|
||||
</style>
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
<body class="d-flex flex-column min-vh-100">
|
||||
<body>
|
||||
<!-- Header - Full Width -->
|
||||
<header class="header bg-dark text-white">
|
||||
<div class="container-fluid d-flex justify-content-between align-items-center h-100">
|
||||
<div class="d-flex align-items-center">
|
||||
<button class="navbar-toggler d-md-none me-2" type="button" id="sidebarToggle" aria-label="Toggle navigation">
|
||||
<i class="bi bi-list text-white"></i>
|
||||
</button>
|
||||
<h5 class="mb-0">Zanzibar Autonomous Zone</h5>
|
||||
</div>
|
||||
<div>
|
||||
<ul class="navbar-nav flex-row">
|
||||
{% if user and user.id %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle"></i> {{ user.name }}
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="/tickets/new">New Ticket</a></li>
|
||||
<li><a class="dropdown-item" href="/my-tickets">My Tickets</a></li>
|
||||
<li><a class="dropdown-item" href="/governance/my-votes">My Votes</a></li>
|
||||
{% if user.role == "Admin" %}
|
||||
<li><a class="dropdown-item" href="/admin">Admin Panel</a></li>
|
||||
{% endif %}
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="/logout">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item me-2">
|
||||
<a class="nav-link text-white {% if active_page == 'login' %}active{% endif %}" href="/login">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-white {% if active_page == 'register' %}active{% endif %}" href="/register">Register</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="d-flex">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar bg-light shadow-sm border-end" id="sidebar">
|
||||
<div class="bg-dark text-white p-3">
|
||||
<h3 class="mb-0">Actix MVC App</h3>
|
||||
</div>
|
||||
<div class="py-3">
|
||||
<div class="py-2">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link d-flex align-items-center ps-3 py-2 {% if active_page == 'home' %}active fw-bold border-start border-4 border-primary bg-light{% endif %}" href="/">
|
||||
@ -94,65 +152,27 @@
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="main-content d-flex flex-column min-vh-100">
|
||||
<!-- Top Navbar -->
|
||||
<nav class="navbar navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler d-md-none" type="button" id="sidebarToggle" aria-label="Toggle navigation">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
<a class="navbar-brand d-md-none" href="/">Actix MVC App</a>
|
||||
<div class="ms-auto">
|
||||
<ul class="navbar-nav flex-row">
|
||||
{% if user and user.id %}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle"></i> {{ user.name }}
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="/tickets/new">New Ticket</a></li>
|
||||
<li><a class="dropdown-item" href="/my-tickets">My Tickets</a></li>
|
||||
<li><a class="dropdown-item" href="/governance/my-votes">My Votes</a></li>
|
||||
{% if user.role == "Admin" %}
|
||||
<li><a class="dropdown-item" href="/admin">Admin Panel</a></li>
|
||||
{% endif %}
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="/logout">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item me-2">
|
||||
<a class="nav-link text-white {% if active_page == 'login' %}active{% endif %}" href="/login">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-white {% if active_page == 'register' %}active{% endif %}" href="/register">Register</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="main-content">
|
||||
<!-- Page Content -->
|
||||
<main class="container py-4 flex-grow-1">
|
||||
<main class="container py-3">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="bg-dark text-white py-4 mt-auto">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h5>Actix MVC App</h5>
|
||||
<p>A Rust web application using Actix Web, Tera templates, and Bootstrap.</p>
|
||||
</main>
|
||||
</div>
|
||||
<div class="col-md-6 text-md-end">
|
||||
<p>© {{ now(year=true) }} Actix MVC App. All rights reserved.</p>
|
||||
</div>
|
||||
|
||||
<!-- Footer - Full Width -->
|
||||
<footer class="footer bg-dark text-white mt-auto">
|
||||
<div class="container-fluid d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span>Convenience, Safety and Privacy</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>© {{ now(year=true) }} Zanzibar Autonomous Zone. All rights reserved.</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://unpkg.com/unpoly@3.7.2/unpoly.min.js"></script>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Contact - Actix MVC App{% endblock %}
|
||||
{% block title %}Contact - Zanzibar Autonomous Zone{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
@ -45,7 +45,7 @@
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">GitHub</h5>
|
||||
<p class="card-text">github.com/example/actix-mvc-app</p>
|
||||
<p class="card-text">github.com/example/zanzibar-autonomous-zone</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,14 +1,14 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Home - Actix MVC App{% endblock %}
|
||||
{% block title %}Home - Zanzibar Autonomous Zone{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title">Welcome to Actix MVC App</h1>
|
||||
<p class="card-text">This is a Rust web application built with:</p>
|
||||
<h1 class="card-title">Welcome to Zanzibar Autonomous Zone</h1>
|
||||
<p class="card-text">Convenience, Safety and Privacy</p>
|
||||
<ul class="list-group list-group-flush mb-4">
|
||||
<li class="list-group-item">Actix Web - A powerful, pragmatic, and extremely fast web framework for Rust</li>
|
||||
<li class="list-group-item">Tera Templates - A template engine inspired by Jinja2 and Django templates</li>
|
||||
|
@ -1,350 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Markdown Editor</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Merriweather:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--editor-bg: #f8f9fa;
|
||||
--preview-bg: #ffffff;
|
||||
--border-color: #e9ecef;
|
||||
--text-color: #212529;
|
||||
--font-mono: 'JetBrains Mono', monospace;
|
||||
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
--font-serif: 'Merriweather', Georgia, serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-sans);
|
||||
color: var(--text-color);
|
||||
line-height: 1.6;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.editor-pane, .preview-pane {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.editor-pane {
|
||||
background-color: var(--editor-bg);
|
||||
border-right: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.preview-pane {
|
||||
background-color: var(--preview-bg);
|
||||
}
|
||||
|
||||
#editor {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
background-color: var(--editor-bg);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
resize: none;
|
||||
outline: none;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#preview {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Typography for the preview pane */
|
||||
#preview h1, #preview h2, #preview h3, #preview h4, #preview h5, #preview h6 {
|
||||
margin-top: 1.5em;
|
||||
margin-bottom: 0.75em;
|
||||
font-family: var(--font-sans);
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
#preview h1 {
|
||||
font-size: 2.25rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding-bottom: 0.3em;
|
||||
}
|
||||
|
||||
#preview h2 {
|
||||
font-size: 1.75rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding-bottom: 0.3em;
|
||||
}
|
||||
|
||||
#preview h3 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
#preview h4 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
#preview p {
|
||||
margin-bottom: 1.25em;
|
||||
font-family: var(--font-serif);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
#preview a {
|
||||
color: #0366d6;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#preview a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#preview code {
|
||||
font-family: var(--font-mono);
|
||||
background-color: rgba(27, 31, 35, 0.05);
|
||||
padding: 0.2em 0.4em;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#preview pre {
|
||||
background-color: #f6f8fa;
|
||||
border-radius: 3px;
|
||||
padding: 16px;
|
||||
overflow: auto;
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
|
||||
#preview pre code {
|
||||
background-color: transparent;
|
||||
padding: 0;
|
||||
font-size: 0.9em;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#preview blockquote {
|
||||
padding: 0 1em;
|
||||
color: #6a737d;
|
||||
border-left: 0.25em solid #dfe2e5;
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
|
||||
#preview ul, #preview ol {
|
||||
padding-left: 2em;
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
|
||||
#preview li {
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
|
||||
#preview table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
|
||||
#preview table th, #preview table td {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #dfe2e5;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#preview table th {
|
||||
background-color: #f6f8fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#preview table tr:nth-child(even) {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
#preview img {
|
||||
max-width: 100%;
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
|
||||
.header {
|
||||
background-color: #ffffff;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background-color: #f1f3f5;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: 6px 12px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Markdown Editor</h1>
|
||||
<div class="header-actions">
|
||||
<button class="btn" id="copy-html">Copy HTML</button>
|
||||
<button class="btn" id="copy-markdown">Copy Markdown</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="editor-pane">
|
||||
<textarea id="editor" spellcheck="false" placeholder="Type your markdown here..."></textarea>
|
||||
</div>
|
||||
<div class="preview-pane">
|
||||
<div id="preview"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>
|
||||
// Set up marked.js options
|
||||
marked.setOptions({
|
||||
breaks: true,
|
||||
gfm: true,
|
||||
headerIds: true,
|
||||
highlight: function(code, lang) {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
|
||||
const editor = document.getElementById('editor');
|
||||
const preview = document.getElementById('preview');
|
||||
const copyHtmlBtn = document.getElementById('copy-html');
|
||||
const copyMarkdownBtn = document.getElementById('copy-markdown');
|
||||
|
||||
// Example markdown content
|
||||
const exampleMarkdown = `# Markdown Editor
|
||||
|
||||
## Introduction
|
||||
|
||||
This is a real-time markdown editor with a split-screen layout. Type markdown on the left, and see the rendered output on the right.
|
||||
|
||||
## Features
|
||||
|
||||
- **Real-time rendering**: See your changes instantly
|
||||
- **Split-screen layout**: Edit and preview side by side
|
||||
- **Beautiful typography**: Using high-quality fonts for readability
|
||||
- **Copy functionality**: Easily copy your markdown or HTML
|
||||
|
||||
## Code Example
|
||||
|
||||
\`\`\`javascript
|
||||
function renderMarkdown() {
|
||||
const markdown = editor.value;
|
||||
const html = marked.parse(markdown);
|
||||
preview.innerHTML = html;
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## Table Example
|
||||
|
||||
| Feature | Description |
|
||||
|---------|-------------|
|
||||
| Real-time Preview | See changes as you type |
|
||||
| Syntax Highlighting | Makes code easier to read |
|
||||
| Tables | Format data in rows and columns |
|
||||
| Lists | Create ordered and unordered lists |
|
||||
|
||||
## Blockquote Example
|
||||
|
||||
> The best way to predict the future is to invent it.
|
||||
>
|
||||
> — Alan Kay
|
||||
|
||||
## Image Example
|
||||
|
||||

|
||||
|
||||
## Task List
|
||||
|
||||
- [x] Create markdown editor
|
||||
- [x] Add real-time preview
|
||||
- [x] Style with nice typography
|
||||
- [ ] Add more features
|
||||
|
||||
## Math Example (if supported)
|
||||
|
||||
When $a \\ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
|
||||
$$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$
|
||||
|
||||
---
|
||||
|
||||
*Made with ❤️ using HTML, CSS, and JavaScript*`;
|
||||
|
||||
// Set initial content
|
||||
editor.value = exampleMarkdown;
|
||||
|
||||
// Function to render markdown
|
||||
function renderMarkdown() {
|
||||
const markdown = editor.value;
|
||||
const html = marked.parse(markdown);
|
||||
preview.innerHTML = html;
|
||||
}
|
||||
|
||||
// Initial render
|
||||
renderMarkdown();
|
||||
|
||||
// Real-time rendering
|
||||
editor.addEventListener('input', renderMarkdown);
|
||||
|
||||
// Copy HTML functionality
|
||||
copyHtmlBtn.addEventListener('click', function() {
|
||||
const html = preview.innerHTML;
|
||||
navigator.clipboard.writeText(html)
|
||||
.then(() => {
|
||||
alert('HTML copied to clipboard!');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to copy HTML: ', err);
|
||||
});
|
||||
});
|
||||
|
||||
// Copy Markdown functionality
|
||||
copyMarkdownBtn.addEventListener('click', function() {
|
||||
const markdown = editor.value;
|
||||
navigator.clipboard.writeText(markdown)
|
||||
.then(() => {
|
||||
alert('Markdown copied to clipboard!');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to copy Markdown: ', err);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user