Merge pull request #554 from SrS2225a/master
Add support for kde integration
This commit is contained in:
commit
5d99a96f84
4 changed files with 89 additions and 1 deletions
|
@ -114,4 +114,35 @@ class ClientController extends Controller
|
|||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
* @throws \Twig\Error\LoaderError
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
*/
|
||||
public function getKDEScript(Request $request, Response $response, int $id): Response
|
||||
{
|
||||
$user = make(UserRepository::class)->get($request, $id, true);
|
||||
|
||||
if (!$user->token) {
|
||||
$this->session->alert(lang('no_upload_token'), 'danger');
|
||||
|
||||
return redirect($response, $request->getHeaderLine('Referer'));
|
||||
}
|
||||
|
||||
return view()->render(
|
||||
$response->withHeader('Content-Disposition', 'attachment;filename="xbackbone_uploader_'.$user->username.'.sh"'),
|
||||
'scripts/xbackbone_kde_uploader.sh.twig',
|
||||
[
|
||||
'username' => $user->username,
|
||||
'upload_url' => route('upload'),
|
||||
'token' => $user->token,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ $app->group('', function (RouteCollectorProxy $group) {
|
|||
$group->post('/user/{id}/refreshToken', [UserController::class, 'refreshToken'])->setName('refreshToken');
|
||||
$group->get('/user/{id}/config/sharex', [ClientController::class, 'getShareXConfig'])->setName('config.sharex');
|
||||
$group->get('/user/{id}/config/script', [ClientController::class, 'getBashScript'])->setName('config.script');
|
||||
$group->get('/user/{id}/config/kde_script', [ClientController::class, 'getKDEScript'])->setName('kde_config.script');
|
||||
|
||||
$group->get('/user/{id}/export', [ExportController::class, 'downloadData'])->setName('export.data');
|
||||
|
||||
|
|
52
resources/templates/scripts/xbackbone_kde_uploader.sh.twig
Normal file
52
resources/templates/scripts/xbackbone_kde_uploader.sh.twig
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
|
||||
create_desktop_entry() {
|
||||
cat << "EOF" > "$HOME/.local/share/kio/servicemenus/xbackbone-uploader.desktop"
|
||||
[Desktop Entry]
|
||||
Type=Service
|
||||
ServiceTypes=KonqPopupMenu/Plugin
|
||||
Icon=imaga
|
||||
X-KDE-StartupNotify=false
|
||||
X-KDE-Priority=TopLevel
|
||||
MimeType=image/*;
|
||||
Actions=xbackbone_upload
|
||||
|
||||
[Desktop Action xbackbone_upload]
|
||||
Name=Upload with XBackBone
|
||||
Exec=sh -c 'RESPONSE="$(curl -s -F "token={{ token }}" -F "upload=@%u" {{ upload_url }})"; if [ "$(echo "${RESPONSE}" | jq -r ".message")" = "OK" ]; then URL="$(echo "${RESPONSE}" | jq -r ".url")"; if [ "${DESKTOP_SESSION}" != "" ]; then echo "${URL}" | xclip -selection c; notify-send "Upload completed!" "${URL}"; else echo "${URL}"; fi; exit 0; else MESSAGE="$(echo "${RESPONSE}" | jq -r ".message")"; if [ $? -ne 0 ]; then echo "Unexpected response:"; echo "${RESPONSE}"; exit 1; fi; if [ "${DESKTOP_SESSION}" != "" ]; then notify-send "Error!" "${MESSAGE}"; else echo "Error! ${MESSAGE}"; fi; exit 1; fi'
|
||||
Icon=image
|
||||
EOF
|
||||
|
||||
echo "Service menu created!";
|
||||
}
|
||||
|
||||
check() {
|
||||
ERRORS=0;
|
||||
|
||||
if [ ! -x "$(command -v jq)" ]; then
|
||||
echo "jq command not found.";
|
||||
ERRORS=1;
|
||||
fi
|
||||
|
||||
if [ ! -x "$(command -v curl)" ]; then
|
||||
echo "curl command not found.";
|
||||
ERRORS=1;
|
||||
fi
|
||||
|
||||
if [ ! -x "$(command -v xclip)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
|
||||
echo "xclip command not found.";
|
||||
ERRORS=1;
|
||||
fi
|
||||
|
||||
if [ ! -x "$(command -v notify-send)" ] && [ "${DESKTOP_SESSION}" != "" ]; then
|
||||
echo "notify-send command not found.";
|
||||
ERRORS=1;
|
||||
fi
|
||||
|
||||
if [ "${ERRORS}" -eq 1 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
check
|
||||
create_desktop_entry
|
|
@ -66,7 +66,11 @@
|
|||
<div class="btn-group">
|
||||
<a href="{{ route('config.sharex', {'id': user.id}) }}" class="btn btn-lg btn-outline-dark"><i class="fas fa-fw fa-download"></i> ShareX</a>
|
||||
<a href="javascript:alert('{{ lang('copied') }}')" data-clipboard-text="{{ route('config.screencloud', {'token': user.token}) }}" class="btn btn-lg btn-outline-info btn-clipboard"><i class="fas fa-fw fa-download"></i> Screencloud</a>
|
||||
<a href="{{ route('config.script', {'id': user.id}) }}" class="btn btn-lg btn-outline-danger"><i class="fas fa-fw fa-download"></i> Linux Script</a>
|
||||
<a href="{{ route('config.script', {'id': user.id}) }}" type="button" class="btn btn-lg btn-outline-danger"><i class="fas fa-fw fa-download"></i> Linux Script</a>
|
||||
<button type="button" class="btn btn-outline-danger dropdown-toggle dropdown-toggle-split" id="userDropdown" data-toggle="dropdown" aria-expanded="false"></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item text-danger" href="{{ route('kde_config.script', {'id': user.id}) }}"><i class="fas fa-fw fa-download"></i> KDE Linux Script</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue