-
Notifications
You must be signed in to change notification settings - Fork 70
Allow url adressible version on app page #193
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
Open
rnwood
wants to merge
5
commits into
SplashtopInc:master
Choose a base branch
from
rnwood:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c89475
Initial plan
Copilot e62fae7
Add URL addressable version selection with path-based routing (/apps/…
Copilot ef92ec6
Add mock API endpoints for local testing
Copilot 825ff3b
Fix useEffect dependency array in SingleApp.js
Copilot dad6024
Merge pull request #1 from rnwood/copilot/add-url-addressable-version…
rnwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Mock API endpoint for testing - returns a single app by ID | ||
| export default function handler(req, res) { | ||
| const { id } = req.query; | ||
|
|
||
| const mockApps = { | ||
| "7zip.7zip": { | ||
| _id: "7zip.7zip", | ||
| name: "7-Zip", | ||
| publisher: "Igor Pavlov", | ||
| desc: "7-Zip is a file archiver with a high compression ratio. It supports packing and unpacking various archive formats including 7z, ZIP, GZIP, BZIP2, TAR, and more. The software features a high compression ratio in 7z format, strong AES-256 encryption, self-extracting capability, and integration with Windows Shell.", | ||
| icon: null, | ||
| homepage: "https://www.7-zip.org/", | ||
| latestVersion: "24.09", | ||
| updatedAt: new Date().toISOString(), | ||
| license: "LGPL-2.1", | ||
| licenseUrl: "https://www.7-zip.org/license.txt", | ||
| versions: [ | ||
| { version: "24.09", installers: ["https://example.com/7z2409-x64.exe"], installerType: "exe" }, | ||
| { version: "24.08", installers: ["https://example.com/7z2408-x64.exe"], installerType: "exe" }, | ||
| { version: "24.07", installers: ["https://example.com/7z2407-x64.exe"], installerType: "exe" }, | ||
| { version: "23.01", installers: ["https://example.com/7z2301-x64.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["archive", "compression", "zip", "7z", "utility"], | ||
| }, | ||
| "Mozilla.Firefox": { | ||
| _id: "Mozilla.Firefox", | ||
| name: "Firefox", | ||
| publisher: "Mozilla", | ||
| desc: "Firefox is a free and open-source web browser developed by Mozilla. It uses the Gecko rendering engine to display web pages, which implements current and anticipated web standards. Firefox includes tabbed browsing, spell checking, incremental find, live bookmarking, and a download manager.", | ||
| icon: null, | ||
| homepage: "https://www.mozilla.org/firefox/", | ||
| latestVersion: "133.0", | ||
| updatedAt: new Date().toISOString(), | ||
| license: "MPL-2.0", | ||
| licenseUrl: "https://www.mozilla.org/MPL/2.0/", | ||
| versions: [ | ||
| { version: "133.0", installers: ["https://example.com/firefox-133.exe"], installerType: "exe" }, | ||
| { version: "132.0", installers: ["https://example.com/firefox-132.exe"], installerType: "exe" }, | ||
| { version: "131.0", installers: ["https://example.com/firefox-131.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["browser", "web", "mozilla", "internet"], | ||
| }, | ||
| "Microsoft.VisualStudioCode": { | ||
| _id: "Microsoft.VisualStudioCode", | ||
| name: "Visual Studio Code", | ||
| publisher: "Microsoft", | ||
| desc: "Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. It is free and built on open source. It features IntelliSense, debugging, built-in Git support, and thousands of extensions.", | ||
| icon: null, | ||
| homepage: "https://code.visualstudio.com/", | ||
| latestVersion: "1.95.0", | ||
| updatedAt: new Date().toISOString(), | ||
| license: "MIT", | ||
| licenseUrl: "https://code.visualstudio.com/license", | ||
| versions: [ | ||
| { version: "1.95.0", installers: ["https://example.com/vscode-1.95.exe"], installerType: "exe" }, | ||
| { version: "1.94.0", installers: ["https://example.com/vscode-1.94.exe"], installerType: "exe" }, | ||
| { version: "1.93.0", installers: ["https://example.com/vscode-1.93.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["editor", "code", "ide", "microsoft", "development"], | ||
| }, | ||
| }; | ||
|
|
||
| const app = mockApps[id]; | ||
|
|
||
| if (!app) { | ||
| res.status(404).json({ error: "App not found" }); | ||
| return; | ||
| } | ||
|
|
||
| res.status(200).json(app); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Mock API endpoint for testing - returns a list of apps | ||
| export default function handler(req, res) { | ||
| const mockApps = [ | ||
| { | ||
| _id: "7zip.7zip", | ||
| name: "7-Zip", | ||
| publisher: "Igor Pavlov", | ||
| desc: "7-Zip is a file archiver with a high compression ratio.", | ||
| icon: null, | ||
| homepage: "https://www.7-zip.org/", | ||
| latestVersion: "24.09", | ||
| updatedAt: new Date().toISOString(), | ||
| versions: [ | ||
| { version: "24.09", installers: ["https://example.com/7z2409-x64.exe"], installerType: "exe" }, | ||
| { version: "24.08", installers: ["https://example.com/7z2408-x64.exe"], installerType: "exe" }, | ||
| { version: "24.07", installers: ["https://example.com/7z2407-x64.exe"], installerType: "exe" }, | ||
| { version: "23.01", installers: ["https://example.com/7z2301-x64.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["archive", "compression", "zip", "7z"], | ||
| }, | ||
| { | ||
| _id: "Mozilla.Firefox", | ||
| name: "Firefox", | ||
| publisher: "Mozilla", | ||
| desc: "Firefox is a free and open-source web browser developed by Mozilla.", | ||
| icon: null, | ||
| homepage: "https://www.mozilla.org/firefox/", | ||
| latestVersion: "133.0", | ||
| updatedAt: new Date().toISOString(), | ||
| versions: [ | ||
| { version: "133.0", installers: ["https://example.com/firefox-133.exe"], installerType: "exe" }, | ||
| { version: "132.0", installers: ["https://example.com/firefox-132.exe"], installerType: "exe" }, | ||
| { version: "131.0", installers: ["https://example.com/firefox-131.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["browser", "web", "mozilla"], | ||
| }, | ||
| { | ||
| _id: "Microsoft.VisualStudioCode", | ||
| name: "Visual Studio Code", | ||
| publisher: "Microsoft", | ||
| desc: "Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.", | ||
| icon: null, | ||
| homepage: "https://code.visualstudio.com/", | ||
| latestVersion: "1.95.0", | ||
| updatedAt: new Date().toISOString(), | ||
| versions: [ | ||
| { version: "1.95.0", installers: ["https://example.com/vscode-1.95.exe"], installerType: "exe" }, | ||
| { version: "1.94.0", installers: ["https://example.com/vscode-1.94.exe"], installerType: "exe" }, | ||
| { version: "1.93.0", installers: ["https://example.com/vscode-1.93.exe"], installerType: "exe" }, | ||
| ], | ||
| tags: ["editor", "code", "ide", "microsoft"], | ||
| }, | ||
| ]; | ||
|
|
||
| res.status(200).json(mockApps); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import styles from "../../../styles/home.module.scss"; | ||
|
|
||
| import SingleApp from "../../../components/SingleApp"; | ||
|
|
||
| import Footer from "../../../components/Footer"; | ||
| import Error from "../../../components/Error"; | ||
|
|
||
| import Skeleton from "react-loading-skeleton"; | ||
|
|
||
| import { useRouter } from "next/router"; | ||
| import MetaTags from "../../../components/MetaTags"; | ||
| import fetchWinstallAPI from "../../../utils/fetchWinstallAPI"; | ||
| import DonateCard from "../../../components/DonateCard"; | ||
|
|
||
| function AppSkeleton() { | ||
| return ( | ||
| <div> | ||
| <div className="skeleton-group"> | ||
| <Skeleton circle={true} height={30} width={30} /> | ||
| <Skeleton count={1} height={25} /> | ||
| </div> | ||
| <Skeleton count={5} height={20} /> | ||
| <div className="skeleton-list"> | ||
| <Skeleton count={5} width={250} /> | ||
| </div> | ||
| <div className="skeleton-button"> | ||
| <Skeleton count={1} width={140} height={50} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function AppDetail({ app, initialVersion }) { | ||
| const router = useRouter(); | ||
| const fallbackMessage = { | ||
| title: "Sorry! We could not load this app.", | ||
| subtitle: "Unfortunately, this app could not be loaded. Either it does not exist, or something else went wrong. Please try again later." | ||
| } | ||
|
|
||
| if(!router.isFallback && !app){ | ||
| return <Error {...fallbackMessage}/> | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className={styles.intro}> | ||
| <div className="illu-box"> | ||
| {router.isFallback ? ( | ||
| <AppSkeleton/> | ||
| ) : ( | ||
| <div> | ||
| <MetaTags | ||
| title={`Install ${app.name} v${initialVersion} with winget - winstall`} | ||
| desc={app.desc} | ||
| /> | ||
| <ul className="largeApp"><SingleApp app={app} large={true} initialVersion={initialVersion}/></ul> | ||
| <DonateCard addMargin="top"/> | ||
| </div> | ||
| )} | ||
| <div className="art"> | ||
| <img | ||
| src="/assets/logo.svg" | ||
| draggable={false} | ||
| alt="winstall logo" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <Footer /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export async function getStaticPaths() { | ||
| return { | ||
| paths: [], | ||
| fallback: true, | ||
| }; | ||
| } | ||
|
|
||
| export async function getStaticProps({ params }) { | ||
| try{ | ||
| let { response: app } = await fetchWinstallAPI(`/apps/${params.id}`); | ||
|
|
||
| if (!app) { | ||
| return { props: {} }; | ||
| } | ||
|
|
||
| // Validate that the version exists for this app | ||
| const versionExists = app.versions && app.versions.some(v => v.version === params.version); | ||
|
|
||
| if (!versionExists) { | ||
| return { props: {} }; | ||
| } | ||
|
|
||
| return { props: { app, initialVersion: params.version } } | ||
| } catch(err) { | ||
| return { props: {} }; | ||
| } | ||
| } | ||
|
|
||
| export default AppDetail; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I don't think we should duplicate this list of apps (here and in
[id].js). If there is such a mock list, then it should only exist once in the code base. That doesn't mean that the list can't be exposed as an API in multiple places though, of course.