Skip to content

Commit 3d4a4a9

Browse files
authored
Updates (#9)
* Updates * Fix Popup * Privacy * Add Version to Options * Cleanup
1 parent 48c676a commit 3d4a4a9

File tree

17 files changed

+73
-38
lines changed

17 files changed

+73
-38
lines changed

PRIVACY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Data Collection
2+
3+
Your data is not being collected, stored or used for any purpose.
File renamed without changes.

manifest-chrome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"service_worker": "js/service-worker.js"
44
},
55
"permissions": ["offscreen"],
6-
"minimum_chrome_version": "88"
6+
"minimum_chrome_version": "109"
77
}

manifest.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"manifest_version": 3,
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"name": "Django Files",
5-
"description": "Django Files Web Extension",
5+
"description": "Django Files Web Extension designed to work with django-files/django-files.",
66
"homepage_url": "https://github.com/django-files/web-extension",
77
"author": "Shane",
88
"commands": {
@@ -25,18 +25,18 @@
2525
"default_title": "Django Files",
2626
"default_popup": "html/popup.html",
2727
"default_icon": {
28-
"16": "images/logo16.png",
29-
"32": "images/logo32.png",
30-
"48": "images/logo48.png",
31-
"96": "images/logo96.png",
32-
"128": "images/logo128.png"
28+
"16": "media/logo16.png",
29+
"32": "media/logo32.png",
30+
"48": "media/logo48.png",
31+
"96": "media/logo96.png",
32+
"128": "media/logo128.png"
3333
}
3434
},
3535
"icons": {
36-
"16": "images/logo16.png",
37-
"32": "images/logo32.png",
38-
"48": "images/logo48.png",
39-
"96": "images/logo96.png",
40-
"128": "images/logo128.png"
36+
"16": "media/logo16.png",
37+
"32": "media/logo32.png",
38+
"48": "media/logo48.png",
39+
"96": "media/logo96.png",
40+
"128": "media/logo128.png"
4141
}
4242
}

src/css/options.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ video {
1313
height: auto;
1414
z-index: -100;
1515
transform: translateX(-50%) translateY(-50%);
16-
background: url("../images/loop.jpg") no-repeat;
16+
background: url("../media/loop.jpg") no-repeat;
1717
background-size: cover;
1818
transition: 1s opacity;
1919
}

src/html/options.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22
<html lang="en" data-bs-theme="dark" class="h-100">
33
<head>
44
<title>Django Files Options</title>
5-
<link rel="icon" href="../images/logo16.png" sizes="any">
5+
<link rel="icon" href="../media/logo16.png" sizes="any">
66
<link rel="stylesheet" type="text/css" href="../dist/bootstrap/bootstrap.min.css">
77
<link rel="stylesheet" type="text/css" href="../dist/fontawesome/js/all.min.js">
88
<link rel="stylesheet" type="text/css" href="../css/options.css">
99
</head>
1010
<body class="h-100">
1111

12-
<video poster="../images/loop.jpg" id="bgvid" playsinline autoplay muted loop>
13-
<source src="../images/loop.webm" type="video/webm">
12+
<video poster="../media/loop.jpg" id="bgvid" playsinline autoplay muted loop>
13+
<source src="../media/loop.webm" type="video/webm">
1414
</video>
1515

1616
<div class="container-fluid p-2 h-100">
1717
<div class="d-flex align-items-center h-100">
18-
<div class="col-md-6 col-12 m-auto">
18+
<div class="col-xl-6 col-md-8 col-12 m-auto">
1919
<div class="card p-2 mb-3" >
20-
<h1 class="text-center">Django Files Extension</h1>
21-
<img src="../images/logo96.png" class="img-fluid m-auto d-block my-1" alt="Django Files" height="96" width="96">
20+
21+
<div class="justify-content-center align-items-center d-flex">
22+
<img src="../media/logo48.png" class="img-fluid float-start me-2" alt="Link Extractor" height="48" width="48">
23+
<h1 class="align-middle">Django Files Extension</h1>
24+
</div>
25+
<div class="clearfix"></div>
26+
<p class="text-center lead mb-0">v<span id="version"></span></p>
2227
<div class="card-body">
2328
<table class="table table-sm table-borderless">
2429
<caption class="visually-hidden">Keyboard Shortcuts</caption>
@@ -48,6 +53,10 @@ <h1 class="text-center">Django Files Extension</h1>
4853
<input class="form-check-input" type="checkbox" role="switch" id="contextMenu">
4954
<label class="form-check-label" for="contextMenu" aria-describedby="contextMenuHelp">Enable Right Click Menu</label>
5055
</div>
56+
<div class="form-check form-switch mb-3">
57+
<input class="form-check-input" type="checkbox" role="switch" id="showUpdate">
58+
<label class="form-check-label" for="showUpdate" aria-describedby="showUpdateHelp">Show Release Notes on Update</label>
59+
</div>
5160
<button id="submit" type="submit" class="btn btn-outline-success w-100">
5261
Save Options <i class="fa-regular fa-floppy-disk ms-2"></i></button>
5362
</form>

src/html/popup.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>Django Files Popup</title>
5-
<link rel="icon" href="../images/logo16.png" sizes="any">
5+
<link rel="icon" href="../media/logo16.png" sizes="any">
66
<link rel="stylesheet" type="text/css" href="../dist/bootstrap/bootstrap.min.css">
77
<link rel="stylesheet" type="text/css" href="../dist/fontawesome/js/all.min.js">
88
<link rel="stylesheet" type="text/css" href="../css/popup.css">
@@ -12,15 +12,15 @@
1212

1313
<div class="container-fluid p-3">
1414
<div class="text-center">
15-
<img src="../images/logo32.png" class="float-start" alt="Django Files" height="32" width="32">
15+
<img src="../media/logo32.png" class="float-start" alt="Django Files" height="32" width="32">
1616
<h2>Django Files Extension</h2>
1717
</div>
1818
<div class="d-grid g-2">
1919
<div id="django-files-links" class="btn-group btn-group-sm" role="group" aria-label="Django Files Links" style="display: none;">
20-
<button type="button" class="btn btn-outline-success" data-href="" data-location="/files/">
21-
<i class="fa-regular fa-folder-open me-2"></i> Files</button>
22-
<button type="button" class="btn btn-outline-success" data-href="" data-location="/gallery/">
23-
<i class="fa-regular fa-images me-2"></i> Gallery</button>
20+
<a role="button" class="btn btn-outline-success" data-href="" data-location="/files/">
21+
<i class="fa-regular fa-folder-open me-2"></i> Files</a>
22+
<a role="button" class="btn btn-outline-success" data-href="" data-location="/gallery/">
23+
<i class="fa-regular fa-images me-2"></i> Gallery</a>
2424
</div>
2525
<a class="btn btn-outline-primary btn-sm my-1" role="button" target="_blank" data-href="../html/options.html">
2626
<i class="fa-solid fa-gear me-2"></i> Open Options</a>

src/js/options.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { createContextMenus } from './exports.js'
44

55
document.addEventListener('DOMContentLoaded', initOptions)
6-
76
document.getElementById('options-form').addEventListener('submit', saveOptions)
87

98
/**
@@ -21,12 +20,15 @@ async function initOptions() {
2120
url_input.placeholder = 'https://example.com'
2221
url_input.focus()
2322
}
23+
document.getElementById('version').textContent =
24+
chrome.runtime.getManifest().version
2425
document.getElementById('token').value = auth?.token || ''
2526
document.getElementById('contextMenu').checked = options.contextMenu
27+
document.getElementById('showUpdate').checked = options.showUpdate
2628
const commands = await chrome.commands.getAll()
2729
document.getElementById('mainKey').textContent =
2830
commands.find((x) => x.name === '_execute_action').shortcut || 'Not Set'
29-
document.getElementById('recentFiles').value = options?.recentFiles || '10'
31+
document.getElementById('recentFiles').value = options.recentFiles || '10'
3032
}
3133

3234
/**
@@ -45,6 +47,7 @@ async function saveOptions(event) {
4547
let options = {}
4648
options.recentFiles = document.getElementById('recentFiles').value
4749
options.contextMenu = document.getElementById('contextMenu').checked
50+
options.showUpdate = document.getElementById('showUpdate').checked
4851
if (options.contextMenu) {
4952
chrome.contextMenus.removeAll()
5053
createContextMenus()

src/js/popup.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async function initPopup() {
5050
}
5151

5252
updateTable(data)
53+
5354
const clipboard = new ClipboardJS('.clip') // eslint-disable-line
5455
document.querySelectorAll('[data-href]').forEach((el) => {
5556
el.addEventListener('click', popupLink)
@@ -66,12 +67,13 @@ async function popupLink(event) {
6667
console.log('popupLink:', event)
6768
const { auth } = await chrome.storage.sync.get(['auth'])
6869
let url
69-
if (event.target.dataset.location) {
70-
url = auth?.url + event.target.dataset.location
71-
} else if (event.target.dataset.href.startsWith('http')) {
72-
url = event.target.dataset.href
70+
const anchor = event.target.closest('a')
71+
if (anchor?.dataset?.location) {
72+
url = auth?.url + anchor.dataset.location
73+
} else if (anchor?.dataset?.href.startsWith('http')) {
74+
url = anchor.dataset.href
7375
} else {
74-
url = chrome.runtime.getURL(event.target.dataset.href)
76+
url = chrome.runtime.getURL(anchor.dataset.href)
7577
}
7678
console.log(`url: ${url}`)
7779
await chrome.tabs.create({ active: true, url })

src/js/service-worker.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { createContextMenus } from './exports.js'
44

55
chrome.runtime.onInstalled.addListener(onInstalled)
6-
76
chrome.contextMenus.onClicked.addListener(contextMenuClick)
87

98
chrome.notifications.onClicked.addListener((notificationId) => {
@@ -14,16 +13,35 @@ chrome.notifications.onClicked.addListener((notificationId) => {
1413
/**
1514
* Init Context Menus and Options
1615
* @function onInstalled
16+
* @param {InstalledDetails} details
1717
*/
18-
export async function onInstalled() {
19-
console.log('onInstalled')
18+
async function onInstalled(details) {
19+
console.log('onInstalled:', details)
2020
let { options } = await chrome.storage.sync.get(['options'])
21-
options = options || { contextMenu: true, recentFiles: '10' }
21+
options = options || {
22+
contextMenu: true,
23+
recentFiles: '10',
24+
showUpdate: false,
25+
}
2226
console.log('options:', options)
2327
await chrome.storage.sync.set({ options })
2428
if (options.contextMenu) {
2529
createContextMenus()
2630
}
31+
if (details.reason === 'install') {
32+
const url = chrome.runtime.getURL('/html/options.html')
33+
await chrome.tabs.create({ active: true, url })
34+
} else if (options.showUpdate && details.reason === 'update') {
35+
const manifest = chrome.runtime.getManifest()
36+
if (manifest.version !== details.previousVersion) {
37+
const url = `https://github.com/django-files/web-extension/releases/tag/${manifest.version}`
38+
console.log(`url: ${url}`)
39+
await chrome.tabs.create({ active: true, url })
40+
}
41+
}
42+
chrome.runtime.setUninstallURL(
43+
'https://github.com/django-files/web-extension/issues'
44+
)
2745
}
2846

2947
/**
@@ -108,7 +126,7 @@ async function sendNotification(title, text, id = '', timeout = 10) {
108126
console.log(`sendNotification: ${id || 'randomID'}: ${title} - ${text}`)
109127
const options = {
110128
type: 'basic',
111-
iconUrl: chrome.runtime.getURL('images/logo128.png'),
129+
iconUrl: chrome.runtime.getURL('media/logo96.png'),
112130
title: title,
113131
message: text,
114132
}

0 commit comments

Comments
 (0)