Skip to content

Commit ea8d274

Browse files
committed
working first test version admin editor
1 parent 91007e1 commit ea8d274

22 files changed

+40038
-48
lines changed

adminEditor/bundle.css

Lines changed: 0 additions & 7 deletions
This file was deleted.

adminEditor/bundle.js

Whitespace-only changes.

adminEditor/bundle.min.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

adminEditor/bundle.min.js

Whitespace-only changes.

adminEditor/bundle_script.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
# List of CDN URLs for CSS and JS files
66
css_urls = [
7-
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css',
8-
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css'
9-
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.css'
7+
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.css",
8+
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.css",
9+
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.css"
1010
]
1111

1212
js_urls = [
13-
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.bundle.min.js'
14-
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js'
15-
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/markdown/markdown.min.js'
13+
"https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.bundle.js",
14+
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.js",
15+
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/markdown/markdown.js"
1616
]
1717

1818
# Function to download and bundle files
@@ -23,21 +23,21 @@ def bundle_files(urls, output_file, minify=False):
2323
if response.status_code == 200:
2424
content += response.text + '\n'
2525
else:
26-
print(f"Failed to download {url}")
26+
print(f"Failed to download {url}"+ '\n')
2727

2828
if minify:
2929
if output_file.endswith('.css'):
3030
content = csscompressor.compress(content)
3131
elif output_file.endswith('.js'):
3232
content = jsmin(content)
3333

34-
with open(output_file, 'w') as bundle:
34+
with open(output_file, 'w', encoding='utf-8') as bundle:
3535
bundle.write(content)
3636

3737
# Bundle and minify CSS and JS files
38-
bundle_files(css_urls, 'bundle.css')
39-
bundle_files(css_urls, 'bundle.min.css', minify=True)
40-
bundle_files(js_urls, 'bundle.js')
41-
bundle_files(js_urls, 'bundle.min.js', minify=True)
38+
bundle_files(css_urls, 'static/bundle.css')
39+
bundle_files(css_urls, 'static/bundle.min.css', minify=True)
40+
bundle_files(js_urls, 'static/bundle.js')
41+
bundle_files(js_urls, 'static/bundle.min.js', minify=True)
4242

4343
print("Bundling and minification complete!")

adminEditor/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,19 @@ func handleProcessMedia(w http.ResponseWriter, r *http.Request) {
263263
return
264264
}
265265

266+
// Get the dimensions of the source image
267+
srcWidth := src.Bounds().Dx()
268+
srcHeight := src.Bounds().Dy()
269+
270+
// Calculate the new height to maintain the aspect ratio
271+
newHeight := (config.Server.ImageResize.MaxWidth * srcHeight) / srcWidth
272+
266273
// Resize the image
267274
var resized image.Image
268275
if config.Server.ImageResize.Method == "fit" {
269-
resized = imaging.Fit(src, config.Server.ImageResize.MaxWidth, 0, imaging.Lanczos)
276+
resized = imaging.Fit(src, config.Server.ImageResize.MaxWidth, newHeight, imaging.Lanczos)
270277
} else {
271-
resized = imaging.Fill(src, config.Server.ImageResize.MaxWidth, 0, imaging.Center, imaging.Lanczos)
278+
resized = imaging.Fill(src, config.Server.ImageResize.MaxWidth, newHeight, imaging.Center, imaging.Lanczos)
272279
}
273280

274281
// Save the resized image
@@ -281,9 +288,9 @@ func handleProcessMedia(w http.ResponseWriter, r *http.Request) {
281288
// Create and save thumbnail
282289
var thumbnail image.Image
283290
if config.Server.ThumbnailResize.Method == "fit" {
284-
thumbnail = imaging.Fit(src, config.Server.ThumbnailResize.MaxWidth, 0, imaging.Lanczos)
291+
thumbnail = imaging.Fit(src, config.Server.ThumbnailResize.MaxWidth, newHeight, imaging.Lanczos)
285292
} else {
286-
thumbnail = imaging.Fill(src, config.Server.ThumbnailResize.MaxWidth, 0, imaging.Center, imaging.Lanczos)
293+
thumbnail = imaging.Fill(src, config.Server.ThumbnailResize.MaxWidth, newHeight, imaging.Center, imaging.Lanczos)
287294
}
288295

289296
thumbnailFile := filepath.Join(config.Server.AssetFolder, "thumb_"+newFileName)

adminEditor/static/bundle.css

Lines changed: 19181 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)