diff --git a/.bumpversion.cfg b/.bumpversion.cfg index a3e7328..5dc4c32 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.12 +current_version = 0.2.2 commit = True tag = True diff --git a/.dockerignore b/.dockerignore index 07609c9..bc6932a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,3 @@ staticfiles/ .bump2version.cfg .env .git/ -.gitignore \ No newline at end of file diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index d8a7609..6fe936f 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -21,15 +21,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install bump2version + run: pip install bump2version + + - name: Get current version from bump2version + id: version + run: echo "VERSION=$(bump2version --dry-run --list patch | grep current_version | sed -r s,"^.*=",,)" >> $GITHUB_ENV + - name: Set Docker tag based on branch id: tag run: | + # master branch uses specific version tagging, others use the branch name if [[ "${{ gitea.ref_name }}" == "master" ]]; then - TAG="latest" - elif [[ "${{ gitea.ref_name }}" == "staging" ]]; then - TAG="staging" - elif [[ "${{ gitea.ref_name }}" == "dev" ]]; then - TAG="dev" + TAG="${{ env.VERSION }}" + else + TAG="${{ gitea.ref_name }}" fi echo "TAG=$TAG" >> $GITHUB_ENV @@ -42,5 +48,12 @@ jobs: - name: Tag & Push Docker image run: | + # Push the branch-specific or version-specific tag docker tag pyrss-website:${{ env.TAG }} xordk/pyrss-website:${{ env.TAG }} docker push xordk/pyrss-website:${{ env.TAG }} + + # If on master, push an additional "latest" tag + if [[ "${{ gitea.ref_name }}" == "master" ]]; then + docker tag pyrss-website:${{ env.TAG }} xordk/pyrss-website:latest + docker push xordk/pyrss-website:latest + fi diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9115d01 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ + +**unreleased** + +**v0.2.2** + +- Enhancement: added open graph meta tags +- Fix: csrf trusted origins warning, from not including url protocol +- Fix/Enhancement: Replaced `` buttons with `` } }, { @@ -143,7 +143,7 @@ function resolveChannelNames(guildId) { $("").text(channel.text) .attr("href", href) .attr("target", "_blank") - .addClass("text-decoration-none text-nowrap") + .addClass("btn btn-link text-decoration-none text-nowrap") ); } }); diff --git a/apps/static/js/home/filters.js b/apps/static/js/home/filters.js index 83cfd42..73d2ebc 100644 --- a/apps/static/js/home/filters.js +++ b/apps/static/js/home/filters.js @@ -40,7 +40,7 @@ async function initFiltersTable() { title: "Name", data: "name", render: function(data, type, row) { - return `${data}` + return `` } }, { diff --git a/apps/static/js/home/index.js b/apps/static/js/home/index.js index 39c0912..acf55ed 100644 --- a/apps/static/js/home/index.js +++ b/apps/static/js/home/index.js @@ -9,17 +9,11 @@ $(document).ready(async function() { await loadServerOptions(); }); -// $('#serverTabs [data-bs-toggle="tab"]').on("show.bs.tab", function(event) { -// const activeTab = $(event.target); -// $(".tab-pane-buttons .tab-pane-buttons-item").hide(); -// $(`.tab-pane-buttons .tab-pane-buttons-item[data-tab="${activeTab.attr("id")}"]`).show(); -// }); - $(document).on("selectedServerChange", function() { $("#subscriptionsTab").click(); }); -function genHexString(len) { +function genHexString(len=6) { let output = ''; for (let i = 0; i < len; ++i) { output += (Math.floor(Math.random() * 16)).toString(16); diff --git a/apps/static/js/home/servers.js b/apps/static/js/home/servers.js index 2333876..4c8fb0c 100644 --- a/apps/static/js/home/servers.js +++ b/apps/static/js/home/servers.js @@ -1,3 +1,6 @@ + +// #region Loaded Servers + var loadedServers = {}; // Returns the currently active server, or null if none are active. @@ -44,9 +47,21 @@ function removeFromLoadedServers(serverPrimaryKey) { delete loadedServers[serverPrimaryKey]; removeServerTemplate(serverPrimaryKey); + $("#backToSelectServer").click(); +} + +// #endregion + +// #region Server Back Btn + +$("#backToSelectServer").on("click", function() { $("#noSelectedServer").show(); $("#selectedServerContainer").hide(); -} +}); + +// #endregion + +// #region Server Modal $("#serverOptionsRefreshBtn").on("click", async function() { await loadServerOptions(); @@ -94,6 +109,10 @@ async function loadServerOptions() { } +// #endregion + +// #region Server Sidebar + // Load any existing 'saved guilds' from the database async function loadSavedGuilds() { try { @@ -137,9 +156,17 @@ function removeServerTemplate(serverPrimaryKey) { // Open 'Add Server' Form Modal $("#newServerBtn").on("click", function() { - $("#serverFormModal").modal("show"); + newServerModal(); }); +function newServerModal() { + $("#serverFormModal").modal("show"); +} + +// #endregion + +// #region New Server + // Submit 'Add Server' Form $("#serverForm").on("submit", async function(event) { event.preventDefault(); @@ -182,6 +209,10 @@ async function registerNewServer(serverName, serverGuildId, serverIconHash, serv return response.id; } +// #endregion + +// #region Select Server + function selectServer(primaryKey) { var server = loadedServers[primaryKey]; @@ -203,12 +234,34 @@ function selectServer(primaryKey) { loadedServers[primaryKey].currentlyActive = true; $("#noSelectedServer").hide(); - $("#selectedServerContainer").show(); + $("#selectedServerContainer").show().css("display", "flex"); $(document).trigger("selectedServerChange"); } +// #endregion + +// #region Delete Server Btn + $("#deleteSelectedServerBtn").on("click", async function() { + const notes = [ + "No Subscriptions, Filters or Tracked Content will be deleted.", + "No data will be deleted for other users.", + "The server will no longer appear on your sidebar.", + "You can re-add the server", + "All Subscriptions, Filters and Tracked Content will be available when/if you re-add the server." + ]; + const notesString = arrayToHtmlList(notes).prop("outerHTML"); + + await confirmDeleteModal( + "Close this server?", + `This is a safe, non-permanent action:

${notesString}`, + deleteSelectedServer, + null + ); +}); + +async function deleteSelectedServer() { var activeServer = getCurrentlyActiveServer(); if (!activeServer) { @@ -226,5 +279,38 @@ $("#deleteSelectedServerBtn").on("click", async function() { alert(error) alert(JSON.stringify(error, null, 4)) } +}; -}); \ No newline at end of file +// #endregion + +$(document).on("selectedServerChange", function() { + resolveServerStrings(); + $("#serverJoinAlert").hide(); +}) + +// #region Resolve Strings + +function resolveServerStrings() { + const server = getCurrentlyActiveServer(); + + // Server names + $(".resolve-to-server-name").text(server.name); + + // Server Guild Ids + $(".resolve-to-server-id").text(server.guild_id) + + // Bot Invite links + $(".resolve-to-invite-link").attr("href", `https://discord.com/oauth2/authorize +?client_id=1129345991758336020 +&permissions=2147534848 +&scope=bot+applications.commands +&guild_id=${server.guild_id} +&disable_guild_select=true`); + +} + +$("#backToSelectServer").on("click", function() { + +}); + +// #endregion diff --git a/apps/static/js/home/subscriptions.js b/apps/static/js/home/subscriptions.js index 18ea333..e262095 100644 --- a/apps/static/js/home/subscriptions.js +++ b/apps/static/js/home/subscriptions.js @@ -43,7 +43,7 @@ async function initSubscriptionTable() { data: "name", className: "text-truncate", render: function(data, type, row) { - return `${data}`; + return ``; } }, { @@ -51,7 +51,7 @@ async function initSubscriptionTable() { data: "url", className: "text-truncate", render: function(data, type) { - return `${data}`; + return `${data}`; } }, { @@ -371,19 +371,14 @@ async function loadSubscriptions(guildId) { // #region Server Change Event Handler $(document).on("selectedServerChange", async function() { + let server = getCurrentlyActiveServer(); + guildId = server.guild_id; - // Hide alerts - $("#serverJoinAlert").attr("style", "display: none !important"); + $("#subEmbedColour .colour-reset").attr("data-defaultcolour", "#" + server.default_embed_colour); - updateBotInviteLink(); - - const activeServer = getCurrentlyActiveServer(); - - $("#subEmbedColour .colour-reset").attr("data-defaultcolour", "#" + activeServer.default_embed_colour); - - await loadSubscriptions(activeServer.guild_id); - await loadChannelOptions(activeServer.guild_id); - await loadFilterOptions(activeServer.guild_id); + await loadSubscriptions(guildId); + await loadChannelOptions(guildId); + await loadFilterOptions(guildId); await loadMutatorOptions(); }) @@ -479,7 +474,7 @@ async function loadChannelOptions(guildId) { // Also check that the user hasn't changed the currently active guild, otherwise // the alert will show under the wrong server. if (getCurrentlyActiveServer().guild_id === guildId) - showServerJoinAlert(); + $("#serverJoinAlert").show(); const guildName = getServerFromSnowflake(guildId).name; @@ -587,29 +582,3 @@ async function loadFilterOptions(guildId) { } // #endregion - - -// #region Bot Not in Server Alert -function showServerJoinAlert() { - const guildId = getCurrentlyActiveServer().guild_id; - const inviteUrl = `https://discord.com/oauth2/authorize -?client_id=1129345991758336020 -&permissions=2147534848&scope=bot+applications.commands -&guild_id=${guildId} -&disable_guild_select=true` - - $("#serverJoinAlert a.alert-link").attr("href", inviteUrl); - $("#serverJoinAlert").show(); -} -// #endregion - -function updateBotInviteLink() { - const guildId = getCurrentlyActiveServer().guild_id; - const inviteUrl = `https://discord.com/oauth2/authorize -?client_id=1129345991758336020 -&permissions=2147534848&scope=bot+applications.commands -&guild_id=${guildId} -&disable_guild_select=true` - - $("#invitePyrssToServerBtn").attr("href", inviteUrl); -} diff --git a/apps/templates/home/index.html b/apps/templates/home/index.html index b7e16f0..7c6cc10 100644 --- a/apps/templates/home/index.html +++ b/apps/templates/home/index.html @@ -22,37 +22,52 @@
-
- select a server +
+
+ PYRSS Logo +

PYRSS

+
+

Select or add a server from the left hand menu to get started. For more help check the README.

+
+
Resources
+
+ + + + +
+
+
+