Merge pull request #35 from ifl0w/develop

Version 2.2.2
This commit is contained in:
Wolfgang Rumpler 2018-04-13 00:24:44 +02:00 committed by GitHub
commit 3962e9c0b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 128 additions and 94 deletions

View file

@ -6,33 +6,34 @@ Random Wallpapers for Gnome 3 is a gnome shell extension which fetches a random
![Screenshot](/assets/screenshot.png)
## Installation (symlink to repository)
Run `git clone git@github.com:ifl0w/RandomWallpaperGnome3.git` to clone the repository.
Run `./install.sh` to make a symbolic link from the extensions folder to the git repository.
Clone the repository and run `./install.sh` in the repository folder to make a symbolic link from the extensions folder to the git repository.
This installation will depend on the repository folder, so do not delete the cloned folder.
Then open the command prompt (Alt+F2) end enter `r` to restart the gnome session.
In the case you are using wayland, then no restart should be required.
Now you should be able to activate the extension through the gnome-tweak-tool.
__Installing this way has various advantages:__
* Switching between versions and branches.
* Updateing the extension with `git pull`
## Installation (manually)
Open the commandline and type the following lines:
Clone or download the repository and copy the folder `randomwallpaper@iflow.space` in the repository to `~/.local/share/gnome-shell/extensions/`.
```
git clone git@github.com:ifl0w/RandomWallpaperGnome3.git
cp -r RandomWallpaperGnome3/randomwallpaper@iflow.space ~/.local/share/gnome-shell/extensions/
```
Then open the command prompt (Alt+F2) end enter `r` to restart the gnome session.
In the case you are using wayland, then no restart should be required.
Then open the command prompt (Alt+F2) end enter `r` without qotes.
Now you should be able to activate the extension through the gnome-tweak-tool.
## Uninstall
Run `./install uninstall` to delete the symbolic link.
If you installed the extension manually you have to delete the extension folder with `rm -rf ~/.local/share/gnome-shell/extensions/randomwallpaper@iflow.space`.
If you installed the extension manually you have to delete the extension folder `randomwallpaper@iflow.space` in `~/.local/share/gnome-shell/extensions/`.
## Debugging
Extension output can be followed with `./debug.sh`. Information should be printed using the existing logger class but can also be printed with `global.log()` (not recommended).
To debug the prefs.js use `./debug.sh perfs`.
To debug the `prefs.js` use `./debug.sh perfs`.
## Compiling schemas
This can be done with the command: `glib-compile-schemas randomwallpaper@iflow.space/schemas/`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -8,13 +8,17 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
width="120"
height="120"
viewBox="0 0 120 120"
version="1.1"
id="svg4"
sodipodi:docname="icon.svg"
inkscape:version="0.92.1 r">
sodipodi:docname="icon_v2.svg"
inkscape:version="0.92.2 2405546, 2018-03-11"
style="enable-background:new"
inkscape:export-filename="/home/wolfgang/Develop/RandomWallpaperGnome3/assets/icon.svg.png"
inkscape:export-xdpi="212"
inkscape:export-ydpi="212">
<metadata
id="metadata10">
<rdf:RDF>
@ -50,6 +54,16 @@
x2="24"
y2="12"
gradientUnits="userSpaceOnUse" />
<filter
inkscape:collect="always"
style="color-interpolation-filters:sRGB"
id="filter852">
<feBlend
inkscape:collect="always"
mode="multiply"
in2="BackgroundImage"
id="feBlend854" />
</filter>
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
@ -61,23 +75,39 @@
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1145"
inkscape:window-height="1172"
id="namedview6"
showgrid="false"
inkscape:zoom="4.9166667"
inkscape:cx="41.499897"
inkscape:cy="40.854617"
inkscape:zoom="2.3350001"
inkscape:cx="-73.129975"
inkscape:cy="-22.174101"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-y="28"
inkscape:window-maximized="1"
inkscape:current-layer="svg4"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<path
style="fill:#33334b;fill-opacity:1;stroke:none;stroke-width:13.66373348;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="M 5.515625,0 C 2.4604779,0 0,2.460478 0,5.515625 v 88.96875 C 0,97.539522 2.4604779,100 5.515625,100 h 88.970703 c 3.055148,0 5.513671,-2.460478 5.513671,-5.515625 V 5.515625 C 99.999999,2.460478 97.541476,0 94.486328,0 Z M 16.150391,14.357422 H 83.84961 c 0.981656,0.0014 1.791596,0.811308 1.792968,1.792969 v 53.591796 c -0.0014,0.981653 -0.805639,1.799405 -1.792968,1.800782 H 16.150391 c -0.987332,-0.0014 -1.791593,-0.819133 -1.792969,-1.800782 V 16.150391 c 0.0014,-0.981657 0.811312,-1.791594 1.792969,-1.792969 z m 7.857422,8.041016 c -0.988906,2.75e-4 -1.775116,0.786485 -1.775391,1.77539 v 37.542969 c 2.75e-4,0.988909 0.786484,1.777067 1.775391,1.777344 h 51.984375 c 0.988901,-2.77e-4 1.775114,-0.788439 1.77539,-1.777344 V 24.173828 c -2.76e-4,-0.988906 -0.786489,-1.775115 -1.77539,-1.77539 z m 3.439453,2.470703 h 45.107422 c 0.567933,-4.7e-5 1.12966,0.230279 1.53125,0.623047 0.401589,0.392767 0.636766,0.942589 0.636719,1.498046 v 31.863282 c 4.7e-5,0.555457 -0.23513,1.105279 -0.636719,1.498046 -0.40159,0.392768 -0.963317,0.621141 -1.53125,0.621094 H 27.447266 c -0.567934,4.7e-5 -1.131613,-0.228326 -1.533203,-0.621094 -0.40159,-0.392767 -0.636767,-0.942589 -0.636719,-1.498046 V 26.990234 c -4.8e-5,-0.555457 0.235129,-1.105279 0.636719,-1.498046 0.40159,-0.392768 0.965269,-0.623094 1.533203,-0.623047 z M 40.40625,73.59375 h 19.1875 c 0.521531,0.0013 1.013887,0.230804 1.351563,0.621094 l 7.335937,8.464843 c 0.483066,0.562457 0.543936,1.329127 0.275391,1.917969 -0.26855,0.588843 -0.885438,1.041378 -1.626953,1.044922 H 33.070313 c -0.741487,-0.0036 -1.358401,-0.456092 -1.626953,-1.044922 -0.268553,-0.58883 -0.207669,-1.35552 0.27539,-1.917969 l 7.335938,-8.464843 c 0.337681,-0.390282 0.830068,-0.619807 1.351562,-0.621094 z"
id="rect4614"
inkscape:connector-curvature="0" />
fit-margin-top="10"
fit-margin-left="10"
fit-margin-right="10"
fit-margin-bottom="10" />
<g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="Layer 1"
style="display:inline"
transform="translate(10,10)" />
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer 2"
style="display:inline;opacity:1"
transform="translate(10,10)" />
<g
id="g1257"
transform="translate(10,10)">
<path
id="rect4614"
style="fill:#326679;fill-opacity:1;stroke:none;stroke-width:11.24918652;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
d="m 22.132812,25.824219 c -0.808185,0.0011 -1.475462,0.668376 -1.476562,1.476562 v 44.121094 c 0.0011,0.808179 0.663704,1.481322 1.476562,1.482422 h 55.734376 c 0.812856,-0.0011 1.475462,-0.674239 1.476562,-1.482422 V 27.300781 c -0.0011,-0.808189 -0.668375,-1.475462 -1.476562,-1.476562 z m 31.785157,10.628906 8.666015,2.931641 -6.039062,6.871093 -0.986328,-3.675781 c -5.578248,1.494688 -6.167418,4.933346 -6.847656,8.914063 -0.730238,4.264682 -1.553892,9.098413 -8.81836,11.044921 l -2.451172,0.65625 -0.65625,-2.451171 2.451172,-0.65625 c 5.69344,-1.525554 6.285112,-4.999405 6.972656,-9.021485 0.724069,-4.22888 1.54409,-9.021858 8.69336,-10.9375 z m -14.376953,8.412109 c 2.06771,0.104266 3.689143,0.799733 5.052734,1.777344 -0.288344,0.93362 -0.494193,1.855058 -0.65625,2.720703 -1.873113,-1.657387 -4.148218,-2.557714 -7.986328,-1.529297 l -2.449219,0.65625 -0.658203,-2.451172 2.451172,-0.65625 c 1.603807,-0.429738 3.005467,-0.580137 4.246094,-0.517578 z m 18.316406,6.292969 8.666016,2.931641 -6.039063,6.871094 L 59.5,57.285156 c -4.227803,1.132836 -7.032531,0.283284 -9.193359,-1.28125 0.290797,-0.934276 0.498041,-1.853122 0.660156,-2.71875 1.856434,1.653971 4.095715,2.561486 7.875,1.548828 z M 42.101562,74.59375 c -0.429336,0.0011 -0.835273,0.190404 -1.113281,0.511719 l -6.039062,4.630859 c -0.397699,0.463058 -0.447658,1.093346 -0.226563,1.578125 0.221095,0.484777 0.729383,0.858528 1.339844,0.861328 h 27.875 c 0.610478,-0.0029 1.11875,-0.376541 1.339844,-0.861328 0.221092,-0.484788 0.171144,-1.115063 -0.226563,-1.578125 L 59.011719,75.105469 C 58.733714,74.784146 58.327809,74.59485 57.898438,74.59375 Z M 50,0 A 50,50 0 0 0 0,50 50,50 0 0 0 50,100 50,50 0 0 0 100,50 50,50 0 0 0 50,0 Z m 0,6.1328125 A 43.867611,43.867611 0 0 1 93.867188,50 43.867611,43.867611 0 0 1 50,93.867188 43.867611,43.867611 0 0 1 6.1328125,50 43.867611,43.867611 0 0 1 50,6.1328125 Z"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -96,7 +96,7 @@ var HistoryElement = new Lang.Class({
this.imageUrlItem = new PopupMenu.PopupMenuItem('Open Image In Browser');
this.imageUrlItem.connect('activate', () => {
Util.spawn(['xdg-open', this.historyEntry.source.imageUrl]);
Util.spawn(['xdg-open', this.historyEntry.source.imageLinkUrl]);
});
this.menu.addMenuItem(this.imageUrlItem);

View file

@ -24,7 +24,8 @@ var HistoryEntry = new Lang.Class({
authorUrl: null,
source: source,
sourceUrl: null,
imageUrl: url
imageDownloadUrl: url, // URL used for downloading the image
imageLinkUrl: url // URL used for linking back to the website of the image
};
},
});

View file

@ -3,13 +3,14 @@
"3.20",
"3.22",
"3.24",
"3.26"
"3.26",
"3.28"
],
"uuid": "randomwallpaper@iflow.space",
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
"name": "Random Wallpaper",
"description": "Fetches a random wallpaper from an online source and sets it as desktop background. \nThe desktop background can be updated periodically or manually.",
"version": 10,
"semantic-version": "2.2.1",
"version": 11,
"semantic-version": "2.2.2",
"url": "https://github.com/ifl0w/RandomWallpaperGnome3"
}

View file

@ -14,7 +14,7 @@ const Gettext = imports.gettext.domain('space.iflow.randomwallpaper');
const RWG_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.space.iflow.randomwallpaper';
const RWG_SETTINGS_SCHEMA_DESKTOPPER = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.desktopper';
const RWG_SETTINGS_SCHEMA_UNSPLASH = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.unsplash';
const RWG_SETTINGS_SCHEMA_WALLHEAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallheaven';
const RWG_SETTINGS_SCHEMA_WALLHAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven';
const RWG_SETTINGS_SCHEMA_GENERIC_JSON = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.genericJSON';
const LoggerModule = Self.imports.logger;
@ -41,7 +41,7 @@ var RandomWallpaperSettings = new Lang.Class({
noSettings: null,
desktopperSettings: null,
unsplashSettings: null,
wallheavenSettings: null,
wallhavenSettings: null,
genericJsonSettings: null,
_init: function () {
@ -64,10 +64,10 @@ var RandomWallpaperSettings = new Lang.Class({
this.unsplashSettings = this._builder.get_object('unsplash-settings');
this.bindUnsplash();
// Wallheaven Settings
this._wallheaven_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_WALLHEAVEN);
this.wallheavenSettings = this._builder.get_object('wallheaven-settings');
this.bindWallheaven();
// Wallhaven Settings
this._wallhaven_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_WALLHAVEN);
this.wallhavenSettings = this._builder.get_object('wallhaven-settings');
this.bindWallhaven();
// Generic JSON Settings
this._generic_json_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_GENERIC_JSON);
@ -95,8 +95,8 @@ var RandomWallpaperSettings = new Lang.Class({
case 1: // desktopper
this.currentSourceSettingsWidget = this.desktopperSettings;
break;
case 2: // wallheaven
this.currentSourceSettingsWidget = this.wallheavenSettings;
case 2: // wallhaven
this.currentSourceSettingsWidget = this.wallhavenSettings;
break;
case 3: // generic JSON
this.currentSourceSettingsWidget = this.genericJsonSettings;
@ -180,35 +180,35 @@ var RandomWallpaperSettings = new Lang.Class({
Gio.SettingsBindFlags.DEFAULT);
},
bindWallheaven: function () {
this._wallheaven_settings.bind('wallheaven-keyword',
this._builder.get_object('wallheaven-keyword'),
bindWallhaven: function () {
this._wallhaven_settings.bind('wallhaven-keyword',
this._builder.get_object('wallhaven-keyword'),
'text',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('resolutions',
this._builder.get_object('wallheaven-resolutions'),
this._wallhaven_settings.bind('resolutions',
this._builder.get_object('wallhaven-resolutions'),
'text',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('category-general',
this._builder.get_object('wallheaven-category-general'),
this._wallhaven_settings.bind('category-general',
this._builder.get_object('wallhaven-category-general'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('category-anime',
this._builder.get_object('wallheaven-category-anime'),
this._wallhaven_settings.bind('category-anime',
this._builder.get_object('wallhaven-category-anime'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('category-people',
this._builder.get_object('wallheaven-category-people'),
this._wallhaven_settings.bind('category-people',
this._builder.get_object('wallhaven-category-people'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('allow-sfw',
this._builder.get_object('wallheaven-allow-sfw'),
this._wallhaven_settings.bind('allow-sfw',
this._builder.get_object('wallhaven-allow-sfw'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._wallheaven_settings.bind('allow-sketchy',
this._builder.get_object('wallheaven-allow-sketchy'),
this._wallhaven_settings.bind('allow-sketchy',
this._builder.get_object('wallhaven-allow-sketchy'),
'active',
Gio.SettingsBindFlags.DEFAULT);
},

View file

@ -4,7 +4,7 @@
<enum id='org.gnome.shell.extensions.space.iflow.randomwallpaper.sources'>
<value value='0' nick='unsplash'/>
<value value='1' nick='desktoppr'/>
<value value='2' nick='wallheaven'/>
<value value='2' nick='wallhaven'/>
<value value='3' nick='genericJSON'/>
</enum>
@ -109,8 +109,8 @@
</schema>
<schema path="/org/gnome/shell/extensions/space-iflow-randomwallpaper-sources/"
id='org.gnome.shell.extensions.space.iflow.randomwallpaper.wallheaven'>
<key type='s' name='wallheaven-keyword'>
id='org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven'>
<key type='s' name='wallhaven-keyword'>
<default>""</default>
<summary>Keyword</summary>
<description>The keyword will be used to search images.</description>

View file

@ -278,7 +278,7 @@ You can also define a prefix that will be added to the image URL.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">The source that is used to fetch random wallpapers. You can select between unsplash.com, desktoppr.co, wallheaven.cc and a generic JSON source for experienced users.</property>
<property name="label" translatable="yes">The source that is used to fetch random wallpapers. You can select between unsplash.com, desktoppr.co, wallhaven.cc and a generic JSON source for experienced users.</property>
<property name="wrap">True</property>
<property name="max_width_chars">1</property>
<property name="xalign">0</property>
@ -316,7 +316,7 @@ You can also define a prefix that will be added to the image URL.</property>
<items>
<item id="unsplash">unsplash.com</item>
<item id="desktoppr">desktoppr.co</item>
<item id="wallheaven">alpha.wallheaven.cc</item>
<item id="wallhaven">alpha.wallhaven.cc</item>
<item id="genericJSON" translatable="yes">Generic JSON</item>
</items>
</object>
@ -1187,7 +1187,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
</object>
<object class="GtkBox" id="wallheaven-settings">
<object class="GtkBox" id="wallhaven-settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
@ -1209,7 +1209,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="wallheaven-keyword">
<object class="GtkEntry" id="wallhaven-keyword">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">10</property>
@ -1241,7 +1241,7 @@ You can also define a prefix that will be added to the image URL.</property>
<property name="margin_bottom">10</property>
<property name="layout_style">start</property>
<child>
<object class="GtkCheckButton" id="wallheaven-allow-sfw">
<object class="GtkCheckButton" id="wallhaven-allow-sfw">
<property name="label" translatable="yes">SFW (Safe for work)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -1255,7 +1255,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wallheaven-allow-sketchy">
<object class="GtkCheckButton" id="wallhaven-allow-sketchy">
<property name="label" translatable="yes">Sketchy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -1295,7 +1295,7 @@ You can also define a prefix that will be added to the image URL.</property>
<property name="margin_bottom">10</property>
<property name="layout_style">start</property>
<child>
<object class="GtkCheckButton" id="wallheaven-category-general">
<object class="GtkCheckButton" id="wallhaven-category-general">
<property name="label" translatable="yes">General</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -1309,7 +1309,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wallheaven-category-anime">
<object class="GtkCheckButton" id="wallhaven-category-anime">
<property name="label" translatable="yes">Anime</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -1323,7 +1323,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wallheaven-category-people">
<object class="GtkCheckButton" id="wallhaven-category-people">
<property name="label" translatable="yes">People</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -1357,7 +1357,7 @@ You can also define a prefix that will be added to the image URL.</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="wallheaven-resolutions">
<object class="GtkEntry" id="wallhaven-resolutions">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="placeholder_text" translatable="yes">1920x1080, 1920x1200</property>

View file

@ -7,7 +7,7 @@ const Json = imports.gi.Json;
const RWG_SETTINGS_SCHEMA_DESKTOPPER = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.desktopper';
const RWG_SETTINGS_SCHEMA_UNSPLASH = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.unsplash';
const RWG_SETTINGS_SCHEMA_WALLHEAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallheaven';
const RWG_SETTINGS_SCHEMA_WALLHAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven';
const RWG_SETTINGS_SCHEMA_GENERIC_JSON = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.genericJSON';
const SettingsModule = Self.imports.settings;
@ -74,10 +74,10 @@ var DesktopperAdapter = new Lang.Class({
session.queue_message(message, (session, message) => {
let data = JSON.parse(message.response_body.data);
let response = data.response;
let imageUrl = encodeURI(response.image.url);
let imageDownloadUrl = encodeURI(response.image.url);
if (callback) {
let historyEntry = new HistoryModule.HistoryEntry(null, 'desktopper.co', imageUrl);
let historyEntry = new HistoryModule.HistoryEntry(null, 'desktopper.co', imageDownloadUrl);
historyEntry.source.sourceUrl = 'https://www.desktoppr.co/';
callback(historyEntry);
}
@ -128,6 +128,7 @@ var UnsplashAdapter = new Lang.Class({
let authorName = data.user.name;
let authorUrl = encodeURI(data.user.links.html);
let imageLinkUrl = encodeURI(data.urls.raw + '&' + utmParameters);
let downloadLocation = data.links.download_location + '?' + clientParam;
let downloadMessage = Soup.Message.new('GET', downloadLocation);
@ -135,12 +136,11 @@ var UnsplashAdapter = new Lang.Class({
session.queue_message(downloadMessage, (session, message) => {
let downloadData = JSON.parse(message.response_body.data);
let imageUrl = encodeURI(downloadData.url + '&' + utmParameters);
if (callback) {
let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(imageUrl));
let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(downloadData.url));
historyEntry.source.sourceUrl = encodeURI(this.sourceUrl + '?' + utmParameters);
historyEntry.source.authorUrl = encodeURI(authorUrl + '?' + utmParameters);
historyEntry.source.imageLinkUrl = imageLinkUrl;
callback(historyEntry);
}
});
@ -177,8 +177,8 @@ var UnsplashAdapter = new Lang.Class({
}
});
var WallheavenAdapter = new Lang.Class({
Name: "WallheavenAdapter",
var WallhavenAdapter = new Lang.Class({
Name: "WallhavenAdapter",
Extends: BaseAdapter,
_settings: null,
@ -194,7 +194,7 @@ var WallheavenAdapter = new Lang.Class({
_init: function () {
this.parent();
this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_WALLHEAVEN);
this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_WALLHAVEN);
},
requestRandomImage: function (callback) {
@ -223,14 +223,15 @@ var WallheavenAdapter = new Lang.Class({
session.queue_message(message, () => {
let body = message.response_body.data;
let imageUrl = body.match(new RegExp(/\/\/wallpapers.wallhaven.cc\/wallpapers\/full\/.*?"/))[0];
imageUrl = imageUrl.slice(0, -1);
imageUrl = 'http:' + imageUrl;
imageUrl = encodeURI(imageUrl);
let imageDownloadUrl = body.match(new RegExp(/\/\/wallpapers.wallhaven.cc\/wallpapers\/full\/.*?"/))[0];
imageDownloadUrl = imageDownloadUrl.slice(0, -1);
imageDownloadUrl = 'http:' + imageDownloadUrl;
imageDownloadUrl = encodeURI(imageDownloadUrl);
if (callback) {
let historyEntry = new HistoryModule.HistoryEntry(null, 'wallhaven.cc', imageUrl);
let historyEntry = new HistoryModule.HistoryEntry(null, 'wallhaven.cc', imageDownloadUrl);
historyEntry.source.sourceUrl = 'https://alpha.wallhaven.cc/';
historyEntry.source.imageLinkUrl = url;
callback(historyEntry);
}
})
@ -259,7 +260,7 @@ var WallheavenAdapter = new Lang.Class({
},
_readOptionsFromSettings: function () {
this.options.q = this._settings.get('wallheaven-keyword', 'string');
this.options.q = this._settings.get('wallhaven-keyword', 'string');
this.options.resolutions = this._settings.get('resolutions', 'string').split(',');
this.options.resolutions = this.options.resolutions.map((elem) => {
@ -275,7 +276,7 @@ var WallheavenAdapter = new Lang.Class({
let purity = [];
purity.push(+this._settings.get('allow-sfw', 'boolean'));
purity.push(+this._settings.get('allow-sketchy', 'boolean'));
purity.push(0); // required by wallheaven
purity.push(0); // required by wallhaven
this.options.purity = purity.join('');
}
});
@ -304,12 +305,12 @@ var GenericJsonAdapter = new Lang.Class({
session.queue_message(message, (session, message) => {
let response = JSON.parse(message.response_body.data);
let JSONPath = this._settings.get("generic-json-response-path", "string");
let imageUrl = this._jsonPathParser.access(response, JSONPath);
imageUrl = this._settings.get("generic-json-url-prefix", "string") + imageUrl;
let imageDownloadUrl = this._jsonPathParser.access(response, JSONPath);
imageDownloadUrl = this._settings.get("generic-json-url-prefix", "string") + imageDownloadUrl;
if (callback) {
let historyEntry = new HistoryModule.HistoryEntry(null, 'Generic JSON Source', imageUrl);
historyEntry.source.sourceUrl = imageUrl;
let historyEntry = new HistoryModule.HistoryEntry(null, 'Generic JSON Source', imageDownloadUrl);
historyEntry.source.sourceUrl = imageDownloadUrl;
callback(historyEntry);
}
});

View file

@ -59,7 +59,7 @@ var WallpaperController = new Lang.Class({
this._desktopperAdapter = new SourceAdapter.DesktopperAdapter();
this._unsplashAdapter = new SourceAdapter.UnsplashAdapter();
this._wallheavenAdapter = new SourceAdapter.WallheavenAdapter();
this._wallhavenAdapter = new SourceAdapter.WallhavenAdapter();
this._genericJsonAdapter = new SourceAdapter.GenericJsonAdapter();
this.logger = new LoggerModule.Logger('RWG3', 'WallpaperController');
@ -97,7 +97,7 @@ var WallpaperController = new Lang.Class({
this.imageSourceAdapter = this._desktopperAdapter;
break;
case 2:
this.imageSourceAdapter = this._wallheavenAdapter;
this.imageSourceAdapter = this._wallhavenAdapter;
break;
case 3:
this.imageSourceAdapter = this._genericJsonAdapter;
@ -223,9 +223,9 @@ var WallpaperController = new Lang.Class({
this._timer.begin(); // reset timer
this._requestRandomImageFromAdapter((historyElement) => {
this.logger.info("Requesting image: " + historyElement.source.imageUrl);
this.logger.info("Requesting image: " + historyElement.source.imageDownloadUrl);
this._fetchFile(historyElement.source.imageUrl, (historyId, path) => {
this._fetchFile(historyElement.source.imageDownloadUrl, (historyId, path) => {
historyElement.path = path;
historyElement.id = historyId;