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

Implement localized store #561

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aiohttp==3.8.4
aiohttp==3.8.5
aiohttp-jinja2==1.5.1
aiohttp_cors==0.7.0
watchdog==2.1.7
Expand Down
12 changes: 12 additions & 0 deletions backend/src/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
else:
logger.fatal(f"Could not fetch from URL. {await res.text()}")

storeUrl = ""
match self.settings.getSetting("store", 0):
case 0: storeUrl = "https://plugins.deckbrew.xyz/plugins" # default
case 1: storeUrl = "https://testing.deckbrew.xyz/plugins" # testing
case 2: storeUrl = self.settings.getSetting("store-url", "https://plugins.deckbrew.xyz/plugins") # custom
case _: storeUrl = "https://plugins.deckbrew.xyz/plugins"
logger.info(f"Incrementing installs for {name} from URL {storeUrl} (version {version})")
async with ClientSession() as client:
res = await client.post(storeUrl+f"/{name}/versions/{version}/increment?isUpdate={isInstalled}", ssl=get_ssl_context())
if res.status != 200:
logger.error(f"Server did not accept install count increment request. code: {res.status}")

# Check to make sure we got the file
if res_zip is None:
logger.fatal(f"Could not fetch {artifact}")
Expand Down
26 changes: 24 additions & 2 deletions backend/src/localplatformlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ def chown(path : str, user : UserType = UserType.HOST_USER, recursive : bool =
def chmod(path : str, permissions : int, recursive : bool = True) -> bool:
if _get_effective_user_id() != 0:
return True
result = call(["chmod", "-R", str(permissions), path] if recursive else ["chmod", str(permissions), path])
return result == 0

try:
octal_permissions = int(str(permissions), 8)

if recursive:
for root, dirs, files in os.walk(path):
for d in dirs:
os.chmod(os.path.join(root, d), octal_permissions)
for d in files:
os.chmod(os.path.join(root, d), octal_permissions)

os.chmod(path, octal_permissions)
except:
return False

return True

def folder_owner(path : str) -> UserType|None:
user_owner = _get_user_owner(path)
Expand Down Expand Up @@ -125,11 +139,19 @@ async def service_restart(service_name : str) -> bool:
return res.returncode == 0

async def service_stop(service_name : str) -> bool:
if not await service_active(service_name):
# Service isn't running. pretend we stopped it
return True

cmd = ["systemctl", "stop", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0

async def service_start(service_name : str) -> bool:
if await service_active(service_name):
# Service is running. pretend we started it
return True

cmd = ["systemctl", "start", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0
Expand Down
21 changes: 7 additions & 14 deletions frontend/src/components/PluginView.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
ButtonItem,
Focusable,
PanelSection,
PanelSectionRow,
joinClassNames,
scrollClasses,
staticClasses,
} from 'decky-frontend-lib';
import { ButtonItem, Focusable, PanelSection, PanelSectionRow } from 'decky-frontend-lib';
import { VFC, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaEyeSlash } from 'react-icons/fa';
Expand Down Expand Up @@ -36,10 +28,7 @@ const PluginView: VFC = () => {
return (
<Focusable onCancelButton={closeActivePlugin}>
<TitleView />
<div
className={joinClassNames(staticClasses.TabGroupPanel, scrollClasses.ScrollPanel, scrollClasses.ScrollY)}
style={{ height: '100%' }}
>
<div style={{ height: '100%', paddingTop: '16px' }}>
{(visible || activePlugin.alwaysRender) && activePlugin.content}
</div>
</Focusable>
Expand All @@ -48,7 +37,11 @@ const PluginView: VFC = () => {
return (
<>
<TitleView />
<div className={joinClassNames(staticClasses.TabGroupPanel, scrollClasses.ScrollPanel, scrollClasses.ScrollY)}>
<div
style={{
paddingTop: '16px',
}}
>
<PanelSection>
{pluginList
.filter((p) => p.content)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/TitleView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const titleStyles: CSSProperties = {
display: 'flex',
paddingTop: '3px',
paddingRight: '16px',
position: 'sticky',
top: '0px',
};

const TitleView: VFC = () => {
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ export async function getPluginList(): Promise<StorePlugin[]> {
headers: {
'X-Decky-Version': version.current,
},
}).then((r) => r.json());
}).then((r) => {
let res = JSON.parse(JSON.stringify(r.json()));
const lng = navigator.language;
if (res.hasOwnProperty('name-' + lng)) {
res.name = res['name-' + lng];
}
if (res.hasOwnProperty('description-' + lng)) {
res.description = res['description-' + lng];
}
return res;
});
}

export async function installFromURL(url: string) {
Expand Down
Loading