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

Rework UI in preparation for multiple sources #143

Merged
merged 3 commits into from
Dec 14, 2022
Merged
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
26 changes: 18 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
BASEDIR="[email protected]"
ZIPNAME="$BASEDIR.zip"

rm $ZIPNAME
rm $BASEDIR/schemas/gschemas.compiled
rm $BASEDIR/wallpapers/*
glib-compile-schemas $BASEDIR/schemas/

cd $BASEDIR
zip -r $ZIPNAME .
mv $ZIPNAME ..
rm "$ZIPNAME"
rm "$BASEDIR/schemas/gschemas.compiled"
rm "$BASEDIR/wallpapers/"*
glib-compile-schemas "$BASEDIR/schemas/"

# cd "$BASEDIR/ui" || exit 1
blueprint-compiler batch-compile "$BASEDIR/ui" "$BASEDIR/ui" \
ifl0w marked this conversation as resolved.
Show resolved Hide resolved
"$BASEDIR/ui/generic_json.blp" \
"$BASEDIR/ui/page_general.blp" \
"$BASEDIR/ui/page_sources.blp" \
"$BASEDIR/ui/reddit.blp" \
"$BASEDIR/ui/source_row.blp" \
"$BASEDIR/ui/unsplash.blp" \
"$BASEDIR/ui/wallhaven.blp"

cd "$BASEDIR" || exit 1
zip -r "$ZIPNAME" .
mv "$ZIPNAME" ..
4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

datahome="${XDG_DATA_HOME:-HOME/.local/share}"
Copy link
Owner

Choose a reason for hiding this comment

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

Cool 👍

Copy link
Contributor Author

@Lucki Lucki Dec 14, 2022

Choose a reason for hiding this comment

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

Well, that's embarrassing - I missed a $ before HOME, just recognized this while looking in the description of #144 where I wrote the example correctly…
Another fixing commit for the last PR, sry!


extensionFolder="[email protected]"
sourcepath="$PWD/$extensionFolder"
targetpath="/home/$USER/.local/share/gnome-shell/extensions"
targetpath="$datahome/gnome-shell/extensions"

if [ "$1" = "uninstall" ]; then
echo "# Removing $targetpath/$extensionFolder"
Expand Down
31 changes: 26 additions & 5 deletions [email protected]/jsonpath/jsonpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ var JSONPathParser = function () {
*
* @param inputObject the object to access
* @param inputString the json path expression
* @param randomElements the predefined random Elements
* @param newRandomness whether to ignore previously defined random Elements
* @returns {*}
*/
this.access = function (inputObject, inputString) {
this.access = function (inputObject, inputString, randomElements = null, newRandomness = true) {
Lucki marked this conversation as resolved.
Show resolved Hide resolved
if (inputObject === null || inputObject === undefined) {
return null;
}

if (inputString.length === 0) {
return inputObject;
return {
Object: inputObject,
RandomElements: randomElements,
};
}

if (randomElements === null) {
randomElements = [];
newRandomness = true;
}

let startDot = inputString.indexOf('.');
Expand All @@ -34,7 +44,7 @@ var JSONPathParser = function () {
return null;
}

return this.access(targetObject, inputStringTail)
return this.access(targetObject, inputStringTail, randomElements, newRandomness);

} else {

Expand All @@ -48,11 +58,22 @@ var JSONPathParser = function () {

switch (indexString) {
case "@random":
return this.access(this.randomElement(targetObject), inputStringTail);
let randomNumber = null;
if (!newRandomness && randomElements.length >= 1) {
// Take and remove first element
randomNumber = randomElements.shift();
} else if (!newRandomness && randomElements.length < 1) {
randomNumber = this.randomElement(targetObject);
} else {
randomNumber = this.randomElement(targetObject);
randomElements.push(randomNumber);
}

return this.access(randomNumber, inputStringTail, randomElements, newRandomness);
// add special keywords here
default:
// expecting integer
return this.access(targetObject[parseInt(indexString)], inputStringTail);
return this.access(targetObject[parseInt(indexString)], inputStringTail, randomElements, newRandomness);
}

}
Expand Down
Loading