Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Implementing OS-specific download buttons #2581

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ca39ab3
chore: add .idea folder to .gitignore
plvzfq-rit Nov 12, 2024
e83fe3b
feat: change link of masthead button to go to download section
plvzfq-rit Nov 12, 2024
920801c
feat: add slash to link of masthead button
plvzfq-rit Nov 12, 2024
5bba799
feat!: add other packages to [[os]].vue
plvzfq-rit Nov 12, 2024
dc4b088
feat: add Windows buttons
plvzfq-rit Nov 12, 2024
15f2540
feat: add Linux specific buttons
plvzfq-rit Nov 12, 2024
66d774a
feat: add Mac-specific buttons
plvzfq-rit Nov 12, 2024
bd7151a
feat: upgrade Windows button group to n-flex from n-grid
plvzfq-rit Nov 12, 2024
fd4baeb
feat: add button icons to Windows buttons
plvzfq-rit Nov 12, 2024
d1dc670
feat: have Linux button group use n-flow
plvzfq-rit Nov 12, 2024
ac0c12a
feat: update Linux button group to have same style as Windows button …
plvzfq-rit Nov 12, 2024
327e74e
feat: remove unnecessary class to span of Windows button group
plvzfq-rit Nov 12, 2024
75b24ea
feat: update Mac buttons to have same style as Windows buttons
plvzfq-rit Nov 12, 2024
b983296
fix: update colors of Mac buttons from default to primary
plvzfq-rit Nov 12, 2024
5218500
fix: add periods to Mac button extensions
plvzfq-rit Nov 12, 2024
4e41c33
fix: add parentheses to isLinux function call
plvzfq-rit Nov 12, 2024
f51f078
feat: create DownloadButton vue file
plvzfq-rit Nov 12, 2024
d387430
refactor: use DownloadButton in LandingPageDownload
plvzfq-rit Nov 12, 2024
4334e79
feat: migrate from fosshub to github releases and fix button href bug
plvzfq-rit Dec 27, 2024
f13dc6a
Merge branch 'JabRef:main' into implementing-os-specific-download-but…
plvzfq-rit Dec 27, 2024
a80d9f5
feat: remove extraneous console.log statements
plvzfq-rit Dec 27, 2024
5fe7d43
Merge branch 'implementing-os-specific-download-buttons' of https://g…
plvzfq-rit Dec 27, 2024
52da8e1
Merge branch 'main' into implementing-os-specific-download-buttons
plvzfq-rit Jan 12, 2025
ee46a56
chore: remove unused downloadUrl constant
plvzfq-rit Jan 12, 2025
28bcfc6
refactor: change .zip and .tar.gz to more descriptive names (portables)
plvzfq-rit Jan 12, 2025
466393f
feat: change from /download to GitHub release page
plvzfq-rit Jan 12, 2025
f682d8f
chore: remove unused import
plvzfq-rit Jan 12, 2025
adde018
test: trying to update tests
plvzfq-rit Jan 12, 2025
be8a2fc
style: run prettier on DownloadButton.vue
plvzfq-rit Jan 12, 2025
c779276
style: run prettier on components/LandingPageDownload.client.vue
plvzfq-rit Jan 12, 2025
2db0a21
style: run prettier on pages/download/[[os]].vue
plvzfq-rit Jan 12, 2025
7877825
style: run prettier on pages/index.vue
plvzfq-rit Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ storybook-static/

# End of https://www.toptal.com/developers/gitignore/api/vscode,nuxtjs,node

# webstorm
.idea/*

# Automatically generated files
apollo/gql.ts
apollo/graphql.ts
Expand Down
30 changes: 30 additions & 0 deletions components/DownloadButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<n-button
type="primary"
size="large"
style="height: 3.2em"
>
<template #icon>
<n-icon>
<Icon name="material-symbols:download" />
</n-icon>
</template>
<a
class="text-2xl"
:href
>{{ text }}</a
>
</n-button>
</template>
<script setup lang="ts">
defineProps({
text: {
type: String,
default: '',
},
href: {
type: String,
default: '',
},
})
</script>
68 changes: 52 additions & 16 deletions components/LandingPageDownload.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,55 @@
JabRef is free and works across all your devices.
</h3>
<div class="text-center">
<n-button
type="primary"
size="large"
style="height: 3.2em"
>
<a
class="text-2xl"
:href="downloadUrl"
>Download JabRef</a
>
</n-button>
<span v-if="isWindows()">
<n-flex justify="center">
<DownloadButton
text=".msi"
href="/download/win_msi"
/>
<DownloadButton
text="Windows Portable"
href="/download/win_zip"
/>
</n-flex>
</span>

<span v-if="isLinux()">
<n-flex justify="center">
<DownloadButton
text=".deb"
href="/download/linux_deb"
/>
<DownloadButton
text=".rpm"
href="/download/linux_rpm"
/>
<DownloadButton
text="Linux Portable"
href="/download/linux_tar_gz"
/>
</n-flex>
</span>
<span v-if="isMac()">
<n-flex justify="center">
<DownloadButton
text="arm64 .dmg"
href="/download/mac_arm64_dmg"
/>
<DownloadButton
text="arm64 .dmg"
href="/download/mac_arm64_pkg"
/>
<DownloadButton
text="x86_64 .dmg"
href="/download/mac_x86_64_dmg"
/>
<DownloadButton
text="x86_64 .pkg"
href="/download/mac_x86_64_pkg"
/>
</n-flex>
</span>
</div>

<div class="text-center pt-8 text-sm">
Expand All @@ -30,7 +68,7 @@
Also available for
<t-nuxtlink
class="text-primary-500"
href="download"
href="https://github.com/JabRef/jabref/releases/latest"
>mac OS X and Linux</t-nuxtlink
>
<br />
Expand All @@ -41,7 +79,7 @@
Also available for
<t-nuxtlink
class="text-primary-500"
href="download"
href="https://github.com/JabRef/jabref/releases/latest"
>Windows and Linux</t-nuxtlink
>
<br />
Expand All @@ -52,7 +90,7 @@
Also available for
<t-nuxtlink
class="text-primary-500"
href="download"
href="https://github.com/JabRef/jabref/releases/latest"
>
mac OS X and Windows
</t-nuxtlink>
Expand All @@ -77,6 +115,4 @@
</template>
<script setup lang="ts">
import { isLinux, isMac, isWindows } from '~/composables/detectOs'

const downloadUrl = constructDownloadUrl()
</script>
6 changes: 3 additions & 3 deletions composables/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export function constructDownloadUrl(): string {
if (os) {
osSuffix =
{
windows: 'win',
mac: 'mac',
linux: 'linux',
windows: 'win_msi',
mac: 'mac_arm64_dmg',
linux: 'linux_deb',
}[os] || ''
}
return `/download/${osSuffix}`
Expand Down
32 changes: 26 additions & 6 deletions pages/download/[[os]].vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,43 @@ definePageMeta({
layout: false,

middleware: async (to) => {
let downloadUrl = 'https://www.fosshub.com/JabRef.html'
const os = to.params.os as string | undefined
if (os && ['win', 'mac', 'linux'].includes(os)) {
let downloadUrl = `https://github.com/JabRef/jabref/releases/download/`
if (
os &&
[
'win_msi',
'win_zip',
'mac_arm64_dmg',
'mac_arm64_pkg',
'mac_x86_64_dmg',
'mac_x86_64_pkg',
'linux_deb',
'linux_rpm',
'linux_tar_gz',
].includes(os)
) {
const { data } = await useFetch('/api/getLatestRelease')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in the process of phasing out fosshub, can you change it to github release?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see what I could do+

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Siedlerchr, just finished migrating the links from Fosshub to GitHub Release. There have been troubles on my end though with the useFetch function for some reason that I'm not sure of; this hinders me from fully checking if the implementation's good or not. Using it at the moment in my branch yields an undefined value. I checked the response attained by the function and it said that I had bad credentials. Investigating further led me to see that I do not have a GITHUB_REPO_TOKEN attribute in my .env file. Should I perhaps put a personal GitHub token in the .env file for testing purposes?

For now though, I'll try to work on the overview page. Much thanks!

const latestRelease = data.value?.version
downloadUrl += `v${latestRelease}`
if (latestRelease) {
downloadUrl +=
{
win: `?dwl=JabRef-${latestRelease}.msi`,
mac: `?dwl=JabRef-${latestRelease}.pkg`,
linux: `?dwl=jabref_${latestRelease}_amd64.deb`,
win_msi: `/JabRef-${latestRelease}.msi`,
win_zip: `/JabRef-${latestRelease}-portable_windows.zip`,
mac_arm64_dmg: `/JabRef-${latestRelease}-arm64.dmg`,
mac_arm64_pkg: `/JabRef-${latestRelease}-arm64.pkg`,
mac_x86_64_dmg: `/JabRef-${latestRelease}.dmg`,
mac_x86_64_pkg: `/JabRef-${latestRelease}.pkg`,
linux_deb: `/jabref_${latestRelease}_amd64.deb`,
linux_rpm: `/jabref-${latestRelease}-1.x86_64.rpm`,
linux_tar_gz: `/JabRef-${latestRelease}-portable_linux.tar.gz`,
}[os] ?? ''
}
}

return await navigateTo(downloadUrl, { external: true })
},
})
const downloadUrl = 'https://www.fosshub.com/JabRef.html'
const downloadUrl = `https://github.com/JabRef/jabref/releases/download/`
</script>
3 changes: 1 addition & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<ClientOnly>
<a
class="text-2xl"
:href="constructDownloadUrl()"
href="/#download"
>Download JabRef</a
>
</ClientOnly>
Expand All @@ -97,7 +97,6 @@
</template>

<script setup lang="ts">
import { constructDownloadUrl } from '~/composables/downloads'
definePageMeta({ layout: false })

const links = [
Expand Down
4 changes: 2 additions & 2 deletions server/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ describe('index page', () => {
})

describe('download', () => {
it('redirects to fosshub', async () => {
it('downloads file from GitHub release', async () => {
const response = await fetch('/download')
// Client side redirect uses meta refresh
expect(response.status).toBe(200)
expect(await response.text()).toContain(
'https://www.fosshub.com/JabRef.html',
'https://github.com/JabRef/jabref/releases/download/',
)
})
})
Loading