Merge branch 'branch-2.10'

This commit is contained in:
Shish 2024-02-04 00:25:57 +00:00
commit e753a68e76
5 changed files with 40 additions and 60 deletions

View file

@ -31,35 +31,11 @@ jobs:
zip -r shimmie2-${{ steps.get_version.outputs.VERSION }}.zip shimmie2
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Shimmie ${{ steps.get_version.outputs.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
name: Shimmie ${{ steps.get_version.outputs.VERSION }}
body: Automated release from tags
draft: false
prerelease: false
- name: Upload Zip
id: upload-release-asset-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ../shimmie2-${{ steps.get_version.outputs.VERSION }}.zip
asset_name: shimmie2-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip
- name: Upload Tar
id: upload-release-asset-tar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ../shimmie2-${{ steps.get_version.outputs.VERSION }}.tgz
asset_name: shimmie2-${{ steps.get_version.outputs.VERSION }}.tgz
asset_content_type: application/gzip
files: |
../shimmie2-${{ steps.get_version.outputs.VERSION }}.zip
../shimmie2-${{ steps.get_version.outputs.VERSION }}.tgz

View file

@ -383,8 +383,6 @@ class BasePage
$data_href = get_base_href();
$theme_name = $config->get_string(SetupConfig::THEME, 'default');
$this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>", 40);
# static handler will map these to themes/foo/static/bar.ico or ext/static_files/static/bar.ico
$this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>", 41);
$this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>", 42);
@ -558,6 +556,7 @@ class BasePage
$body_attrs = [
"data-userclass" => $user->class->name,
"data-base-href" => get_base_href(),
];
print emptyHTML(

View file

@ -42,7 +42,7 @@ function updateCompletions(element) {
}
else {
element.completer_timeout = setTimeout(() => {
fetch(base_href + '/api/internal/autocomplete?s=' + word).then(
fetch(document.body.getAttribute("data-base-href") + '/api/internal/autocomplete?s=' + word).then(
(response) => response.json()
).then((json) => {
if(element.selected_completion !== -1) {
@ -232,16 +232,11 @@ document.addEventListener('DOMContentLoaded', () => {
event.preventDefault();
highlightCompletion(element, element.selected_completion+1);
}
// if enter or right are pressed, add the selected completion
// if enter or right are pressed while a completion is selected, add the selected completion
else if((event.code === "Enter" || event.code == "ArrowRight") && element.selected_completion !== -1) {
event.preventDefault();
setCompletion(element, Object.keys(element.completions)[element.selected_completion]);
}
// If enter is pressed while nothing is selected, submit the form
else if(event.code === "Enter" && element.selected_completion === -1) {
event.preventDefault();
element.form.submit();
}
// if escape is pressed, hide the completion block
else if(event.code === "Escape") {
event.preventDefault();

30
ext/handle_mp3/script.js Normal file
View file

@ -0,0 +1,30 @@
document.addEventListener("DOMContentLoaded", () => {
let main_image = document.getElementById("main_image");
if (main_image) {
main_image.setAttribute("volume", 0.25);
}
let base_href = document.body.getAttribute("data-base-href");
let audio_src = document.getElementById("audio_src");
if (audio_src) {
let ilink = audio_src.getAttribute("src");
window.jsmediatags.read(location.origin + base_href + ilink, {
onSuccess: function (tag) {
var artist = tag.tags.artist,
title = tag.tags.title;
document.getElementById("audio-title").innerText = title;
document.getElementById("audio-artist").innerText = artist;
document
.getElementById("audio-download")
.setAttribute(
"download",
(artist + " - " + title).substring(0, 250) + ".mp3",
);
},
onError: function (error) {
console.log(error);
},
});
}
});

View file

@ -13,31 +13,11 @@ class MP3FileHandlerTheme extends Themelet
$ilink = $image->get_image_link();
$html = "
<audio controls class='shm-main-image audio_image' id='main_image' alt='main image'>
<source src=\"$ilink\" type=\"audio/mpeg\">
<source id='audio_src' src=\"$ilink\" type=\"audio/mpeg\">
Your browser does not support the audio element.
</audio>
<p>Title: <span id='audio-title'>???</span> | Artist: <span id='audio-artist'>???</span></p>
<script>
$('#main_image').prop('volume', 0.25);
var jsmediatags = window.jsmediatags;
jsmediatags.read(location.origin+base_href+'$ilink', {
onSuccess: function(tag) {
var artist = tag.tags.artist,
title = tag.tags.title;
$('#audio-title').text(title);
$('#audio-artist').text(artist);
$('#audio-download').prop('download', (artist+' - '+title).substr(0, 250)+'.mp3');
},
onError: function(error) {
console.log(error);
}
});
</script>
<p><a href='$ilink' id='audio-download'>Download</a>";
$page->add_html_header("<script src='{$data_href}/ext/handle_mp3/lib/jsmediatags.min.js' type='text/javascript'></script>");