Skip to content

Commit 1cae564

Browse files
authored
Fix and Update Site (#7)
1 parent 3747d6e commit 1cae564

File tree

6 files changed

+129
-13
lines changed

6 files changed

+129
-13
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ site_name: Django Files
66
site_url: https://django-files.github.io/
77
github_url: https://github.com/django-files/django-files
88

9+
extension_github: https://github.com/django-files/web-extension
910
chrome_url: https://chromewebstore.google.com/detail/django-files/abpbiefojfkekhkjnpakpekkpeibnjej
1011
firefox_url: https://addons.mozilla.org/en-US/firefox/addon/django-files/
1112
chrome_id: abpbiefojfkekhkjnpakpekkpeibnjej

_layouts/default.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
{% endif %}
2727

2828
<link rel="icon" href="/favicon.ico" sizes="any">
29-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
30-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
29+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
30+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
3131
<link rel="stylesheet" href="/css/main.css">
3232

3333
{% if page.title == 'Screen Shots' %}
@@ -93,7 +93,21 @@
9393
</div>
9494
</footer>
9595

96-
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js" integrity="sha512-X/YkDZyjTf4wyc2Vy16YGCPHwAY8rZJY+POgokZjQB2mhIRFJCckEGc6YyX9eNsPfn0PzThEuNs+uaomE5CO6A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
96+
<button type="button" class="btn btn-outline-primary" id="back-to-top">
97+
<i class="fa-regular fa-square-caret-up"></i>
98+
</button> <!-- back-to-top -->
99+
100+
<div aria-live="polite" aria-atomic="true" class="">
101+
<div id="toast-container" class="toast-container position-fixed bottom-0 end-0 p-3"></div>
102+
</div> <!-- toast-container -->
103+
104+
<div class="d-none">
105+
<div class="toast align-items-center border-0" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="5000">
106+
<div class="toast-body small"></div>
107+
</div>
108+
</div> <!-- d-none -->
109+
110+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js" integrity="sha512-7Pi/otdlbbCR+LnW+F7PwFcSDJOuUJB3OxtEHbg4vSMvzvJjde4Po1v4BR9Gdc9aXNUNFVUY+SK51wWT8WF0Gg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
97111
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js" integrity="sha512-7O5pXpc0oCRrxk8RUfDYFgn0nO1t+jLuIOQdOMRp4APB7uZ4vSjspzp5y6YDtDs4VzUSTbWzBFZ/LKJhnyFOKw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
98112
<script type="text/javascript" src="/js/main.js"></script>
99113

css/main.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* CSS for global */
2+
3+
#back-to-top {
4+
position: fixed;
5+
bottom: 64px;
6+
right: 20px;
7+
display: none;
8+
z-index: 3;
9+
}
10+
11+
.toast-container {
12+
max-width: 260px;
13+
width: 100%;
14+
}

extension.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ <h1>{{ site.site_name }} - {{ page.title }}</h1>
1212
<img src="https://img.shields.io/chrome-web-store/users/{{ site.chrome_id }}?logo=google&logoColor=white&label=google%20users" alt="Chrome Web Store Users" style="max-width: 100%;"></a>
1313
<a href="{{ site.firefox_url }}" rel="nofollow" target="_blank">
1414
<img src="https://img.shields.io/amo/users/{{ site.firefox_id }}?logo=mozilla&label=mozilla%20users" alt="Mozilla Add-on Users" style="max-width: 100%;"></a>
15+
<a href="{{ site.chrome_url }}" rel="nofollow" target="_blank">
1516
<img src="https://img.shields.io/chrome-web-store/v/{{ site.chrome_id }}?label=chrome&logo=googlechrome" alt="Chrome Web Store Version" style="max-width: 100%;"></a>
1617
<a href="{{ site.firefox_url }}" rel="nofollow" target="_blank">
1718
<img src="https://img.shields.io/amo/v/{{ site.firefox_id }}?label=firefox&logo=firefox" alt="Mozilla Add-on Version" style="max-width: 100%;"></a>
18-
<a href="{{ site.github_url }}/releases/latest" rel="nofollow" target="_blank">
19+
<a href="{{ site.extension_github }}/releases/latest" rel="nofollow" target="_blank">
1920
<img src="https://img.shields.io/github/v/release/{{ site.github_name }}?logo=github" alt="GitHub Release Version" style="max-width: 100%;"></a>
20-
<a href="{{ site.github_url }}/blob/master/manifest.json" rel="nofollow" target="_blank">
21+
<a href="{{ site.extension_github }}/blob/master/manifest.json" rel="nofollow" target="_blank">
2122
<img src="https://img.shields.io/github/manifest-json/v/{{ site.github_name }}?filename=manifest.json&logo=json&label=manifest" alt="Manifest Version" style="max-width: 100%;"></a>
2223
</div>
2324

25+
<p class="lead" data-nosnippet><a href="#configure">Configure</a> | <a href="#setup">Setup</a> | <a href="#usage">Usage</a></p>
26+
2427
<p class="lead">
2528
Modern Chrome Web Extension and Firefox Browser Addon for Django Files to view recent uploads, shorten URLs, and upload Images, Video or Audio files with a right click.
2629
</p>
@@ -85,7 +88,7 @@ <h2 id="configure">Configure</h2>
8588
<img src="/images/extension/pin-firefox.jpg" class="img-thumbnail" alt="Chrome Pin Extension" width="320">
8689
</div>
8790

88-
<h2>Setup</h2>
91+
<h2 id="setup">Setup</h2>
8992
<p>
9093
To automatically configure the web extension to work with your Django Files instance do the following:
9194
</p>
@@ -123,13 +126,13 @@ <h2>Support</h2>
123126

124127
<p>
125128
Please submit an
126-
<a href="{{ site.github_url }}/issues" target="_blank">Issue</a>
129+
<a href="{{ site.extension_github }}/issues" target="_blank">Issue</a>
127130
if you find bugs and open a
128-
<a href="{{ site.github_url }}/discussions/categories/feature-requests" target="_blank">Feature Request</a>
131+
<a href="{{ site.extension_github }}/discussions/categories/feature-requests" target="_blank">Feature Request</a>
129132
if you have any ideas, suggestions, or requests.
130133
</p>
131134

132135
<p>
133-
More information can be found on GitHub,
134-
<a href="https://github.com/django-files/web-extension" target="_blank" rel="noopener">django-files/web-extension</a>.
136+
More information can be found on GitHub:
137+
<a href="https://github.com/django-files/web-extension" target="_blank" rel="noopener">django-files/web-extension</a>
135138
</p>

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ <h2>Running</h2>
2222

2323
<h3>
2424
Docker Run
25-
<small class="text-body-secondary"><a href="#" onclick="return false;" class="clip" data-clipboard-target="#docker-run-inline"><i class="fa-solid fa-copy"></i></a></small>
25+
<a href="#" class="small clip" data-clipboard-target="#docker-run-inline">
26+
<i class="fa-solid fa-copy"></i></a>
2627
</h3>
2728
<pre class="border border-success rounded-3 px-3 pb-3"><code id="docker-run-inline">
2829
docker run --name "django-files" -d --restart unless-stopped \
@@ -35,7 +36,8 @@ <h3>
3536

3637
<h3>
3738
Docker Compose
38-
<small class="text-body-secondary"><a href="#" onclick="return false;" class="clip" data-clipboard-target="#docker-compose-inline"><i class="fa-solid fa-copy"></i></a></small>
39+
<a href="#" class="small clip" data-clipboard-target="#docker-compose-inline">
40+
<i class="fa-solid fa-copy"></i></a>
3941
</h3>
4042
<pre class="border border-success rounded-3 px-3 pb-3"><code id="docker-compose-inline">
4143
version: '3'

js/main.js

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,83 @@
1-
new ClipboardJS('.clip')
1+
// JS Main
2+
3+
const backToTop = document.getElementById('back-to-top')
4+
if (backToTop) {
5+
window.addEventListener('scroll', debounce(onScroll))
6+
backToTop.addEventListener('click', () => {
7+
document.body.scrollTop = 0
8+
document.documentElement.scrollTop = 0
9+
})
10+
}
11+
12+
document
13+
.querySelectorAll('.clip')
14+
.forEach((el) => el.addEventListener('click', (e) => e.preventDefault()))
15+
16+
if (typeof ClipboardJS !== 'undefined') {
17+
const clipboard = new ClipboardJS('.clip')
18+
clipboard.on('success', function (event) {
19+
// console.debug('clipboard.success:', event)
20+
// const text = event.text
21+
// console.debug(`text: "${text}"`)
22+
if (event.trigger.dataset.toast) {
23+
showToast(event.trigger.dataset.toast)
24+
} else {
25+
showToast('Copied to Clipboard')
26+
}
27+
})
28+
clipboard.on('error', function (event) {
29+
// console.debug('clipboard.error:', event)
30+
showToast('Clipboard Copy Failed', 'warning')
31+
})
32+
}
33+
34+
/**
35+
* On Scroll Callback
36+
* @function onScroll
37+
*/
38+
function onScroll() {
39+
if (
40+
document.body.scrollTop > 20 ||
41+
document.documentElement.scrollTop > 20
42+
) {
43+
backToTop.style.display = 'block'
44+
} else {
45+
backToTop.style.display = 'none'
46+
}
47+
}
48+
49+
/**
50+
* Show Bootstrap Toast
51+
* @function showToast
52+
* @param {String} message
53+
* @param {String} type
54+
*/
55+
function showToast(message, type = 'success') {
56+
console.debug(`showToast: ${type}: ${message}`)
57+
const clone = document.querySelector('.d-none .toast')
58+
const container = document.getElementById('toast-container')
59+
if (!clone || !container) {
60+
return console.warn('Missing clone or container:', clone, container)
61+
}
62+
const element = clone.cloneNode(true)
63+
element.querySelector('.toast-body').innerHTML = message
64+
element.classList.add(`text-bg-${type}`)
65+
container.appendChild(element)
66+
const toast = new bootstrap.Toast(element)
67+
element.addEventListener('mousemove', () => toast.hide())
68+
toast.show()
69+
}
70+
71+
/**
72+
* DeBounce Function
73+
* @function debounce
74+
* @param {Function} fn
75+
* @param {Number} timeout
76+
*/
77+
function debounce(fn, timeout = 250) {
78+
let timeoutID
79+
return (...args) => {
80+
clearTimeout(timeoutID)
81+
timeoutID = setTimeout(() => fn(...args), timeout)
82+
}
83+
}

0 commit comments

Comments
 (0)