Compare commits
173 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 41312f48f3 | |||
| d39c7f824b | |||
| 07b41c7407 | |||
| 0917f57dbd | |||
| 126bd19770 | |||
| 60fc9d7cfd | |||
| d75c63a8ce | |||
| 6d6d928733 | |||
| db41a691e6 | |||
| 2c5217e744 | |||
| 9a4bf4b9f8 | |||
| 571d80fa6b | |||
| 81439edf87 | |||
| e5f2d5c941 | |||
| b63549ae0a | |||
| c19c2cbd1d | |||
| 3bcd6af23c | |||
| a77fa3ae03 | |||
| 03b1936740 | |||
| b280d83234 | |||
| a4a01a6394 | |||
| de47b21a52 | |||
| 8dc71214aa | |||
| dec1bfdc7e | |||
| e17f0c622b | |||
| 88afb27a22 | |||
| f05eec6d53 | |||
| 68c4f6ccfe | |||
| ff92499406 | |||
| b49cc69c49 | |||
| 82aabc080a | |||
| 6afab6f421 | |||
| ed10ba1310 | |||
| 85b05a14bc | |||
| 668c73c8d2 | |||
| d6858b62a7 | |||
| 9bed643023 | |||
| 3f759bce2e | |||
| 00700c3211 | |||
| 8e21c80a33 | |||
| fda441bebd | |||
| 183191727b | |||
| 8fd52dd8a0 | |||
| 141f9ee32d | |||
| 5dee5cc52b | |||
| d157f3f244 | |||
| 813dda3579 | |||
| 8db0b16954 | |||
| 3339bb5ec8 | |||
| 3196988c98 | |||
| efbd570830 | |||
| 3f492b6160 | |||
| 4b804873a6 | |||
| 0bb19eae06 | |||
| f65d9b6231 | |||
| 3e0b62b109 | |||
| ea85197874 | |||
| cb649951ae | |||
| 3a0b18e51e | |||
| ab1306a7b8 | |||
| 0c5825afb8 | |||
| 11524e9f14 | |||
| 0a195f8a8f | |||
| 2c263f77db | |||
| 13c241f3b9 | |||
| f025ad4d2a | |||
| 4bb5610f7f | |||
| a48212cac7 | |||
|
|
dd958bbaa5 | ||
| 0dc523fe42 | |||
|
|
a920123a52 | ||
|
|
78a85f8e3f | ||
|
|
fcfcda84ae | ||
|
|
4f3a1a8261 | ||
|
|
75f94b46e7 | ||
|
|
3bc56e2e8f | ||
|
|
cc5398907f | ||
| cfec5fd9ed | |||
| c7153e070e | |||
| 5d053551d8 | |||
| eb40e97357 | |||
| 6e450b72f1 | |||
| cf94bfe488 | |||
| b87e224781 | |||
| 5b5d122a1c | |||
|
|
e3ba0540a5 | ||
| be009e51ac | |||
| 517a5c88d5 | |||
| 818ef06189 | |||
| b19e3dd06c | |||
| 11cde07393 | |||
| 99308a98c9 | |||
|
|
020fc6efe6 | ||
|
|
9a0e2e523a | ||
|
|
cca7f55760 | ||
|
|
2f554c5274 | ||
|
|
edb4f914ab | ||
|
|
342b1d6a3d | ||
|
|
c6c41c799f | ||
|
|
edc8eac2e7 | ||
|
|
1523a2ea2a | ||
|
|
77b4df463c | ||
|
|
9078c17ef0 | ||
|
|
edf0622be9 | ||
|
|
b94f1ced35 | ||
|
|
81bac3ec8d | ||
|
|
4d9cc5e142 | ||
|
|
5db62a607d | ||
|
|
8379ed09a5 | ||
|
|
2de7df0d21 | ||
|
|
1fe9ebedb5 | ||
|
|
4c54eb33d6 | ||
|
|
1d49e3a34c | ||
|
|
81a062296e | ||
|
|
873c8f32e8 | ||
|
|
e14a639d71 | ||
|
|
b6c0d89f1f | ||
|
|
b05b6e34a3 | ||
|
|
ebfcfda58e | ||
|
|
fad040badf | ||
|
|
6a52f0daa2 | ||
|
|
aef2b8eef3 | ||
|
|
288b4513c1 | ||
|
|
c8be783e03 | ||
|
|
1c89abbac3 | ||
|
|
57b3ba6422 | ||
|
|
b434594d3a | ||
|
|
f17dc19d3e | ||
|
|
8e033e2fc2 | ||
|
|
b456f588fc | ||
|
|
1f8e30489e | ||
|
|
5420d693d2 | ||
|
|
d02b713341 | ||
|
|
ba5f901a78 | ||
|
|
40aec194bd | ||
|
|
dd17ff43b2 | ||
|
|
aab094d152 | ||
|
|
15e305e658 | ||
|
|
41e762445f | ||
|
|
ddb54f398c | ||
|
|
74d5236408 | ||
|
|
9279db22f5 | ||
|
|
6ffdd51bf0 | ||
|
|
369144f03f | ||
|
|
f24fc3da3c | ||
|
|
c474db9a0c | ||
|
|
56ef57b112 | ||
|
|
8b132bf559 | ||
|
|
6968d8ed0e | ||
|
|
927474261e | ||
|
|
6c0bf60e07 | ||
|
|
58b8bdbd31 | ||
|
|
9c4799073b | ||
|
|
19e5a02d6e | ||
|
|
218f556a98 | ||
|
|
ee6ba89ab4 | ||
|
|
cc59671ff4 | ||
|
|
0405a8ba39 | ||
|
|
b24d2bef07 | ||
|
|
48d2646545 | ||
|
|
13893312d8 | ||
|
|
2efb4a4fb9 | ||
|
|
923d514dff | ||
|
|
6146758f59 | ||
|
|
7dbf05e2e1 | ||
|
|
5101a426c0 | ||
|
|
9cab3341b6 | ||
|
|
bd1a80af61 | ||
|
|
9bbc88eca7 | ||
|
|
307b8ffae0 | ||
|
|
87585b44ec | ||
|
|
da9216ce09 | ||
|
|
3ff4969946 |
46 changed files with 6768 additions and 10535 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,6 +1,3 @@
|
|||
build
|
||||
dist
|
||||
.DS_Store
|
||||
FeedTheMonkey.app
|
||||
FeedTheMonkey.egg-info/
|
||||
feedthemonkey.egg-info/
|
||||
target/
|
||||
data/gschemas.compiled
|
||||
|
|
|
|||
33
.travis.yml
Normal file
33
.travis.yml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
language: cpp
|
||||
compiler: gcc
|
||||
sudo: require
|
||||
dist: trusty
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y
|
||||
- sudo apt-get update -qq
|
||||
install:
|
||||
- sudo apt-get -y install qt58base qt58webengine qt58quickcontrols
|
||||
- source /opt/qt58/bin/qt58-env.sh
|
||||
script:
|
||||
- qmake PREFIX=/usr
|
||||
- make -j4
|
||||
- sudo make INSTALL_ROOT=appdir install ; sudo chown -R $USER appdir ; find appdir/
|
||||
- wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
|
||||
- chmod a+x linuxdeployqt*.AppImage
|
||||
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
|
||||
- "./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -qmldir=./qml/
|
||||
-bundle-non-qt-libs"
|
||||
- "./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -qmldir=./qml/
|
||||
-appimage"
|
||||
- find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " "
|
||||
-f 2-3 | sort | uniq
|
||||
- mv FeedTheMonkey*.AppImage FeedTheMonkey.AppImage
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: d+hHwOnmeLPVvuue6VDCs2LwLS+BFzJF/BB5iObtkCYBwQ8ybnVzUcgnjJKOt37SHI0T9kLegI+Lq/843ECYiGiDjQg4PvCF69V8ODgHv3v1qiN5oG/eroBXd83a0+xhi4BuJt0SwcV9mcv4uD9bCPhj944rmMLH+3qD4ysgImBmbYSbbLecE9+QAs7bfrCwQRfdCePBORX3FHa/p12NEtln7xv6ZRyku9LdJSzAcdgm4zc95ggTAVC1+aQB6J0q2QzWPlQcOkLx+ZYmOqClhbSMFpIyPXP8UpXjYyvUlTAd0+wH8BGf0O3lpOqACc7IKIbj9d5oPmghVZo55SyW+RR77G+az+IbGJ7iXZsMfQZsMvtB7hNYhNvUUxQrAau7Y/ve+6sMQmvA7aMHV8kDUvnNW/c2r2jAWwk+N8QzGcP/rclDCKeOWZqZABmrzTViXZVAeXh4hJ8r6mbq8iwagBUPCsVYhVuerQt/KIoWxyn6/1GmMfKGi3dA/v3u1qU61vzrz3yLlJBmUAVPxZdVmqfRweh4BXjImxFMFmf5PYm5FnDg1gmw8rWsgii7+IPYw7DjTAHpjYbtXvDwDgG1nRXiRp2TGtPPgKW1/Uk8r/j5vfB5WcEZ7exLUgsPPjny5MGvzjqOxeLvwK1Pg9jFBFXIx7l1tNMJQxQU0r3DmBg=
|
||||
file: FeedTheMonkey.AppImage
|
||||
on:
|
||||
repo: jeena/FeedTheMonkey
|
||||
skip_cleanup: true
|
||||
draft: true
|
||||
674
COPYING
Normal file
674
COPYING
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
2161
Cargo.lock
generated
Normal file
2161
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
23
Cargo.toml
Normal file
23
Cargo.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "feedthemonkey"
|
||||
version = "3.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "feedthemonkey"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
gtk4 = { version = "0.11", features = ["v4_14"] }
|
||||
libadwaita = { version = "0.9", features = ["v1_6"] }
|
||||
webkit6 = { version = "0.6" }
|
||||
gio = { version = "0.22" }
|
||||
glib = { version = "0.22" }
|
||||
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
|
||||
regex = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
libsecret = { version = "0.9", features = ["v0_19"] }
|
||||
|
||||
[build-dependencies]
|
||||
BIN
Icon.icns
BIN
Icon.icns
Binary file not shown.
30
LICENSE.txt
30
LICENSE.txt
|
|
@ -1,30 +0,0 @@
|
|||
BSD license
|
||||
===========
|
||||
|
||||
Copyright (c) 2013, Jeena Paradies
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
- Neither the name of Bungloo nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
111
README.md
111
README.md
|
|
@ -1,58 +1,101 @@
|
|||
<img align=right src="http://jabs.nu/feedthemonkey/feedthemonkey-icon.png" width='256' alt='Icon'>
|
||||
# FeedTheMonkey
|
||||
|
||||
# Feed the Monkey
|
||||
<img align="right" src="data/icons/net.jeena.FeedTheMonkey.png" width="256" alt="Icon">
|
||||
|
||||
Feed the Monkey is a desktop client for [TinyTinyRSS](http://tt-rss.org). That means that it doesn't work as a standalone feed reader but only as a client for the TinyTinyRSS API which it uses to get the normalized feeds and to synchronize the "article read" marks.
|
||||
FeedTheMonkey is a desktop client for any server that implements the
|
||||
[Greader API](https://github.com/theoldreader/api).
|
||||
|
||||
It is written in PyQt and uses WebKit to show the contents.
|
||||
It doesn't work as a standalone feed reader — it connects to a server to fetch articles and sync read state.
|
||||
|
||||
You need to have PyQt installed and a account on a TinyTinyRSS server.
|
||||
It follows the [river of news](http://scripting.com/2014/06/02/whatIsARiverOfNewsAggregator.html) philosophy: all unread articles appear in a single flat list and are automatically marked as read as you flip through them one by one.
|
||||
|
||||
License: BSD
|
||||
## Features
|
||||
|
||||
## Installation
|
||||
- **River of news**: all unread articles in one flat list, auto-marked as read as you flip through them one by one
|
||||
- **Offline reading**: article content and images are cached locally so you can read without a connection
|
||||
- **Image caching**: images are pre-fetched after each reload; can be disabled in preferences and is always skipped on metered connections
|
||||
- **Offline sync**: read/unread state changes made offline are queued and pushed to the server next time you're online
|
||||
- **Persistent state**: the article list, selected article, and scroll position are restored when you reopen the app
|
||||
- **Dark mode**: follows the system color scheme automatically
|
||||
- **Keyboard navigation**: vi-style shortcuts for hands-free reading
|
||||
- **Zoom**: adjustable content zoom, persisted across restarts
|
||||
- **Fullscreen** and toggleable sidebar
|
||||
|
||||
### Linux + Windows
|
||||
When logging in, enter:
|
||||
|
||||
Download the [ZIP](https://github.com/jeena/feedthemonkey/archive/master.zip)-file, unzip it and then run:
|
||||
- **FreshRSS**: `https://example.com/api/greader.php`
|
||||
- **Miniflux**: `https://example.com`
|
||||
- Other compatible servers: consult your server's documentation for the Greader API endpoint
|
||||
|
||||
On Linux you can just do (if you have PyQt4, python2 and python2-autotools already installed):
|
||||
`sudo python2 setup.py install`
|
||||
## Dependencies
|
||||
|
||||
On Windows you need to install (those are links to the binary packages):
|
||||
### Runtime
|
||||
|
||||
- [Python2 x32](http://www.python.org/ftp/python/2.7.4/python-2.7.4.msi) or [Python x64](http://www.python.org/ftp/python/2.7.4/python-2.7.4.amd64.msi)
|
||||
- [PyQt4 x32](http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.1/PyQt4-4.10.1-gpl-Py2.7-Qt4.8.4-x32.exe) or [PyQt x64](http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.1/PyQt4-4.10.1-gpl-Py2.7-Qt4.8.4-x64.exe)
|
||||
- GTK 4 (`gtk4`)
|
||||
- libadwaita (`libadwaita`)
|
||||
- WebKitGTK 6 (`webkitgtk-6.0`)
|
||||
- GLib / GIO (`glib-2.0`, `gio-2.0`)
|
||||
|
||||
Then rename `feedthemonkey` to `feedthemonkey.pyw` and then you can run it by double-clicking.
|
||||
On Arch Linux: `sudo pacman -S gtk4 libadwaita webkitgtk-6.0`
|
||||
|
||||
### OS X
|
||||
### Build
|
||||
|
||||
Download [FeedTheMonkey.app.zip](http://jabs.nu/feedthemonkey/download/FeedTheMonkey.app.zip) unzip it and move it to your Applications folder. After that just run it like every other app.
|
||||
- Rust toolchain (`rustup` / `cargo`)
|
||||
- `blueprint-compiler` — compiles `.blp` UI files to `.ui`
|
||||
- `glib-compile-schemas` — compiles GSettings schemas (part of `glib2`)
|
||||
- `glib-compile-resources` — compiles GResource bundles (part of `glib2`)
|
||||
|
||||
## Keyboard shortcuts
|
||||
On Arch Linux: `sudo pacman -S blueprint-compiler glib2`
|
||||
|
||||
The keyboard shortcuts are inspired by other feed readers which are inspired by the text editor vi.
|
||||
## Building
|
||||
|
||||
`j` or `→` show nex article
|
||||
`k` or `←` show previous article
|
||||
`n` or `Return` open current article in the default browser
|
||||
`r` reload articles
|
||||
`s` star current article
|
||||
`Ctrl S` show starred articles
|
||||
`Ctrl Q` quit
|
||||
`Ctrl +` zoom in
|
||||
`Ctrl -` zoom out
|
||||
`Ctrl 0` reset zoom
|
||||
```sh
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
On OS X use `Cmd` instead of `Ctrl`.
|
||||
The binary is at `target/release/feedthemonkey`.
|
||||
|
||||
## Installing
|
||||
|
||||
```sh
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
This installs the binary, icon, desktop entry, and GSettings schema to `/usr/local`.
|
||||
Set `PREFIX` to install elsewhere:
|
||||
|
||||
```sh
|
||||
sudo PREFIX=/usr ./install.sh
|
||||
```
|
||||
|
||||
## Trivia
|
||||
|
||||
I just hacked together this one within one day so it is not feature complete yet and has no real error handling.
|
||||
|
||||
Right now it only loads unread articles and shows them one after another. I might add a sidebar in the future, we will see.
|
||||
This is version 3 of FeedTheMonkey, rewritten in Rust with GTK4 and libadwaita.
|
||||
Version 2 was written in C++ with Qt and QML, and version 1 in PyQt — you can find
|
||||
them in the `v2` and `v1` branches of this repo.
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||

|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `j` or `→` | Next article |
|
||||
| `k` or `←` | Previous article |
|
||||
| `Return` | Open in browser |
|
||||
| `r` | Reload |
|
||||
| `F11` | Toggle fullscreen |
|
||||
| `Ctrl+W` | Quit |
|
||||
| `Ctrl++` | Zoom in |
|
||||
| `Ctrl+-` | Zoom out |
|
||||
| `Ctrl+0` | Reset zoom |
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015–2026 Jeena
|
||||
|
||||
FeedTheMonkey is free software: you can redistribute it and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software Foundation, either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
|
|
|||
17
build-osx.sh
17
build-osx.sh
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
HERE=`pwd`
|
||||
TMP="/tmp"
|
||||
|
||||
rm -rf FeedTheMonkey.app
|
||||
rm -rf $TMP/feedthemonkey
|
||||
mkdir $TMP/feedthemonkey
|
||||
cp Icon.icns $TMP/feedthemonkey/
|
||||
cp setup.py $TMP/feedthemonkey
|
||||
cp feedthemonkey $TMP/feedthemonkey/
|
||||
cd $TMP/feedthemonkey
|
||||
python setup.py py2app
|
||||
mv $TMP/feedthemonkey/dist/FeedTheMonkey.app $HERE
|
||||
cd $HERE
|
||||
rm -rf $TMP/feedthemonkey
|
||||
FeedTheMonkey.app/Contents/MacOS/FeedTheMonkey
|
||||
66
build.rs
Normal file
66
build.rs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let data_dir = manifest_dir.join("data");
|
||||
let ui_dir = data_dir.join("ui");
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
|
||||
// Compile all .blp files to .ui files
|
||||
let blp_files: Vec<_> = std::fs::read_dir(&ui_dir)
|
||||
.expect("data/ui/ directory not found")
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.path())
|
||||
.filter(|p| p.extension().map_or(false, |ext| ext == "blp"))
|
||||
.collect();
|
||||
|
||||
for blp in &blp_files {
|
||||
println!("cargo:rerun-if-changed={}", blp.display());
|
||||
}
|
||||
|
||||
if !blp_files.is_empty() {
|
||||
let status = Command::new("blueprint-compiler")
|
||||
.arg("batch-compile")
|
||||
.arg(&ui_dir)
|
||||
.arg(&ui_dir)
|
||||
.args(&blp_files)
|
||||
.status()
|
||||
.expect("failed to run blueprint-compiler — is it installed?");
|
||||
assert!(status.success(), "blueprint-compiler failed");
|
||||
}
|
||||
|
||||
// Compile GSettings schema into data/ so dev builds can find it
|
||||
let schema_file = data_dir.join("net.jeena.FeedTheMonkey.gschema.xml");
|
||||
println!("cargo:rerun-if-changed={}", schema_file.display());
|
||||
let status = Command::new("glib-compile-schemas")
|
||||
.arg(&data_dir)
|
||||
.status()
|
||||
.expect("failed to run glib-compile-schemas — is it installed?");
|
||||
assert!(status.success(), "glib-compile-schemas failed");
|
||||
println!("cargo:rustc-env=GSETTINGS_SCHEMA_DIR={}", data_dir.display());
|
||||
|
||||
// Compile GResource
|
||||
let gresource_xml = data_dir.join("resources.gresource.xml");
|
||||
println!("cargo:rerun-if-changed={}", gresource_xml.display());
|
||||
|
||||
// Watch HTML/CSS so changes trigger a resource rebuild
|
||||
let html_dir = manifest_dir.join("html");
|
||||
if let Ok(entries) = std::fs::read_dir(&html_dir) {
|
||||
for entry in entries.filter_map(|e| e.ok()) {
|
||||
println!("cargo:rerun-if-changed={}", entry.path().display());
|
||||
}
|
||||
}
|
||||
|
||||
let gresource_out = out_dir.join("feedthemonkey.gresource");
|
||||
let status = Command::new("glib-compile-resources")
|
||||
.arg(format!("--sourcedir={}", data_dir.display()))
|
||||
.arg(format!("--sourcedir={}", manifest_dir.display()))
|
||||
.arg(format!("--target={}", gresource_out.display()))
|
||||
.arg(&gresource_xml)
|
||||
.status()
|
||||
.expect("failed to run glib-compile-resources — is it installed?");
|
||||
assert!(status.success(), "glib-compile-resources failed");
|
||||
|
||||
println!("cargo:rustc-env=GRESOURCE_FILE={}", gresource_out.display());
|
||||
}
|
||||
BIN
data/icons/net.jeena.FeedTheMonkey.png
Normal file
BIN
data/icons/net.jeena.FeedTheMonkey.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
11
data/net.jeena.FeedTheMonkey.desktop
Normal file
11
data/net.jeena.FeedTheMonkey.desktop
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[Desktop Entry]
|
||||
Name=FeedTheMonkey
|
||||
GenericName=Feed Reader
|
||||
Comment=A desktop client for the Tiny Tiny RSS feed reader
|
||||
Exec=feedthemonkey
|
||||
Icon=net.jeena.FeedTheMonkey
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Network;News;GTK;
|
||||
StartupNotify=true
|
||||
StartupWMClass=feedthemonkey
|
||||
33
data/net.jeena.FeedTheMonkey.gschema.xml
Normal file
33
data/net.jeena.FeedTheMonkey.gschema.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
<schema id="net.jeena.FeedTheMonkey" path="/net/jeena/FeedTheMonkey/">
|
||||
<key name="window-width" type="i">
|
||||
<default>900</default>
|
||||
<summary>Window width</summary>
|
||||
</key>
|
||||
<key name="window-height" type="i">
|
||||
<default>600</default>
|
||||
<summary>Window height</summary>
|
||||
</key>
|
||||
<key name="window-maximized" type="b">
|
||||
<default>false</default>
|
||||
<summary>Window maximized state</summary>
|
||||
</key>
|
||||
<key name="sidebar-width" type="i">
|
||||
<default>280</default>
|
||||
<summary>Sidebar width in pixels</summary>
|
||||
</key>
|
||||
<key name="zoom-level" type="d">
|
||||
<default>1.0</default>
|
||||
<summary>WebView zoom level</summary>
|
||||
</key>
|
||||
<key name="content-filters" type="s">
|
||||
<default>''</default>
|
||||
<summary>Content rewrite rules, one per line: domain from to [from to …]</summary>
|
||||
</key>
|
||||
<key name="cache-images" type="b">
|
||||
<default>true</default>
|
||||
<summary>Download and cache article images for offline reading (skipped on metered connections)</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
12
data/resources.gresource.xml
Normal file
12
data/resources.gresource.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/net/jeena/FeedTheMonkey">
|
||||
<file preprocess="xml-stripblanks">ui/window.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/login_dialog.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/article_row.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/shortcuts.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/preferences_dialog.ui</file>
|
||||
<file>html/content.html</file>
|
||||
<file>html/content.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
BIN
data/screenshot.png
Normal file
BIN
data/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 473 KiB |
45
data/ui/article_row.blp
Normal file
45
data/ui/article_row.blp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $ArticleRow : Gtk.Box {
|
||||
orientation: vertical;
|
||||
margin-top: 12;
|
||||
margin-bottom: 12;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
spacing: 4;
|
||||
|
||||
Box {
|
||||
orientation: horizontal;
|
||||
spacing: 4;
|
||||
|
||||
Label feed_title_label {
|
||||
hexpand: true;
|
||||
xalign: 0;
|
||||
ellipsize: end;
|
||||
styles ["dim-label", "caption"]
|
||||
}
|
||||
|
||||
Label date_label {
|
||||
xalign: 1;
|
||||
styles ["dim-label", "caption"]
|
||||
}
|
||||
}
|
||||
|
||||
Label title_label {
|
||||
hexpand: true;
|
||||
xalign: 0;
|
||||
wrap: true;
|
||||
lines: 2;
|
||||
ellipsize: end;
|
||||
styles ["article-title"]
|
||||
}
|
||||
|
||||
Label excerpt_label {
|
||||
hexpand: true;
|
||||
xalign: 0;
|
||||
ellipsize: end;
|
||||
lines: 1;
|
||||
styles ["dim-label", "caption"]
|
||||
}
|
||||
}
|
||||
67
data/ui/article_row.ui
Normal file
67
data/ui/article_row.ui
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="ArticleRow" parent="GtkBox">
|
||||
<property name="orientation">1</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">0</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="feed_title_label">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">3</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
<class name="caption"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="date_label">
|
||||
<property name="xalign">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
<class name="caption"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="title_label">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">true</property>
|
||||
<property name="lines">2</property>
|
||||
<property name="ellipsize">3</property>
|
||||
<style>
|
||||
<class name="article-title"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="excerpt_label">
|
||||
<property name="hexpand">true</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">3</property>
|
||||
<property name="lines">1</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
<class name="caption"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
43
data/ui/login_dialog.blp
Normal file
43
data/ui/login_dialog.blp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $LoginDialog : Adw.Dialog {
|
||||
title: _("Log In");
|
||||
content-width: 360;
|
||||
|
||||
Adw.ToolbarView {
|
||||
[top]
|
||||
Adw.HeaderBar {}
|
||||
|
||||
Adw.Clamp {
|
||||
margin-top: 12;
|
||||
margin-bottom: 24;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
|
||||
Adw.PreferencesGroup {
|
||||
description: _("FreshRSS: https://example.com/api/greader.php\nMiniflux: https://example.com");
|
||||
|
||||
Adw.EntryRow server_url_row {
|
||||
title: _("Server URL");
|
||||
input-hints: no_spellcheck;
|
||||
input-purpose: url;
|
||||
}
|
||||
|
||||
Adw.EntryRow username_row {
|
||||
title: _("Username");
|
||||
input-hints: no_spellcheck;
|
||||
}
|
||||
|
||||
Adw.PasswordEntryRow password_row {
|
||||
title: _("Password");
|
||||
}
|
||||
|
||||
Adw.ButtonRow login_button {
|
||||
title: _("Log In");
|
||||
styles ["suggested-action"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
data/ui/login_dialog.ui
Normal file
60
data/ui/login_dialog.ui
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="LoginDialog" parent="AdwDialog">
|
||||
<property name="title" translatable="yes">Log In</property>
|
||||
<property name="content-width">360</property>
|
||||
<child>
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar"></object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwClamp">
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">24</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="description" translatable="yes">FreshRSS: https://example.com/api/greader.php
|
||||
Miniflux: https://example.com</property>
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="server_url_row">
|
||||
<property name="title" translatable="yes">Server URL</property>
|
||||
<property name="input-hints">2</property>
|
||||
<property name="input-purpose">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwEntryRow" id="username_row">
|
||||
<property name="title" translatable="yes">Username</property>
|
||||
<property name="input-hints">2</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwPasswordEntryRow" id="password_row">
|
||||
<property name="title" translatable="yes">Password</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwButtonRow" id="login_button">
|
||||
<property name="title" translatable="yes">Log In</property>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
38
data/ui/preferences_dialog.blp
Normal file
38
data/ui/preferences_dialog.blp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $PreferencesDialog : Adw.Dialog {
|
||||
title: _("Preferences");
|
||||
content-width: 500;
|
||||
content-height: 400;
|
||||
|
||||
Adw.ToolbarView {
|
||||
[top]
|
||||
Adw.HeaderBar {}
|
||||
|
||||
Adw.PreferencesPage {
|
||||
Adw.PreferencesGroup {
|
||||
title: _("Images");
|
||||
|
||||
Adw.SwitchRow cache_images_row {
|
||||
title: _("Cache Images");
|
||||
subtitle: _("Download images for offline reading (skipped on metered connections)");
|
||||
}
|
||||
}
|
||||
|
||||
Adw.PreferencesGroup {
|
||||
title: _("Content Filters");
|
||||
description: _("One rule per line: domain find replace [find replace …]\n\nExample:\n www.imycomic.com -150x150.jpg .jpg");
|
||||
|
||||
TextView filters_text_view {
|
||||
monospace: true;
|
||||
wrap-mode: word;
|
||||
top-margin: 8;
|
||||
bottom-margin: 8;
|
||||
left-margin: 8;
|
||||
right-margin: 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
data/ui/preferences_dialog.ui
Normal file
55
data/ui/preferences_dialog.ui
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="PreferencesDialog" parent="AdwDialog">
|
||||
<property name="title" translatable="yes">Preferences</property>
|
||||
<property name="content-width">500</property>
|
||||
<property name="content-height">400</property>
|
||||
<child>
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar"></object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwPreferencesPage">
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="title" translatable="yes">Images</property>
|
||||
<child>
|
||||
<object class="AdwSwitchRow" id="cache_images_row">
|
||||
<property name="title" translatable="yes">Cache Images</property>
|
||||
<property name="subtitle" translatable="yes">Download images for offline reading (skipped on metered connections)</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup">
|
||||
<property name="title" translatable="yes">Content Filters</property>
|
||||
<property name="description" translatable="yes">One rule per line: domain find replace [find replace …]
|
||||
|
||||
Example:
|
||||
www.imycomic.com -150x150.jpg .jpg</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="filters_text_view">
|
||||
<property name="monospace">true</property>
|
||||
<property name="wrap-mode">2</property>
|
||||
<property name="top-margin">8</property>
|
||||
<property name="bottom-margin">8</property>
|
||||
<property name="left-margin">8</property>
|
||||
<property name="right-margin">8</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
112
data/ui/shortcuts.blp
Normal file
112
data/ui/shortcuts.blp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
ShortcutsWindow help_overlay {
|
||||
modal: true;
|
||||
|
||||
ShortcutsSection {
|
||||
section-name: "shortcuts";
|
||||
max-height: 10;
|
||||
|
||||
ShortcutsGroup {
|
||||
title: _("Navigation");
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Next article");
|
||||
accelerator: "j Right";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Previous article");
|
||||
accelerator: "k Left";
|
||||
}
|
||||
}
|
||||
|
||||
ShortcutsGroup {
|
||||
title: _("Article");
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Open in browser");
|
||||
accelerator: "Return n";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Mark as unread");
|
||||
accelerator: "u";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Reload articles");
|
||||
accelerator: "r";
|
||||
}
|
||||
}
|
||||
|
||||
ShortcutsGroup {
|
||||
title: _("View");
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Scroll down");
|
||||
accelerator: "space Page_Down";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Scroll up");
|
||||
accelerator: "Page_Up";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Scroll to top");
|
||||
accelerator: "Home";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Scroll to bottom");
|
||||
accelerator: "End";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Zoom in");
|
||||
accelerator: "<Control>plus";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Zoom out");
|
||||
accelerator: "<Control>minus";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Reset zoom");
|
||||
accelerator: "<Control>0";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Toggle sidebar");
|
||||
accelerator: "F9";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Toggle fullscreen");
|
||||
accelerator: "F11";
|
||||
}
|
||||
}
|
||||
|
||||
ShortcutsGroup {
|
||||
title: _("Application");
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Keyboard shortcuts");
|
||||
accelerator: "F1";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Close window");
|
||||
accelerator: "<Control>w";
|
||||
}
|
||||
|
||||
ShortcutsShortcut {
|
||||
title: _("Quit");
|
||||
accelerator: "<Control>q";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
140
data/ui/shortcuts.ui
Normal file
140
data/ui/shortcuts.ui
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkShortcutsWindow" id="help_overlay">
|
||||
<property name="modal">true</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsSection">
|
||||
<property name="section-name">shortcuts</property>
|
||||
<property name="max-height">10</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Navigation</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Next article</property>
|
||||
<property name="accelerator">j Right</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Previous article</property>
|
||||
<property name="accelerator">k Left</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Article</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Open in browser</property>
|
||||
<property name="accelerator">Return n</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Mark as unread</property>
|
||||
<property name="accelerator">u</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Reload articles</property>
|
||||
<property name="accelerator">r</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">View</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Scroll down</property>
|
||||
<property name="accelerator">space Page_Down</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Scroll up</property>
|
||||
<property name="accelerator">Page_Up</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Scroll to top</property>
|
||||
<property name="accelerator">Home</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Scroll to bottom</property>
|
||||
<property name="accelerator">End</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Zoom in</property>
|
||||
<property name="accelerator"><Control>plus</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Zoom out</property>
|
||||
<property name="accelerator"><Control>minus</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Reset zoom</property>
|
||||
<property name="accelerator"><Control>0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Toggle sidebar</property>
|
||||
<property name="accelerator">F9</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Toggle fullscreen</property>
|
||||
<property name="accelerator">F11</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Application</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Keyboard shortcuts</property>
|
||||
<property name="accelerator">F1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Close window</property>
|
||||
<property name="accelerator"><Control>w</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes">Quit</property>
|
||||
<property name="accelerator"><Control>q</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
221
data/ui/window.blp
Normal file
221
data/ui/window.blp
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
using WebKit 6.0;
|
||||
|
||||
template $FeedTheMonkeyWindow : Adw.ApplicationWindow {
|
||||
default-width: 900;
|
||||
default-height: 600;
|
||||
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Paned paned {
|
||||
focusable: false;
|
||||
resize-start-child: false;
|
||||
shrink-end-child: false;
|
||||
|
||||
start-child: Adw.ToolbarView sidebar_toolbar {
|
||||
top-bar-style: raised;
|
||||
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
show-start-title-buttons: false;
|
||||
show-end-title-buttons: false;
|
||||
|
||||
title-widget: Box {};
|
||||
|
||||
[start]
|
||||
Stack refresh_stack {
|
||||
StackPage {
|
||||
name: "button";
|
||||
child: Button refresh_button {
|
||||
icon-name: "view-refresh-symbolic";
|
||||
tooltip-text: _("Refresh");
|
||||
action-name: "win.reload";
|
||||
};
|
||||
}
|
||||
StackPage {
|
||||
name: "spinner";
|
||||
child: Spinner {
|
||||
spinning: true;
|
||||
width-request: 16;
|
||||
height-request: 16;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[end]
|
||||
MenuButton menu_button {
|
||||
icon-name: "open-menu-symbolic";
|
||||
primary: true;
|
||||
menu-model: primary_menu;
|
||||
}
|
||||
}
|
||||
|
||||
Stack sidebar_content {
|
||||
styles ["sidebar-content"]
|
||||
|
||||
StackPage {
|
||||
name: "placeholder";
|
||||
child: Adw.StatusPage {
|
||||
icon-name: "rss-symbolic";
|
||||
title: _("FeedTheMonkey");
|
||||
description: _("Log in to load your articles");
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "loading";
|
||||
child: Adw.StatusPage {
|
||||
title: _("Loading…");
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "empty";
|
||||
child: Adw.StatusPage {
|
||||
icon-name: "rss-symbolic";
|
||||
title: _("No Unread Articles");
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "error";
|
||||
child: Adw.StatusPage error_status {
|
||||
icon-name: "network-error-symbolic";
|
||||
title: _("Could Not Load Articles");
|
||||
|
||||
Button {
|
||||
label: _("Try Again");
|
||||
halign: center;
|
||||
action-name: "win.reload";
|
||||
styles ["pill", "suggested-action"]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "list";
|
||||
child: ScrolledWindow {
|
||||
hscrollbar-policy: never;
|
||||
ListView article_list_view {
|
||||
single-click-activate: false;
|
||||
show-separators: true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
end-child: Adw.ToolbarView {
|
||||
top-bar-style: raised;
|
||||
width-request: 320;
|
||||
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
[start]
|
||||
Button toggle_sidebar_button {
|
||||
icon-name: "sidebar-show-symbolic";
|
||||
tooltip-text: _("Toggle Sidebar");
|
||||
action-name: "win.toggle-sidebar";
|
||||
}
|
||||
|
||||
[start]
|
||||
Stack content_refresh_stack {
|
||||
visible: false;
|
||||
StackPage {
|
||||
name: "button";
|
||||
child: Button {
|
||||
icon-name: "view-refresh-symbolic";
|
||||
tooltip-text: _("Refresh");
|
||||
action-name: "win.reload";
|
||||
};
|
||||
}
|
||||
StackPage {
|
||||
name: "spinner";
|
||||
child: Spinner {
|
||||
spinning: true;
|
||||
width-request: 16;
|
||||
height-request: 16;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
title-widget: Adw.WindowTitle {
|
||||
title: _("FeedTheMonkey");
|
||||
};
|
||||
|
||||
[end]
|
||||
MenuButton content_menu_button {
|
||||
icon-name: "open-menu-symbolic";
|
||||
primary: true;
|
||||
menu-model: primary_menu;
|
||||
visible: false;
|
||||
}
|
||||
|
||||
[end]
|
||||
MenuButton article_menu_button {
|
||||
icon-name: "view-more-symbolic";
|
||||
menu-model: article_menu;
|
||||
visible: false;
|
||||
}
|
||||
}
|
||||
|
||||
Stack content_stack {
|
||||
StackPage {
|
||||
name: "empty";
|
||||
child: Adw.StatusPage {
|
||||
icon-name: "document-open-symbolic";
|
||||
title: _("No Article Selected");
|
||||
};
|
||||
}
|
||||
|
||||
StackPage {
|
||||
name: "webview";
|
||||
child: WebKit.WebView web_view {};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu primary_menu {
|
||||
section {
|
||||
item {
|
||||
label: _("Log Out");
|
||||
action: "win.logout";
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
item {
|
||||
label: _("Preferences");
|
||||
action: "win.preferences";
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
item {
|
||||
label: _("Keyboard Shortcuts");
|
||||
action: "win.show-help-overlay";
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("About FeedTheMonkey");
|
||||
action: "app.about";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu article_menu {
|
||||
section {
|
||||
item {
|
||||
label: _("Mark Unread");
|
||||
action: "win.mark-unread";
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("Open in Browser");
|
||||
action: "win.open-in-browser";
|
||||
}
|
||||
}
|
||||
}
|
||||
276
data/ui/window.ui
Normal file
276
data/ui/window.ui
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="FeedTheMonkeyWindow" parent="AdwApplicationWindow">
|
||||
<property name="default-width">900</property>
|
||||
<property name="default-height">600</property>
|
||||
<child>
|
||||
<object class="AdwToastOverlay" id="toast_overlay">
|
||||
<child>
|
||||
<object class="GtkPaned" id="paned">
|
||||
<property name="focusable">false</property>
|
||||
<property name="resize-start-child">false</property>
|
||||
<property name="shrink-end-child">false</property>
|
||||
<property name="start-child">
|
||||
<object class="AdwToolbarView" id="sidebar_toolbar">
|
||||
<property name="top-bar-style">1</property>
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-start-title-buttons">false</property>
|
||||
<property name="show-end-title-buttons">false</property>
|
||||
<property name="title-widget">
|
||||
<object class="GtkBox"></object>
|
||||
</property>
|
||||
<child type="start">
|
||||
<object class="GtkStack" id="refresh_stack">
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">button</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton" id="refresh_button">
|
||||
<property name="icon-name">view-refresh-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Refresh</property>
|
||||
<property name="action-name">win.reload</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">spinner</property>
|
||||
<property name="child">
|
||||
<object class="GtkSpinner">
|
||||
<property name="spinning">true</property>
|
||||
<property name="width-request">16</property>
|
||||
<property name="height-request">16</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="menu_button">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="primary">true</property>
|
||||
<property name="menu-model">primary_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="sidebar_content">
|
||||
<style>
|
||||
<class name="sidebar-content"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">placeholder</property>
|
||||
<property name="child">
|
||||
<object class="AdwStatusPage">
|
||||
<property name="icon-name">rss-symbolic</property>
|
||||
<property name="title" translatable="yes">FeedTheMonkey</property>
|
||||
<property name="description" translatable="yes">Log in to load your articles</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">loading</property>
|
||||
<property name="child">
|
||||
<object class="AdwStatusPage">
|
||||
<property name="title" translatable="yes">Loading…</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">empty</property>
|
||||
<property name="child">
|
||||
<object class="AdwStatusPage">
|
||||
<property name="icon-name">rss-symbolic</property>
|
||||
<property name="title" translatable="yes">No Unread Articles</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">error</property>
|
||||
<property name="child">
|
||||
<object class="AdwStatusPage" id="error_status">
|
||||
<property name="icon-name">network-error-symbolic</property>
|
||||
<property name="title" translatable="yes">Could Not Load Articles</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Try Again</property>
|
||||
<property name="halign">3</property>
|
||||
<property name="action-name">win.reload</property>
|
||||
<style>
|
||||
<class name="pill"/>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">list</property>
|
||||
<property name="child">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">2</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="article_list_view">
|
||||
<property name="single-click-activate">false</property>
|
||||
<property name="show-separators">true</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
<property name="end-child">
|
||||
<object class="AdwToolbarView">
|
||||
<property name="top-bar-style">1</property>
|
||||
<property name="width-request">320</property>
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="toggle_sidebar_button">
|
||||
<property name="icon-name">sidebar-show-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Toggle Sidebar</property>
|
||||
<property name="action-name">win.toggle-sidebar</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="start">
|
||||
<object class="GtkStack" id="content_refresh_stack">
|
||||
<property name="visible">false</property>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">button</property>
|
||||
<property name="child">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">view-refresh-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Refresh</property>
|
||||
<property name="action-name">win.reload</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">spinner</property>
|
||||
<property name="child">
|
||||
<object class="GtkSpinner">
|
||||
<property name="spinning">true</property>
|
||||
<property name="width-request">16</property>
|
||||
<property name="height-request">16</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle">
|
||||
<property name="title" translatable="yes">FeedTheMonkey</property>
|
||||
</object>
|
||||
</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="content_menu_button">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="primary">true</property>
|
||||
<property name="menu-model">primary_menu</property>
|
||||
<property name="visible">false</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="article_menu_button">
|
||||
<property name="icon-name">view-more-symbolic</property>
|
||||
<property name="menu-model">article_menu</property>
|
||||
<property name="visible">false</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="content_stack">
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">empty</property>
|
||||
<property name="child">
|
||||
<object class="AdwStatusPage">
|
||||
<property name="icon-name">document-open-symbolic</property>
|
||||
<property name="title" translatable="yes">No Article Selected</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">webview</property>
|
||||
<property name="child">
|
||||
<object class="WebKitWebView" id="web_view"></object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<menu id="primary_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Log Out</attribute>
|
||||
<attribute name="action">win.logout</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Preferences</attribute>
|
||||
<attribute name="action">win.preferences</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">About FeedTheMonkey</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="article_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Mark Unread</attribute>
|
||||
<attribute name="action">win.mark-unread</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Open in Browser</attribute>
|
||||
<attribute name="action">win.open-in-browser</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
570
feedthemonkey
570
feedthemonkey
|
|
@ -1,570 +0,0 @@
|
|||
#!/usr/bin/env python2
|
||||
|
||||
try:
|
||||
import urllib.request as urllib2
|
||||
except:
|
||||
import urllib2
|
||||
|
||||
import sys, os, json, tempfile, urllib, json
|
||||
from PyQt4 import QtGui, QtCore, QtWebKit, QtNetwork
|
||||
from PyQt4.QtNetwork import *
|
||||
from threading import Thread
|
||||
from sys import platform as _platform
|
||||
|
||||
settings = QtCore.QSettings("jabs.nu", "feedthemonkey")
|
||||
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
def __init__(self):
|
||||
QtGui.QMainWindow.__init__(self)
|
||||
self.setWindowIcon(QtGui.QIcon("feedmonkey"))
|
||||
self.addAction(QtGui.QAction("Full Screen", self, checkable=True, toggled=lambda v: self.showFullScreen() if v else self.showNormal(), shortcut="F11"))
|
||||
self.history = self.get("history", [])
|
||||
self.restoreGeometry(QtCore.QByteArray.fromRawData(settings.value("geometry").toByteArray()))
|
||||
self.restoreState(QtCore.QByteArray.fromRawData(settings.value("state").toByteArray()))
|
||||
|
||||
self.initUI()
|
||||
|
||||
session_id = self.get("session_id")
|
||||
server_url = self.get("server_url")
|
||||
|
||||
if not (session_id and server_url):
|
||||
self.authenticate()
|
||||
else:
|
||||
self.initApp()
|
||||
|
||||
def initUI(self):
|
||||
self.list = List(self)
|
||||
self.content = Content(self)
|
||||
|
||||
self.splitter = QtGui.QSplitter(QtCore.Qt.Vertical, self)
|
||||
self.splitter.setHandleWidth(1)
|
||||
self.splitter.addWidget(self.list)
|
||||
self.splitter.addWidget(self.content)
|
||||
self.splitter.restoreState(settings.value("splitterSizes").toByteArray());
|
||||
self.splitter.splitterMoved.connect(self.splitterMoved)
|
||||
|
||||
self.setCentralWidget(self.splitter)
|
||||
|
||||
def mkAction(name, connect, shortcut=None):
|
||||
action = QtGui.QAction(name, self)
|
||||
action.triggered.connect(connect)
|
||||
if shortcut:
|
||||
action.setShortcut(shortcut)
|
||||
return action
|
||||
|
||||
mb = self.menuBar()
|
||||
|
||||
fileMenu = mb.addMenu("&File")
|
||||
fileMenu.addAction(mkAction("&Close", self.close, "Ctrl+W"))
|
||||
fileMenu.addAction(mkAction("&Log Out", self.logOut))
|
||||
fileMenu.addSeparator()
|
||||
fileMenu.addAction(mkAction("&Exit", self.close, "Ctrl+Q"))
|
||||
|
||||
actionMenu = mb.addMenu("&Action")
|
||||
actionMenu.addAction(mkAction("&Reload", self.content.reload, "R"))
|
||||
actionMenu.addAction(mkAction("Show &Starred", self.content.showStarred, "Ctrl+S"))
|
||||
actionMenu.addAction(mkAction("Set &Starred", self.content.setStarred, "S"))
|
||||
actionMenu.addAction(mkAction("Set &Unread", self.content.setUnread, "U"))
|
||||
actionMenu.addAction(mkAction("&Next", self.content.showNext, "J"))
|
||||
actionMenu.addAction(mkAction("&Previous", self.content.showPrevious, "K"))
|
||||
actionMenu.addAction(mkAction("&Open in Browser", self.content.openCurrent, "N"))
|
||||
|
||||
viewMenu = mb.addMenu("&View")
|
||||
viewMenu.addAction(mkAction("Zoom &In", lambda: self.content.wb.setZoomFactor(self.content.wb.zoomFactor() + 0.2), "Ctrl++"))
|
||||
viewMenu.addAction(mkAction("Zoom &Out", lambda: self.content.wb.setZoomFactor(self.content.wb.zoomFactor() - 0.2), "Ctrl+-"))
|
||||
viewMenu.addAction(mkAction("&Reset", lambda: self.content.wb.setZoomFactor(1), "Ctrl+0"))
|
||||
|
||||
windowMenu = mb.addMenu("&Window")
|
||||
windowMenu.addAction(mkAction("Reset to Default", self.resetSplitter, "Ctrl+D"))
|
||||
|
||||
helpMenu = mb.addMenu("&Help")
|
||||
helpMenu.addAction(mkAction("&About", lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://jabs.nu/feedthemonkey", QtCore.QUrl.TolerantMode)) ))
|
||||
|
||||
def initApp(self):
|
||||
session_id = self.get("session_id")
|
||||
server_url = self.get("server_url")
|
||||
self.tinyTinyRSS = TinyTinyRSS(self, server_url, session_id)
|
||||
|
||||
self.content.evaluateJavaScript("setArticle('loading')")
|
||||
self.content.reload()
|
||||
self.show()
|
||||
|
||||
def closeEvent(self, ev):
|
||||
settings.setValue("geometry", self.saveGeometry())
|
||||
settings.setValue("state", self.saveState())
|
||||
return QtGui.QMainWindow.closeEvent(self, ev)
|
||||
|
||||
def put(self, key, value):
|
||||
"Persist an object somewhere under a given key"
|
||||
settings.setValue(key, json.dumps(value))
|
||||
settings.sync()
|
||||
|
||||
def get(self, key, default=None):
|
||||
"Get the object stored under 'key' in persistent storage, or the default value"
|
||||
v = settings.value(key)
|
||||
return json.loads(unicode(v.toString())) if v.isValid() else default
|
||||
|
||||
def setWindowTitle(self, t):
|
||||
super(QtGui.QMainWindow, self).setWindowTitle("Feed the Monkey" + t)
|
||||
|
||||
def splitterMoved(self, pos, index):
|
||||
settings.setValue("splitterSizes", self.splitter.saveState());
|
||||
|
||||
def resetSplitter(self):
|
||||
sizes = self.splitter.sizes()
|
||||
top = sizes[0]
|
||||
bottom = sizes[1]
|
||||
sizes[0] = 200
|
||||
sizes[1] = bottom + top - 200
|
||||
self.splitter.setSizes(sizes)
|
||||
|
||||
def authenticate(self):
|
||||
|
||||
dialog = Login()
|
||||
|
||||
def callback():
|
||||
|
||||
server_url = str(dialog.textServerUrl.text())
|
||||
user = str(dialog.textName.text())
|
||||
password = str(dialog.textPass.text())
|
||||
|
||||
session_id = TinyTinyRSS.login(server_url, user, password)
|
||||
if session_id:
|
||||
self.put("session_id", session_id)
|
||||
self.put("server_url", server_url)
|
||||
self.initApp()
|
||||
else:
|
||||
self.authenticate()
|
||||
|
||||
dialog.accepted.connect(callback)
|
||||
|
||||
dialog.exec_()
|
||||
|
||||
def logOut(self):
|
||||
self.hide()
|
||||
self.content.evaluateJavaScript("setArticle('logout')")
|
||||
self.tinyTinyRSS.logOut()
|
||||
self.tinyTinyRSS = None
|
||||
self.put("session_id", None)
|
||||
self.put("server_url", None)
|
||||
self.authenticate()
|
||||
|
||||
class List(QtGui.QTableWidget):
|
||||
def __init__(self, container):
|
||||
QtGui.QTableWidget.__init__(self)
|
||||
self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.app = container
|
||||
self.itemSelectionChanged.connect(self.rowSelected)
|
||||
self.setShowGrid(False)
|
||||
self.setAlternatingRowColors(True)
|
||||
|
||||
def initHeader(self):
|
||||
self.clear()
|
||||
self.setColumnCount(5)
|
||||
self.setHorizontalHeaderLabels(("*", "Feed", "Title", "Date", "Author"))
|
||||
self.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
|
||||
self.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.ResizeToContents)
|
||||
self.horizontalHeader().setResizeMode(2, QtGui.QHeaderView.Stretch)
|
||||
self.horizontalHeader().setResizeMode(3, QtGui.QHeaderView.ResizeToContents)
|
||||
self.horizontalHeader().setResizeMode(4, QtGui.QHeaderView.ResizeToContents)
|
||||
self.verticalHeader().hide()
|
||||
|
||||
def setItems(self, articles):
|
||||
self.initHeader()
|
||||
self.setRowCount(len(articles))
|
||||
row = 0
|
||||
for article in articles:
|
||||
if "marked" in article:
|
||||
starred = QtGui.QTableWidgetItem("*" if article["marked"] else "")
|
||||
starred.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setItem(row, 0, starred)
|
||||
if "feed_title" in article:
|
||||
feed_title = QtGui.QTableWidgetItem(article["feed_title"])
|
||||
feed_title.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setItem(row, 1, feed_title)
|
||||
if "title" in article:
|
||||
title = QtGui.QTableWidgetItem(article["title"])
|
||||
title.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setItem(row, 2, title)
|
||||
if "updated" in article:
|
||||
date = QtCore.QDateTime.fromTime_t(article["updated"]).toString(QtCore.Qt.SystemLocaleShortDate)
|
||||
d = QtGui.QTableWidgetItem(date)
|
||||
d.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setItem(row, 3, d)
|
||||
if "author" in article:
|
||||
author = QtGui.QTableWidgetItem(article["author"])
|
||||
author.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.setItem(row, 4, author)
|
||||
self.resizeRowToContents(row)
|
||||
row += 1
|
||||
self.selectRow(0)
|
||||
|
||||
def rowSelected(self):
|
||||
indexes = self.selectedIndexes()
|
||||
if len(indexes) > 0:
|
||||
row = indexes[0].row()
|
||||
self.app.content.showIndex(row)
|
||||
|
||||
def updateRead(self):
|
||||
for row, article in enumerate(self.app.content.unread_articles):
|
||||
for x in xrange(0,5):
|
||||
item = self.item(row, x)
|
||||
font = item.font()
|
||||
font.setBold(article["unread"])
|
||||
item.setFont(font)
|
||||
|
||||
def setStarred(self, index, starred):
|
||||
widget = self.itemAt(index, 0)
|
||||
widget.setText("*" if starred else "")
|
||||
|
||||
|
||||
class Content(QtGui.QWidget):
|
||||
def __init__(self, container):
|
||||
QtGui.QWidget.__init__(self)
|
||||
|
||||
self.app = container
|
||||
self.index = 0
|
||||
|
||||
self.wb = QtWebKit.QWebView(titleChanged=lambda t: container.setWindowTitle(t))
|
||||
self.wb.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
|
||||
self.wb.linkClicked.connect(lambda url: self.openLink(url))
|
||||
|
||||
diskCache = QNetworkDiskCache()
|
||||
diskCache.setCacheDirectory("/tmp/feedmonkey")
|
||||
diskCache.setMaximumCacheSize(5*124*124)
|
||||
self.wb.page().networkAccessManager().setCache(diskCache)
|
||||
|
||||
self.setLayout(QtGui.QVBoxLayout(spacing=0))
|
||||
self.layout().setContentsMargins(0, 0, 0, 0)
|
||||
self.layout().addWidget(self.wb)
|
||||
|
||||
self.do_show_next = QtGui.QShortcut(QtCore.Qt.Key_Right, self, activated=self.showNext)
|
||||
self.do_show_previous = QtGui.QShortcut(QtCore.Qt.Key_Left, self, activated=self.showPrevious)
|
||||
self.do_open = QtGui.QShortcut("Return", self, activated=self.openCurrent)
|
||||
|
||||
self.wb.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
|
||||
self.wb.settings().setIconDatabasePath(tempfile.mkdtemp())
|
||||
self.wb.setHtml(self.templateString())
|
||||
|
||||
self.unread_articles = []
|
||||
|
||||
def openLink(self, url):
|
||||
QtGui.QDesktopServices.openUrl(url)
|
||||
|
||||
def reload(self):
|
||||
w = WorkerThread(self.app, self._reload)
|
||||
self.connect(w, QtCore.SIGNAL("reload_done()"), self.reload_done)
|
||||
w.start()
|
||||
|
||||
def showStarred(self):
|
||||
w = WorkerThread(self.app, self._showStarred)
|
||||
self.connect(w, QtCore.SIGNAL("reload_done()"), self.reload_done)
|
||||
w.start()
|
||||
|
||||
def setUnread(self):
|
||||
article = self.unread_articles[self.index]
|
||||
article["unread"] = True
|
||||
article["set_unread"] = True
|
||||
self.app.list.updateRead()
|
||||
self.app.tinyTinyRSS.setArticleRead(article["id"], False)
|
||||
|
||||
def setStarred(self):
|
||||
article = self.unread_articles[self.index]
|
||||
article["marked"] = not article["marked"]
|
||||
self.app.tinyTinyRSS.setArticleStarred(article["id"], article["marked"])
|
||||
self.app.list.setStarred(self.index, article["marked"])
|
||||
self.setArticle(article)
|
||||
|
||||
def _reload(self):
|
||||
self.unread_articles = self.app.tinyTinyRSS.getUnreadFeeds()
|
||||
self.index = -1
|
||||
|
||||
def _showStarred(self):
|
||||
self.unread_articles = self.app.tinyTinyRSS.getStarredFeeds()
|
||||
self.index = -1
|
||||
|
||||
def reload_done(self):
|
||||
self.setUnreadCount()
|
||||
self.app.list.setItems(self.unread_articles)
|
||||
|
||||
def showIndex(self, index):
|
||||
if self.index > -1:
|
||||
previous = self.unread_articles[self.index]
|
||||
if not "set_unread" in previous or not previous["set_unread"]:
|
||||
self.app.tinyTinyRSS.setArticleRead(previous["id"])
|
||||
previous["unread"] = False
|
||||
else:
|
||||
previous["set_unread"] = False
|
||||
|
||||
self.app.list.updateRead()
|
||||
|
||||
self.index = index
|
||||
current = self.unread_articles[self.index]
|
||||
self.setArticle(current)
|
||||
self.setUnreadCount()
|
||||
|
||||
def showNext(self):
|
||||
if self.index + 1 < len(self.unread_articles):
|
||||
self.app.list.selectRow(self.index + 1)
|
||||
|
||||
def showPrevious(self):
|
||||
if self.index > 0:
|
||||
self.app.list.selectRow(self.index - 1)
|
||||
|
||||
def openCurrent(self):
|
||||
current = self.unread_articles[self.index]
|
||||
url = QtCore.QUrl(current["link"])
|
||||
self.openLink(url)
|
||||
|
||||
def setArticle(self, article):
|
||||
func = u"setArticle({});".format(json.dumps(article))
|
||||
self.evaluateJavaScript(func)
|
||||
|
||||
def evaluateJavaScript(self, func):
|
||||
return self.wb.page().mainFrame().evaluateJavaScript(func)
|
||||
|
||||
def setUnreadCount(self):
|
||||
length = len(self.unread_articles)
|
||||
i = 0
|
||||
if self.index > 0:
|
||||
i = self.index
|
||||
unread = length - i
|
||||
|
||||
self.app.setWindowTitle(" (" + str(unread) + "/" + str(length) + ")")
|
||||
if unread < 1:
|
||||
self.evaluateJavaScript("setArticle('empty')")
|
||||
|
||||
def templateString(self):
|
||||
html="""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ttrssl</title>
|
||||
<script type="text/javascript">
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function setArticle(article) {
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
$("date").innerHTML = "";
|
||||
$("title").innerHTML = "";
|
||||
$("title").href = "";
|
||||
$("title").title = "";
|
||||
$("feed_title").innerHTML = "";
|
||||
$("author").innerHTML = "";
|
||||
$("article").innerHTML = "";
|
||||
|
||||
if(article == "empty") {
|
||||
|
||||
$("article").innerHTML = "No unread articles to display.";
|
||||
|
||||
} else if(article == "loading") {
|
||||
|
||||
$("article").innerHTML = "Loading <blink>…</blink>";
|
||||
|
||||
} else if (article == "logout") {
|
||||
|
||||
} else if(article) {
|
||||
|
||||
$("date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000));
|
||||
$("title").innerHTML = article.title;
|
||||
$("title").href = article.link;
|
||||
$("title").title = article.link;
|
||||
$("feed_title").innerHTML = article.feed_title;
|
||||
$("title").className = article.marked ? "starred" : "";
|
||||
$("author").innerHTML = "";
|
||||
if(article.author && article.author.length > 0)
|
||||
$("author").innerHTML = "– " + article.author
|
||||
$("article").innerHTML = article.content;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: "Ubuntu", "Lucida Grande", "Tahoma", sans-serif;
|
||||
padding: 1em 2em 1em 2em;
|
||||
}
|
||||
body.darwin {
|
||||
font-family: "LucidaGrande", sans-serif;
|
||||
}
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
header {
|
||||
margin-bottom: 1em;
|
||||
border-bottom: 1px solid #aaa;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
.starred:after {
|
||||
content: "*";
|
||||
}
|
||||
header p {
|
||||
color: #aaa;
|
||||
margin: 0;
|
||||
padding: 0
|
||||
}
|
||||
a {
|
||||
color: #772953;
|
||||
text-decoration: none;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
article {
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class='""" + _platform + """''>
|
||||
<header>
|
||||
<p><span id="feed_title"></span> <span id="author"></span></p>
|
||||
<h1><a id="title" href=""></a></h1>
|
||||
<p><timedate id="date"></timedate></p>
|
||||
</header>
|
||||
<article id="article"></article>
|
||||
</body>
|
||||
</html>"""
|
||||
return html
|
||||
|
||||
|
||||
|
||||
class TinyTinyRSS:
|
||||
def __init__(self, app, server_url, session_id):
|
||||
self.app = app
|
||||
if server_url and session_id:
|
||||
self.server_url = server_url
|
||||
self.session_id = session_id
|
||||
else:
|
||||
self.app.authenticate()
|
||||
|
||||
def doOperation(self, operation, options=None):
|
||||
url = self.server_url + "/api/"
|
||||
default_options = {'sid': self.session_id, 'op': operation}
|
||||
if options:
|
||||
options = dict(default_options.items() + options.items())
|
||||
else:
|
||||
options = default_options
|
||||
json_string = json.dumps(options)
|
||||
req = urllib2.Request(url)
|
||||
fd = urllib2.urlopen(req, json_string)
|
||||
body = ""
|
||||
while True:
|
||||
data = fd.read(1024)
|
||||
if not len(data):
|
||||
break
|
||||
body += data
|
||||
|
||||
return json.loads(body)["content"]
|
||||
|
||||
def getUnreadFeeds(self, view_mode="unread"):
|
||||
unread_articles = []
|
||||
def more(skip):
|
||||
return self.doOperation("getHeadlines", {"show_excerpt": False, "view_mode": view_mode, "show_content": True, "feed_id": -4, "skip": skip})
|
||||
|
||||
skip = 0
|
||||
while True:
|
||||
new = more( skip)
|
||||
unread_articles += new
|
||||
length = len(new)
|
||||
|
||||
if length < 1:
|
||||
break
|
||||
skip += length
|
||||
|
||||
return unread_articles
|
||||
|
||||
def getStarredFeeds(self):
|
||||
return self.getUnreadFeeds("marked")
|
||||
|
||||
def setArticleRead(self, article_id, read=True):
|
||||
self.updateArticle(article_id, 2, not read)
|
||||
|
||||
def setArticleStarred(self, article_id, starred=True):
|
||||
self.updateArticle(article_id, 0, starred)
|
||||
|
||||
def updateArticle(self, article_id, field, true=True):
|
||||
l = lambda: self.doOperation("updateArticle", {'article_ids':article_id, 'mode': 1 if true else 0, 'field': field})
|
||||
t = Thread(target=l)
|
||||
t.start()
|
||||
|
||||
def logOut(self):
|
||||
self.doOperation("logout")
|
||||
|
||||
@classmethod
|
||||
def login(self, server_url, user, password):
|
||||
url = server_url + "/api/"
|
||||
options = {"op": "login", "user": user, "password": password}
|
||||
json_string = json.dumps(options)
|
||||
req = urllib2.Request(url)
|
||||
fd = urllib2.urlopen(req, json_string)
|
||||
body = ""
|
||||
while 1:
|
||||
data = fd.read(1024)
|
||||
if not len(data):
|
||||
break
|
||||
body += data
|
||||
|
||||
body = json.loads(body)["content"]
|
||||
|
||||
if body.has_key("error"):
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgBox.setText(body["error"])
|
||||
msgBox.exec_()
|
||||
return None
|
||||
|
||||
return body["session_id"]
|
||||
|
||||
|
||||
class Login(QtGui.QDialog):
|
||||
def __init__(self):
|
||||
QtGui.QDialog.__init__(self)
|
||||
self.setWindowIcon(QtGui.QIcon("feedmonkey.png"))
|
||||
self.setWindowTitle("Feed the Monkey - Login")
|
||||
|
||||
self.label = QtGui.QLabel(self)
|
||||
self.label.setText("Please specify a server url, a username and a password.")
|
||||
|
||||
self.textServerUrl = QtGui.QLineEdit(self)
|
||||
self.textServerUrl.setPlaceholderText("http://example.com/ttrss/")
|
||||
self.textServerUrl.setText("http://")
|
||||
|
||||
self.textName = QtGui.QLineEdit(self)
|
||||
self.textName.setPlaceholderText("username")
|
||||
|
||||
self.textPass = QtGui.QLineEdit(self)
|
||||
self.textPass.setEchoMode(QtGui.QLineEdit.Password);
|
||||
self.textPass.setPlaceholderText("password")
|
||||
|
||||
self.buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
|
||||
self.buttons.accepted.connect(self.accept)
|
||||
|
||||
layout = QtGui.QVBoxLayout(self)
|
||||
layout.addWidget(self.label)
|
||||
layout.addWidget(self.textServerUrl)
|
||||
layout.addWidget(self.textName)
|
||||
layout.addWidget(self.textPass)
|
||||
layout.addWidget(self.buttons)
|
||||
|
||||
|
||||
class WorkerThread(QtCore.QThread):
|
||||
|
||||
def __init__(self, parent, do_reload):
|
||||
super(WorkerThread, self).__init__(parent)
|
||||
self.do_reload = do_reload
|
||||
|
||||
def run(self):
|
||||
self.do_reload()
|
||||
self.emit(QtCore.SIGNAL("reload_done()"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
wb = MainWindow()
|
||||
wb.show()
|
||||
sys.exit(app.exec_())
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Version=0.1.0
|
||||
Comment=A desktop client for the TinyTinyRSS feed reader.
|
||||
Exec=feedthemonkey
|
||||
GenericName=Feed Reader
|
||||
Icon=feedthemonkey
|
||||
Name=Feed the Monkey
|
||||
NoDisplay=false
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Network;Qt
|
||||
9793
feedthemonkey.xpm
9793
feedthemonkey.xpm
File diff suppressed because it is too large
Load diff
131
html/content.css
Normal file
131
html/content.css
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/* CSS custom properties are set from Rust via AdwStyleManager.
|
||||
The :root defaults below act as a light-mode fallback only. */
|
||||
|
||||
:root {
|
||||
--bg: #ffffff;
|
||||
--fg: #1a1a1a;
|
||||
--fg-dim: rgba(0,0,0,0.55);
|
||||
--border: rgba(0,0,0,0.12);
|
||||
--header-bg: #f6f5f4;
|
||||
--link: #1c71d8;
|
||||
--code-bg: rgba(0,0,0,0.06);
|
||||
--blockquote-border: rgba(0,0,0,0.2);
|
||||
--font: sans-serif;
|
||||
--font-size: 15px;
|
||||
}
|
||||
|
||||
:root[data-dark="1"] {
|
||||
--bg: #1e1e1e;
|
||||
--fg: rgba(255,255,255,0.87);
|
||||
--fg-dim: rgba(255,255,255,0.5);
|
||||
--border: rgba(255,255,255,0.12);
|
||||
--header-bg: #242424;
|
||||
--link: #78aeed;
|
||||
--code-bg: rgba(255,255,255,0.06);
|
||||
--blockquote-border: rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
font-family: var(--font);
|
||||
font-size: var(--font-size);
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--link);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
article a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
header {
|
||||
padding: 1.5em 2em 1em;
|
||||
background: var(--header-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
header > .inner,
|
||||
article {
|
||||
max-width: 720px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
header > .inner {
|
||||
padding: 0 2em;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: 1.3em;
|
||||
margin: 0.2em 0 0.4em;
|
||||
padding: 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
header h1 a {
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
header p {
|
||||
color: var(--fg-dim);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
article {
|
||||
line-height: 1.6;
|
||||
padding: 1.5em 2em 2em;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
div > a:only-child img,
|
||||
figure > a:only-child img,
|
||||
p > a:only-child img,
|
||||
figure > img:only-child,
|
||||
div > img:only-child,
|
||||
p > img:only-child {
|
||||
display: block;
|
||||
margin: 1em auto;
|
||||
float: none !important;
|
||||
}
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
background: var(--code-bg);
|
||||
padding: 1em;
|
||||
border-radius: 6px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
code {
|
||||
background: var(--code-bg);
|
||||
padding: 0.15em 0.35em;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
pre code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 3px solid var(--blockquote-border);
|
||||
margin-left: 0;
|
||||
padding-left: 1em;
|
||||
color: var(--fg-dim);
|
||||
font-style: italic;
|
||||
}
|
||||
61
html/content.html
Normal file
61
html/content.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<title>FeedTheMonkey</title>
|
||||
<style>/*INJECT_CSS*/</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="inner">
|
||||
<p><span id="feed_title"></span> <span id="author"></span></p>
|
||||
<h1><a id="title" href=""></a></h1>
|
||||
<p><time id="date"></time></p>
|
||||
</div>
|
||||
</header>
|
||||
<article id="article"></article>
|
||||
|
||||
<script>
|
||||
function setArticle(article) {
|
||||
window.scrollTo(0, 0);
|
||||
document.getElementById('date').textContent = '';
|
||||
document.getElementById('title').textContent = '';
|
||||
document.getElementById('title').href = '';
|
||||
document.getElementById('feed_title').textContent = '';
|
||||
document.getElementById('author').textContent = '';
|
||||
document.getElementById('article').innerHTML = '';
|
||||
if (!article) return;
|
||||
document.getElementById('date').textContent =
|
||||
new Date(parseInt(article.updated, 10) * 1000).toLocaleDateString();
|
||||
document.getElementById('title').textContent = article.title || '';
|
||||
document.getElementById('title').href = article.link || '';
|
||||
document.getElementById('feed_title').textContent = article.feed_title || '';
|
||||
if (article.author && article.author.length > 0)
|
||||
document.getElementById('author').textContent = '\u2013 ' + article.author;
|
||||
document.getElementById('article').innerHTML = article.content || '';
|
||||
}
|
||||
|
||||
function setDark(isDark) {
|
||||
document.documentElement.setAttribute('data-dark', isDark ? '1' : '0');
|
||||
}
|
||||
|
||||
function setFont(family, sizePx) {
|
||||
document.documentElement.style.setProperty('--font', family);
|
||||
document.documentElement.style.setProperty('--font-size', sizePx + 'px');
|
||||
}
|
||||
|
||||
function checkKey(e) {
|
||||
if (e.key === 'ArrowRight' || e.key === 'j') {
|
||||
window.location = 'feedthemonkey:next';
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'k') {
|
||||
window.location = 'feedthemonkey:previous';
|
||||
} else if (e.key === 'Enter' || e.key === 'n') {
|
||||
window.location = 'feedthemonkey:open';
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', checkKey);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
31
install.sh
Executable file
31
install.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
# Install FeedTheMonkey system-wide (requires root or sudo).
|
||||
# Run after: cargo build --release
|
||||
|
||||
set -e
|
||||
|
||||
PREFIX="${PREFIX:-/usr/local}"
|
||||
BINARY="target/release/feedthemonkey"
|
||||
|
||||
if [ ! -f "$BINARY" ]; then
|
||||
echo "Binary not found. Run 'cargo build --release' first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install -Dm755 "$BINARY" "$PREFIX/bin/feedthemonkey"
|
||||
install -Dm644 data/net.jeena.FeedTheMonkey.desktop \
|
||||
"$PREFIX/share/applications/net.jeena.FeedTheMonkey.desktop"
|
||||
install -Dm644 data/icons/net.jeena.FeedTheMonkey.png \
|
||||
"$PREFIX/share/icons/hicolor/256x256/apps/net.jeena.FeedTheMonkey.png"
|
||||
|
||||
# Install GSettings schema
|
||||
install -Dm644 data/net.jeena.FeedTheMonkey.gschema.xml \
|
||||
"$PREFIX/share/glib-2.0/schemas/net.jeena.FeedTheMonkey.gschema.xml"
|
||||
glib-compile-schemas "$PREFIX/share/glib-2.0/schemas/"
|
||||
|
||||
# Update icon cache if gtk-update-icon-cache is available
|
||||
if command -v gtk-update-icon-cache &>/dev/null; then
|
||||
gtk-update-icon-cache -f -t "$PREFIX/share/icons/hicolor"
|
||||
fi
|
||||
|
||||
echo "Installed to $PREFIX"
|
||||
74
setup.py
74
setup.py
|
|
@ -1,74 +0,0 @@
|
|||
#!/usr/bin/env python2
|
||||
|
||||
import os, PyQt4
|
||||
from setuptools import setup
|
||||
from sys import platform as _platform
|
||||
|
||||
VERSION = "0.1.2"
|
||||
|
||||
files = []
|
||||
options = {}
|
||||
setup_requires = []
|
||||
|
||||
is_osx = _platform == "darwin"
|
||||
is_win = os.name == "nt"
|
||||
is_linux = not is_osx and not is_win
|
||||
|
||||
if is_linux:
|
||||
setup(
|
||||
name = "FeedTheMonkey",
|
||||
version = VERSION,
|
||||
author = "Jeena Paradies",
|
||||
author_email = "spam@jeenaparadies.net",
|
||||
url = "http://jabs.nu/feedthemonkey",
|
||||
license = "BSD license",
|
||||
scripts = ["feedthemonkey"],
|
||||
data_files=[
|
||||
('/usr/share/applications', ["feedthemonkey.desktop"]),
|
||||
('/usr/share/pixmaps', ["feedthemonkey.xpm"])
|
||||
]
|
||||
)
|
||||
|
||||
if is_osx:
|
||||
options = {
|
||||
'py2app': {
|
||||
'argv_emulation': False,
|
||||
'iconfile': 'Icon.icns',
|
||||
'plist': {
|
||||
'CFBundleShortVersionString': VERSION,
|
||||
'CFBundleIdentifier': "nu.jabs.apps.feedthemonkey",
|
||||
'LSMinimumSystemVersion': "10.4",
|
||||
'CFBundleURLTypes': [
|
||||
{
|
||||
'CFBundleURLName': 'nu.jabs.apps.feedthemonkey.handler',
|
||||
'CFBundleURLSchemes': ['feedthemonkey']
|
||||
}
|
||||
]
|
||||
},
|
||||
'includes':['PyQt4.QtWebKit', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui', 'PyQt4.QtNetwork'],
|
||||
'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtOpenGL', 'PyQt4.QtScript', 'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtXml', 'PyQt4.phonon', 'simplejson'],
|
||||
'qt_plugins': 'imageformats',
|
||||
}
|
||||
}
|
||||
|
||||
setup_requires = ["py2app"]
|
||||
APP = ["feedthemonkey"]
|
||||
|
||||
for dirname, dirnames, filenames in os.walk('.'):
|
||||
for filename in filenames:
|
||||
if filename == "Icon.icns":
|
||||
files += [(dirname, [os.path.join(dirname, filename)])]
|
||||
|
||||
setup(
|
||||
app = APP,
|
||||
name = "FeedTheMonkey",
|
||||
options = options,
|
||||
version = VERSION,
|
||||
author = "Jeena Paradies",
|
||||
author_email = "spam@jeenaparadies.net",
|
||||
url = "http://jabs.nu/feedthemonkey",
|
||||
license = "BSD license",
|
||||
scripts = ["feedthemonkey"],
|
||||
data_files = files,
|
||||
setup_requires = setup_requires
|
||||
)
|
||||
268
src/api.rs
Normal file
268
src/api.rs
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Api {
|
||||
client: Client,
|
||||
pub server_url: String,
|
||||
pub auth_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct StreamContents {
|
||||
items: Vec<Item>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Item {
|
||||
id: String,
|
||||
title: Option<String>,
|
||||
origin: Option<Origin>,
|
||||
canonical: Option<Vec<Link>>,
|
||||
published: Option<i64>,
|
||||
summary: Option<Summary>,
|
||||
author: Option<String>,
|
||||
categories: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Origin {
|
||||
title: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Link {
|
||||
href: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Summary {
|
||||
content: Option<String>,
|
||||
}
|
||||
|
||||
use crate::model::Article;
|
||||
|
||||
/// Return the candidate base URLs to try in order.
|
||||
/// Miniflux serves the Greader API at the server root;
|
||||
/// FreshRSS serves it at /api/greader.php.
|
||||
fn candidate_base_urls(server_url: &str) -> Vec<String> {
|
||||
let base = server_url.trim_end_matches('/');
|
||||
if base.ends_with("/api/greader.php") {
|
||||
vec![base.to_string()]
|
||||
} else {
|
||||
vec![
|
||||
base.to_string(),
|
||||
format!("{base}/api/greader.php"),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl Api {
|
||||
pub async fn login(
|
||||
server_url: &str,
|
||||
username: &str,
|
||||
password: &str,
|
||||
) -> Result<Self, String> {
|
||||
let client = Client::new();
|
||||
let candidates = candidate_base_urls(server_url);
|
||||
let mut last_err = String::new();
|
||||
|
||||
for base in candidates {
|
||||
let url = format!("{base}/accounts/ClientLogin");
|
||||
let resp = match client
|
||||
.post(&url)
|
||||
.form(&[("Email", username), ("Passwd", password)])
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(r) => r,
|
||||
Err(e) => { last_err = e.to_string(); continue; }
|
||||
};
|
||||
|
||||
let status = resp.status();
|
||||
let body = resp.text().await.map_err(|e| e.to_string())?;
|
||||
|
||||
if !status.is_success() {
|
||||
last_err = format!("Login failed ({}): {}", status.as_u16(), human_error(&body, status.as_u16()));
|
||||
continue;
|
||||
}
|
||||
|
||||
let auth_token = match body.lines().find_map(|l| l.strip_prefix("Auth=")) {
|
||||
Some(t) => t.to_string(),
|
||||
None => {
|
||||
last_err = if looks_like_html(&body) {
|
||||
format!(
|
||||
"The server at {base} does not appear to be a \
|
||||
Greader API endpoint. Check your server URL."
|
||||
)
|
||||
} else {
|
||||
format!("Unexpected response from server: {}", body.trim())
|
||||
};
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
return Ok(Self { client, server_url: base, auth_token });
|
||||
}
|
||||
|
||||
Err(last_err)
|
||||
}
|
||||
|
||||
pub async fn fetch_write_token(&self) -> Result<String, String> {
|
||||
let url = format!("{}/reader/api/0/token", self.server_url);
|
||||
let resp = self
|
||||
.client
|
||||
.get(&url)
|
||||
.header("Authorization", format!("GoogleLogin auth={}", self.auth_token))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("Failed to fetch write token: {}", resp.status()));
|
||||
}
|
||||
|
||||
resp.text().await.map_err(|e| e.to_string()).map(|s| s.trim().to_string())
|
||||
}
|
||||
|
||||
pub async fn fetch_unread(&self) -> Result<Vec<Article>, String> {
|
||||
let url = format!(
|
||||
"{}/reader/api/0/stream/contents/reading-list\
|
||||
?xt=user/-/state/com.google/read&n=200&output=json",
|
||||
self.server_url
|
||||
);
|
||||
let resp = self
|
||||
.client
|
||||
.get(&url)
|
||||
.header("Authorization", format!("GoogleLogin auth={}", self.auth_token))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("Failed to fetch articles: {}", resp.status()));
|
||||
}
|
||||
|
||||
let stream: StreamContents = resp.json().await.map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(stream.items.into_iter().map(|item| {
|
||||
let unread = !item.categories.as_deref().unwrap_or_default()
|
||||
.iter()
|
||||
.any(|c| c == "user/-/state/com.google/read");
|
||||
let content = item.summary
|
||||
.as_ref()
|
||||
.and_then(|s| s.content.clone())
|
||||
.unwrap_or_default();
|
||||
let excerpt = plain_text_excerpt(&content, 150);
|
||||
Article {
|
||||
id: item.id,
|
||||
title: item.title.unwrap_or_default(),
|
||||
feed_title: item.origin.as_ref().and_then(|o| o.title.clone()).unwrap_or_default(),
|
||||
author: item.author.unwrap_or_default(),
|
||||
link: item.canonical.as_ref()
|
||||
.and_then(|v| v.first())
|
||||
.map(|l| l.href.clone())
|
||||
.unwrap_or_default(),
|
||||
published: item.published.unwrap_or(0),
|
||||
content,
|
||||
excerpt,
|
||||
unread,
|
||||
}
|
||||
}).collect())
|
||||
}
|
||||
|
||||
pub async fn mark_read(
|
||||
&self,
|
||||
write_token: &str,
|
||||
item_id: &str,
|
||||
) -> Result<(), String> {
|
||||
self.edit_tag(write_token, item_id, "a", "user/-/state/com.google/read").await
|
||||
}
|
||||
|
||||
pub async fn mark_unread(
|
||||
&self,
|
||||
write_token: &str,
|
||||
item_id: &str,
|
||||
) -> Result<(), String> {
|
||||
self.edit_tag(write_token, item_id, "r", "user/-/state/com.google/read").await
|
||||
}
|
||||
|
||||
async fn edit_tag(
|
||||
&self,
|
||||
write_token: &str,
|
||||
item_id: &str,
|
||||
action_key: &str,
|
||||
state: &str,
|
||||
) -> Result<(), String> {
|
||||
let url = format!("{}/reader/api/0/edit-tag", self.server_url);
|
||||
let resp = self
|
||||
.client
|
||||
.post(&url)
|
||||
.header("Authorization", format!("GoogleLogin auth={}", self.auth_token))
|
||||
.form(&[("i", item_id), (action_key, state), ("T", write_token)])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
if resp.status() == reqwest::StatusCode::UNAUTHORIZED {
|
||||
return Err("UNAUTHORIZED".to_string());
|
||||
}
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("edit-tag failed: {}", resp.status()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn looks_like_html(body: &str) -> bool {
|
||||
let trimmed = body.trim_start();
|
||||
trimmed.starts_with("<!") || trimmed.to_ascii_lowercase().starts_with("<html")
|
||||
}
|
||||
|
||||
fn human_error(body: &str, status: u16) -> String {
|
||||
if looks_like_html(body) {
|
||||
match status {
|
||||
401 | 403 => "Wrong username or password.".to_string(),
|
||||
404 => "API endpoint not found. Check your server URL.".to_string(),
|
||||
_ => format!("Server returned HTTP {status}. Check your server URL."),
|
||||
}
|
||||
} else {
|
||||
let trimmed = body.trim();
|
||||
if trimmed.is_empty() {
|
||||
format!("Server returned HTTP {status} with no message.")
|
||||
} else {
|
||||
trimmed.to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn plain_text_excerpt(html: &str, max_chars: usize) -> String {
|
||||
// Very simple HTML stripper — remove tags, collapse whitespace
|
||||
let mut out = String::with_capacity(html.len());
|
||||
let mut in_tag = false;
|
||||
for ch in html.chars() {
|
||||
match ch {
|
||||
'<' => in_tag = true,
|
||||
'>' => in_tag = false,
|
||||
c if !in_tag => out.push(c),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let collapsed: String = out.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
let decoded = decode_html_entities(&collapsed);
|
||||
if decoded.chars().count() <= max_chars {
|
||||
decoded
|
||||
} else {
|
||||
decoded.chars().take(max_chars).collect::<String>() + "…"
|
||||
}
|
||||
}
|
||||
|
||||
fn decode_html_entities(s: &str) -> String {
|
||||
s.replace("&", "&")
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
.replace(""", "\"")
|
||||
.replace("'", "'")
|
||||
.replace("'", "'")
|
||||
.replace(" ", " ")
|
||||
}
|
||||
166
src/app.rs
Normal file
166
src/app.rs
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
use gtk4::prelude::*;
|
||||
use libadwaita::prelude::*;
|
||||
|
||||
use crate::window::FeedTheMonkeyWindow;
|
||||
|
||||
const APP_ID: &str = "net.jeena.FeedTheMonkey";
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct FeedTheMonkeyApp(ObjectSubclass<imp::FeedTheMonkeyApp>)
|
||||
@extends libadwaita::Application, gtk4::Application, gio::Application,
|
||||
@implements gio::ActionGroup, gio::ActionMap;
|
||||
}
|
||||
|
||||
impl FeedTheMonkeyApp {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::builder()
|
||||
.property("application-id", APP_ID)
|
||||
.property("flags", gio::ApplicationFlags::empty())
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn run(&self) -> glib::ExitCode {
|
||||
ApplicationExtManual::run(self)
|
||||
}
|
||||
}
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
use libadwaita::subclass::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FeedTheMonkeyApp;
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for FeedTheMonkeyApp {
|
||||
const NAME: &'static str = "FeedTheMonkeyApp";
|
||||
type Type = super::FeedTheMonkeyApp;
|
||||
type ParentType = libadwaita::Application;
|
||||
}
|
||||
|
||||
impl ObjectImpl for FeedTheMonkeyApp {}
|
||||
|
||||
impl ApplicationImpl for FeedTheMonkeyApp {
|
||||
fn activate(&self) {
|
||||
self.parent_activate();
|
||||
let app = self.obj();
|
||||
|
||||
// Register GResource
|
||||
let resource_bytes = glib::Bytes::from_static(include_bytes!(env!("GRESOURCE_FILE")));
|
||||
let resource = gio::Resource::from_data(&resource_bytes)
|
||||
.expect("failed to load GResource");
|
||||
gio::resources_register(&resource);
|
||||
|
||||
// Apply application-level CSS tweaks
|
||||
let css = gtk4::CssProvider::new();
|
||||
css.load_from_string(
|
||||
"paned > :first-child .top-bar headerbar {
|
||||
background-color: @headerbar_bg_color;
|
||||
box-shadow: none;
|
||||
}
|
||||
paned > :first-child > toolbarview > .content {
|
||||
padding-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
.sidebar-content row:not(:selected) {
|
||||
background-color: alpha(@window_fg_color, 0.07);
|
||||
}
|
||||
.sidebar-content row:not(:selected):hover {
|
||||
background-color: alpha(@window_fg_color, 0.14);
|
||||
}
|
||||
.sidebar-content row:selected {
|
||||
background-color: alpha(@window_fg_color, 0.22);
|
||||
}
|
||||
.article-title {
|
||||
font-size: 1.05em;
|
||||
}"
|
||||
);
|
||||
gtk4::style_context_add_provider_for_display(
|
||||
>k4::gdk::Display::default().unwrap(),
|
||||
&css,
|
||||
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
|
||||
let window = FeedTheMonkeyWindow::new(app.upcast_ref());
|
||||
|
||||
// Shortcuts overlay
|
||||
let builder = gtk4::Builder::from_resource(
|
||||
"/net/jeena/FeedTheMonkey/ui/shortcuts.ui",
|
||||
);
|
||||
let overlay: gtk4::ShortcutsWindow = builder.object("help_overlay").unwrap();
|
||||
window.set_help_overlay(Some(&overlay));
|
||||
|
||||
setup_shortcuts(&window);
|
||||
|
||||
// About action on app
|
||||
let app_weak = app.downgrade();
|
||||
let about_action = gio::SimpleAction::new("about", None);
|
||||
about_action.connect_activate(move |_, _| {
|
||||
if let Some(app) = app_weak.upgrade() {
|
||||
let win = app.active_window();
|
||||
let dialog = libadwaita::AboutDialog::builder()
|
||||
.application_name("FeedTheMonkey")
|
||||
.application_icon("feedthemonkey")
|
||||
.version("3.0.0")
|
||||
.copyright("© Jeena Paradies")
|
||||
.license_type(gtk4::License::Gpl30)
|
||||
.website("https://git.jeena.net/jeena/FeedTheMonkey")
|
||||
.developer_name("Jeena Paradies")
|
||||
.build();
|
||||
dialog.present(win.as_ref().map(|w| w.upcast_ref::<gtk4::Widget>()));
|
||||
}
|
||||
});
|
||||
app.add_action(&about_action);
|
||||
|
||||
// Quit action
|
||||
let app_weak = app.downgrade();
|
||||
let quit_action = gio::SimpleAction::new("quit", None);
|
||||
quit_action.connect_activate(move |_, _| {
|
||||
if let Some(app) = app_weak.upgrade() {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
app.add_action(&quit_action);
|
||||
|
||||
window.present();
|
||||
}
|
||||
}
|
||||
|
||||
impl GtkApplicationImpl for FeedTheMonkeyApp {}
|
||||
impl AdwApplicationImpl for FeedTheMonkeyApp {}
|
||||
}
|
||||
|
||||
fn setup_shortcuts(window: &FeedTheMonkeyWindow) {
|
||||
use gtk4::gdk::{Key, ModifierType};
|
||||
|
||||
let controller = gtk4::ShortcutController::new();
|
||||
controller.set_scope(gtk4::ShortcutScope::Global);
|
||||
|
||||
let add = |controller: >k4::ShortcutController,
|
||||
key: Key,
|
||||
mods: ModifierType,
|
||||
action_name: &str| {
|
||||
let trigger = gtk4::KeyvalTrigger::new(key, mods);
|
||||
let action = gtk4::NamedAction::new(action_name);
|
||||
let shortcut = gtk4::Shortcut::new(Some(trigger), Some(action));
|
||||
controller.add_shortcut(shortcut);
|
||||
};
|
||||
|
||||
// j/k/Left/Right are handled by a capture-phase key controller in window.rs
|
||||
// so they work regardless of which widget has focus.
|
||||
add(&controller, Key::r, ModifierType::empty(), "win.reload");
|
||||
add(&controller, Key::u, ModifierType::empty(), "win.mark-unread");
|
||||
add(&controller, Key::Return, ModifierType::empty(), "win.open-in-browser");
|
||||
add(&controller, Key::n, ModifierType::empty(), "win.open-in-browser");
|
||||
add(&controller, Key::plus, ModifierType::CONTROL_MASK, "win.zoom-in");
|
||||
add(&controller, Key::equal, ModifierType::CONTROL_MASK, "win.zoom-in");
|
||||
add(&controller, Key::minus, ModifierType::CONTROL_MASK, "win.zoom-out");
|
||||
add(&controller, Key::_0, ModifierType::CONTROL_MASK, "win.zoom-reset");
|
||||
add(&controller, Key::F9, ModifierType::empty(), "win.toggle-sidebar");
|
||||
add(&controller, Key::F11, ModifierType::empty(), "win.toggle-fullscreen");
|
||||
add(&controller, Key::w, ModifierType::CONTROL_MASK, "window.close");
|
||||
add(&controller, Key::q, ModifierType::CONTROL_MASK, "app.quit");
|
||||
add(&controller, Key::F1, ModifierType::empty(), "win.show-help-overlay");
|
||||
|
||||
window.add_controller(controller);
|
||||
}
|
||||
193
src/article_row.rs
Normal file
193
src/article_row.rs
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
use gtk4::glib;
|
||||
use gtk4::subclass::prelude::ObjectSubclassIsExt;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct ArticleRow(ObjectSubclass<imp::ArticleRow>)
|
||||
@extends gtk4::Box, gtk4::Widget,
|
||||
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget, gtk4::Orientable;
|
||||
}
|
||||
|
||||
impl ArticleRow {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
|
||||
pub fn bind(&self, obj: &crate::model::ArticleObject) {
|
||||
self.imp().bind(obj);
|
||||
}
|
||||
|
||||
pub fn unbind(&self) {
|
||||
self.imp().unbind();
|
||||
}
|
||||
}
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
use crate::model::ArticleObject;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
use glib::object::ObjectExt;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/net/jeena/FeedTheMonkey/ui/article_row.ui")]
|
||||
pub struct ArticleRow {
|
||||
#[template_child]
|
||||
pub feed_title_label: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub date_label: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub title_label: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub excerpt_label: TemplateChild<gtk4::Label>,
|
||||
|
||||
pub bindings: RefCell<Vec<glib::Binding>>,
|
||||
pub unread_handler: RefCell<Option<(ArticleObject, glib::SignalHandlerId)>>,
|
||||
pub context_menu: std::cell::OnceCell<gtk4::Popover>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for ArticleRow {
|
||||
const NAME: &'static str = "ArticleRow";
|
||||
type Type = super::ArticleRow;
|
||||
type ParentType = gtk4::Box;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for ArticleRow {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
self.setup_context_menu();
|
||||
}
|
||||
|
||||
fn dispose(&self) {
|
||||
if let Some(popover) = self.context_menu.get() {
|
||||
popover.unparent();
|
||||
}
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for ArticleRow {}
|
||||
impl BoxImpl for ArticleRow {}
|
||||
|
||||
impl ArticleRow {
|
||||
fn setup_context_menu(&self) {
|
||||
let button = gtk4::Button::with_label("Mark as Unread");
|
||||
button.set_has_frame(false);
|
||||
|
||||
let popover = gtk4::Popover::new();
|
||||
popover.set_child(Some(&button));
|
||||
popover.set_parent(&*self.obj());
|
||||
self.context_menu.set(popover.clone()).ok();
|
||||
|
||||
// Close popover and activate action when button is clicked.
|
||||
let imp_weak = self.downgrade();
|
||||
let popover_weak = popover.downgrade();
|
||||
button.connect_clicked(move |_| {
|
||||
if let Some(popover) = popover_weak.upgrade() {
|
||||
popover.popdown();
|
||||
}
|
||||
let Some(imp) = imp_weak.upgrade() else { return };
|
||||
let handler = imp.unread_handler.borrow();
|
||||
let Some((obj, _)) = handler.as_ref() else { return };
|
||||
let article_id = obj.article().id.clone();
|
||||
drop(handler);
|
||||
imp.obj()
|
||||
.activate_action(
|
||||
"win.mark-article-unread",
|
||||
Some(&article_id.to_variant()),
|
||||
)
|
||||
.ok();
|
||||
});
|
||||
|
||||
// Right-click gesture to show the popover at cursor position.
|
||||
let gesture = gtk4::GestureClick::new();
|
||||
gesture.set_button(3);
|
||||
let popover_weak2 = popover.downgrade();
|
||||
gesture.connect_pressed(move |gesture, _, x, y| {
|
||||
gesture.set_state(gtk4::EventSequenceState::Claimed);
|
||||
let Some(popover) = popover_weak2.upgrade() else { return };
|
||||
popover.set_pointing_to(Some(>k4::gdk::Rectangle::new(
|
||||
x as i32,
|
||||
y as i32,
|
||||
1,
|
||||
1,
|
||||
)));
|
||||
popover.popup();
|
||||
});
|
||||
self.obj().add_controller(gesture);
|
||||
}
|
||||
|
||||
pub fn bind(&self, obj: &ArticleObject) {
|
||||
let article = obj.article();
|
||||
self.feed_title_label.set_text(&article.feed_title);
|
||||
self.excerpt_label.set_text(&article.excerpt);
|
||||
self.date_label.set_text(&relative_time(article.published));
|
||||
|
||||
// Set initial bold state directly (using Pango markup to avoid
|
||||
// CSS specificity issues with the zoom font-size provider).
|
||||
let escaped = glib::markup_escape_text(&article.title);
|
||||
if article.unread {
|
||||
self.title_label.remove_css_class("dim-label");
|
||||
self.title_label.set_markup(&format!("<b>{escaped}</b>"));
|
||||
} else {
|
||||
self.title_label.add_css_class("dim-label");
|
||||
self.title_label.set_markup(&escaped);
|
||||
}
|
||||
drop(article);
|
||||
|
||||
// Connect handler for future unread state changes.
|
||||
let title_label = self.title_label.clone();
|
||||
let id = obj.connect_notify_local(Some("unread"), move |obj, _| {
|
||||
let article = obj.article();
|
||||
let escaped = glib::markup_escape_text(&article.title);
|
||||
if article.unread {
|
||||
title_label.remove_css_class("dim-label");
|
||||
title_label.set_markup(&format!("<b>{escaped}</b>"));
|
||||
} else {
|
||||
title_label.add_css_class("dim-label");
|
||||
title_label.set_markup(&escaped);
|
||||
}
|
||||
});
|
||||
*self.unread_handler.borrow_mut() = Some((obj.clone(), id));
|
||||
}
|
||||
|
||||
pub fn unbind(&self) {
|
||||
if let Some((obj, id)) = self.unread_handler.borrow_mut().take() {
|
||||
obj.disconnect(id);
|
||||
}
|
||||
for b in self.bindings.borrow_mut().drain(..) {
|
||||
b.unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn relative_time(unix: i64) -> String {
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs() as i64;
|
||||
let diff = now - unix;
|
||||
if diff < 60 {
|
||||
"just now".to_string()
|
||||
} else if diff < 3600 {
|
||||
let m = diff / 60;
|
||||
format!("{m}m ago")
|
||||
} else if diff < 86400 {
|
||||
let h = diff / 3600;
|
||||
format!("{h}h ago")
|
||||
} else if diff < 172800 {
|
||||
"Yesterday".to_string()
|
||||
} else {
|
||||
let d = diff / 86400;
|
||||
format!("{d}d ago")
|
||||
}
|
||||
}
|
||||
29
src/cache.rs
Normal file
29
src/cache.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use crate::model::Article;
|
||||
|
||||
pub struct Cache {
|
||||
pub articles: Vec<Article>,
|
||||
pub selected_id: String,
|
||||
}
|
||||
|
||||
pub fn save(articles: &[Article], selected_id: &str) {
|
||||
let dir = glib::user_cache_dir().join("net.jeena.FeedTheMonkey");
|
||||
std::fs::create_dir_all(&dir).ok();
|
||||
let data = serde_json::json!({
|
||||
"articles": articles,
|
||||
"selected_id": selected_id,
|
||||
});
|
||||
if let Ok(s) = serde_json::to_string(&data) {
|
||||
std::fs::write(dir.join("cache.json"), s).ok();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load() -> Option<Cache> {
|
||||
let path = glib::user_cache_dir()
|
||||
.join("net.jeena.FeedTheMonkey")
|
||||
.join("cache.json");
|
||||
let data = std::fs::read_to_string(path).ok()?;
|
||||
let json: serde_json::Value = serde_json::from_str(&data).ok()?;
|
||||
let articles: Vec<Article> = serde_json::from_value(json["articles"].clone()).ok()?;
|
||||
let selected_id = json["selected_id"].as_str().unwrap_or("").to_string();
|
||||
Some(Cache { articles, selected_id })
|
||||
}
|
||||
65
src/credentials.rs
Normal file
65
src/credentials.rs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
use libsecret::{prelude::*, SchemaAttributeType, SchemaFlags, SearchFlags};
|
||||
use std::collections::HashMap;
|
||||
|
||||
const SCHEMA_NAME: &str = "net.jeena.FeedTheMonkey";
|
||||
const ATTR_SERVER: &str = "server-url";
|
||||
const ATTR_USERNAME: &str = "username";
|
||||
const LABEL: &str = "FeedTheMonkey credentials";
|
||||
|
||||
fn schema() -> libsecret::Schema {
|
||||
libsecret::Schema::new(
|
||||
SCHEMA_NAME,
|
||||
SchemaFlags::NONE,
|
||||
HashMap::from([
|
||||
(ATTR_SERVER, SchemaAttributeType::String),
|
||||
(ATTR_USERNAME, SchemaAttributeType::String),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn store_credentials(server_url: &str, username: &str, password: &str) {
|
||||
let schema = schema();
|
||||
let attrs = HashMap::from([
|
||||
(ATTR_SERVER, server_url),
|
||||
(ATTR_USERNAME, username),
|
||||
]);
|
||||
if let Err(e) = libsecret::password_store_sync(
|
||||
Some(&schema),
|
||||
attrs,
|
||||
Some(libsecret::COLLECTION_DEFAULT.as_str()),
|
||||
LABEL,
|
||||
password,
|
||||
gio::Cancellable::NONE,
|
||||
) {
|
||||
eprintln!("Failed to store credentials: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_credentials() -> Option<(String, String, String)> {
|
||||
let schema = schema();
|
||||
let items = libsecret::password_search_sync(
|
||||
Some(&schema),
|
||||
HashMap::new(),
|
||||
SearchFlags::LOAD_SECRETS | SearchFlags::UNLOCK,
|
||||
gio::Cancellable::NONE,
|
||||
).ok()?;
|
||||
|
||||
let item = items.into_iter().next()?;
|
||||
let attrs = item.attributes();
|
||||
let server_url = attrs.get(ATTR_SERVER)?.to_string();
|
||||
let username = attrs.get(ATTR_USERNAME)?.to_string();
|
||||
let secret = item.retrieve_secret_sync(gio::Cancellable::NONE).ok()??;
|
||||
let password = secret.text()?.to_string();
|
||||
Some((server_url, username, password))
|
||||
}
|
||||
|
||||
pub fn clear_credentials() {
|
||||
let schema = schema();
|
||||
if let Err(e) = libsecret::password_clear_sync(
|
||||
Some(&schema),
|
||||
HashMap::new(),
|
||||
gio::Cancellable::NONE,
|
||||
) {
|
||||
eprintln!("Failed to clear credentials: {e}");
|
||||
}
|
||||
}
|
||||
68
src/filters.rs
Normal file
68
src/filters.rs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/// Content rewrite rules stored in GSettings key "content-filters".
|
||||
///
|
||||
/// Format — one rule per line, tokens separated by spaces:
|
||||
///
|
||||
/// domain from to [from to …]
|
||||
///
|
||||
/// Examples:
|
||||
///
|
||||
/// www.imycomic.com -150x150.jpg .jpg
|
||||
/// www.stuttmann-karikaturen.de /thumbs/ /
|
||||
/// existentialcomics.com src="//static src="https://static
|
||||
///
|
||||
/// The domain is matched as a substring of the article's GUID and link URL.
|
||||
/// Blank lines and lines starting with # are ignored.
|
||||
|
||||
use gtk4::gio;
|
||||
use gtk4::prelude::SettingsExt;
|
||||
|
||||
pub struct Rule {
|
||||
pub pattern: String,
|
||||
pub replacements: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
/// Parse the multi-line text from the GSettings key into rules.
|
||||
pub fn parse(text: &str) -> Vec<Rule> {
|
||||
let mut rules = Vec::new();
|
||||
for line in text.lines() {
|
||||
let line = line.trim();
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
let tokens: Vec<&str> = line.splitn(usize::MAX, ' ')
|
||||
.map(str::trim)
|
||||
.filter(|t| !t.is_empty())
|
||||
.collect();
|
||||
if tokens.len() < 3 || tokens.len() % 2 == 0 {
|
||||
// Need: domain + at least one from/to pair (odd total ≥ 3)
|
||||
eprintln!("filters: skipping malformed line: {line}");
|
||||
continue;
|
||||
}
|
||||
let pattern = tokens[0].to_string();
|
||||
let replacements = tokens[1..]
|
||||
.chunks(2)
|
||||
.map(|c| (c[0].to_string(), c[1].to_string()))
|
||||
.collect();
|
||||
rules.push(Rule { pattern, replacements });
|
||||
}
|
||||
rules
|
||||
}
|
||||
|
||||
/// Load rules from GSettings.
|
||||
pub fn load_rules() -> Vec<Rule> {
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
parse(&settings.string("content-filters"))
|
||||
}
|
||||
|
||||
/// Apply all matching rules to `content`.
|
||||
pub fn apply(rules: &[Rule], guid: &str, link: &str, content: &str) -> String {
|
||||
let mut out = content.to_string();
|
||||
for rule in rules {
|
||||
if guid.contains(&rule.pattern) || link.contains(&rule.pattern) {
|
||||
for (from, to) in &rule.replacements {
|
||||
out = out.replace(from.as_str(), to.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
211
src/image_cache.rs
Normal file
211
src/image_cache.rs
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
use std::collections::HashSet;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::model::Article;
|
||||
|
||||
fn images_dir() -> PathBuf {
|
||||
glib::user_cache_dir()
|
||||
.join("net.jeena.FeedTheMonkey")
|
||||
.join("images")
|
||||
}
|
||||
|
||||
fn url_to_filename(url: &str) -> String {
|
||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||
url.hash(&mut hasher);
|
||||
let hash = format!("{:016x}", hasher.finish());
|
||||
let ext = url.split('?').next()
|
||||
.and_then(|u| u.rsplit('.').next())
|
||||
.filter(|e| e.len() <= 5 && e.bytes().all(|b| b.is_ascii_alphanumeric()))
|
||||
.unwrap_or("");
|
||||
if ext.is_empty() { hash } else { format!("{}.{}", hash, ext) }
|
||||
}
|
||||
|
||||
fn percent_encode(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
for b in s.bytes() {
|
||||
if b.is_ascii_alphanumeric() || b"-.~_".contains(&b) {
|
||||
out.push(b as char);
|
||||
} else {
|
||||
out.push_str(&format!("%{:02X}", b));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn percent_decode(s: &str) -> String {
|
||||
let bytes = s.as_bytes();
|
||||
let mut out = Vec::with_capacity(bytes.len());
|
||||
let mut i = 0;
|
||||
while i < bytes.len() {
|
||||
if bytes[i] == b'%' && i + 2 < bytes.len() {
|
||||
if let Ok(b) = u8::from_str_radix(
|
||||
std::str::from_utf8(&bytes[i + 1..i + 3]).unwrap_or(""),
|
||||
16,
|
||||
) {
|
||||
out.push(b);
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.push(bytes[i]);
|
||||
i += 1;
|
||||
}
|
||||
String::from_utf8_lossy(&out).into_owned()
|
||||
}
|
||||
|
||||
const SCHEME: &str = "feedthemonkey-img";
|
||||
const SCHEME_PREFIX: &str = "feedthemonkey-img:///";
|
||||
|
||||
fn original_url_to_scheme_uri(url: &str) -> String {
|
||||
format!("{}{}", SCHEME_PREFIX, percent_encode(url))
|
||||
}
|
||||
|
||||
/// Register the feedthemonkey-img URI scheme handler on the WebView's context.
|
||||
/// Call this in setup_webview() before load_html().
|
||||
pub fn register_scheme(ctx: &webkit6::WebContext) {
|
||||
ctx.register_uri_scheme(SCHEME, |request| {
|
||||
let uri = request.uri().unwrap_or_default().to_string();
|
||||
let encoded = uri.strip_prefix(SCHEME_PREFIX).unwrap_or(&uri);
|
||||
let original_url = percent_decode(encoded);
|
||||
let path = images_dir().join(url_to_filename(&original_url));
|
||||
|
||||
if path.exists() {
|
||||
serve_file(request.clone(), path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not in cache — download in tokio, serve back on the main thread.
|
||||
let request = request.clone();
|
||||
let (tx, rx) = tokio::sync::oneshot::channel::<bool>();
|
||||
let path_dl = path.clone();
|
||||
|
||||
crate::runtime::spawn_bg(async move {
|
||||
let ok = async {
|
||||
let bytes = reqwest::get(&original_url).await?.bytes().await?;
|
||||
std::fs::create_dir_all(path_dl.parent().unwrap()).ok();
|
||||
std::fs::write(&path_dl, &bytes).ok();
|
||||
Ok::<_, reqwest::Error>(())
|
||||
}
|
||||
.await
|
||||
.is_ok();
|
||||
let _ = tx.send(ok);
|
||||
});
|
||||
|
||||
// spawn_future_local runs on the GLib main loop so the non-Send
|
||||
// URISchemeRequest can be safely held across the await point.
|
||||
glib::spawn_future_local(async move {
|
||||
if rx.await.unwrap_or(false) && path.exists() {
|
||||
serve_file(request, path);
|
||||
} else {
|
||||
request.finish_error(&mut glib::Error::new(
|
||||
gio::IOErrorEnum::NotFound,
|
||||
"Image unavailable",
|
||||
));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn serve_file(request: webkit6::URISchemeRequest, path: PathBuf) {
|
||||
match std::fs::read(&path) {
|
||||
Ok(data) => {
|
||||
let mime = path.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.map(|ext| match ext.to_ascii_lowercase().as_str() {
|
||||
"jpg" | "jpeg" => "image/jpeg",
|
||||
"png" => "image/png",
|
||||
"gif" => "image/gif",
|
||||
"webp" => "image/webp",
|
||||
"svg" => "image/svg+xml",
|
||||
"avif" => "image/avif",
|
||||
_ => "application/octet-stream",
|
||||
})
|
||||
.unwrap_or("application/octet-stream");
|
||||
let stream = gio::MemoryInputStream::from_bytes(&glib::Bytes::from_owned(data));
|
||||
request.finish(&stream, -1, Some(mime));
|
||||
}
|
||||
Err(_) => {
|
||||
request.finish_error(&mut glib::Error::new(
|
||||
gio::IOErrorEnum::NotFound,
|
||||
"Image not found",
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Prefetch all images referenced in the articles into the cache directory.
|
||||
/// Runs entirely in the background; already-cached files are skipped.
|
||||
pub async fn prefetch(articles: Vec<Article>) {
|
||||
let dir = images_dir();
|
||||
std::fs::create_dir_all(&dir).ok();
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
.timeout(std::time::Duration::from_secs(30))
|
||||
.build()
|
||||
.unwrap_or_default();
|
||||
|
||||
let re = regex::Regex::new(&format!(r#"src="{}([^"]+)""#, regex::escape(SCHEME_PREFIX))).unwrap();
|
||||
|
||||
for article in &articles {
|
||||
for cap in re.captures_iter(&article.content) {
|
||||
let original_url = percent_decode(&cap[1]);
|
||||
let path = dir.join(url_to_filename(&original_url));
|
||||
if !path.exists() {
|
||||
if let Ok(resp) = client.get(&original_url).send().await {
|
||||
if let Ok(bytes) = resp.bytes().await {
|
||||
std::fs::write(&path, &bytes).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Rewrite all remote image src attributes to feedthemonkey-img:// URIs.
|
||||
/// No network requests are made here — images are downloaded lazily by the
|
||||
/// URI scheme handler the first time the WebView requests them, then cached.
|
||||
pub fn process(articles: Vec<Article>) -> Vec<Article> {
|
||||
let re = regex::Regex::new(r#"src="(https?://[^"]+)""#).unwrap();
|
||||
articles
|
||||
.into_iter()
|
||||
.map(|mut article| {
|
||||
let content = article.content.clone();
|
||||
let mut rewritten = content.clone();
|
||||
for cap in re.captures_iter(&content) {
|
||||
let url = &cap[1];
|
||||
rewritten = rewritten.replace(
|
||||
&format!("src=\"{}\"", url),
|
||||
&format!("src=\"{}\"", original_url_to_scheme_uri(url)),
|
||||
);
|
||||
}
|
||||
article.content = rewritten;
|
||||
article
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Remove cached image files no longer referenced by any article.
|
||||
pub fn cleanup(articles: &[Article]) {
|
||||
let dir = images_dir();
|
||||
let Ok(entries) = std::fs::read_dir(&dir) else { return };
|
||||
|
||||
let re = regex::Regex::new(
|
||||
&format!(r#"src="{}([^"]+)""#, regex::escape(SCHEME_PREFIX)),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut referenced: HashSet<String> = HashSet::new();
|
||||
for article in articles {
|
||||
for cap in re.captures_iter(&article.content) {
|
||||
referenced.insert(url_to_filename(&percent_decode(&cap[1])));
|
||||
}
|
||||
}
|
||||
|
||||
for entry in entries.filter_map(|e| e.ok()) {
|
||||
let fname = entry.file_name().to_string_lossy().to_string();
|
||||
if !referenced.contains(&fname) {
|
||||
std::fs::remove_file(entry.path()).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
124
src/login_dialog.rs
Normal file
124
src/login_dialog.rs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
use gtk4::glib;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct LoginDialog(ObjectSubclass<imp::LoginDialog>)
|
||||
@extends libadwaita::Dialog, gtk4::Widget,
|
||||
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl LoginDialog {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
use libadwaita::prelude::*;
|
||||
use libadwaita::subclass::prelude::*;
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/net/jeena/FeedTheMonkey/ui/login_dialog.ui")]
|
||||
pub struct LoginDialog {
|
||||
#[template_child]
|
||||
pub server_url_row: TemplateChild<libadwaita::EntryRow>,
|
||||
#[template_child]
|
||||
pub username_row: TemplateChild<libadwaita::EntryRow>,
|
||||
#[template_child]
|
||||
pub password_row: TemplateChild<libadwaita::PasswordEntryRow>,
|
||||
#[template_child]
|
||||
pub login_button: TemplateChild<libadwaita::ButtonRow>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for LoginDialog {
|
||||
const NAME: &'static str = "LoginDialog";
|
||||
type Type = super::LoginDialog;
|
||||
type ParentType = libadwaita::Dialog;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for LoginDialog {
|
||||
fn signals() -> &'static [glib::subclass::Signal] {
|
||||
use std::sync::OnceLock;
|
||||
static SIGNALS: OnceLock<Vec<glib::subclass::Signal>> = OnceLock::new();
|
||||
SIGNALS.get_or_init(|| {
|
||||
vec![
|
||||
glib::subclass::Signal::builder("logged-in")
|
||||
.param_types([
|
||||
String::static_type(),
|
||||
String::static_type(),
|
||||
String::static_type(),
|
||||
])
|
||||
.build(),
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
// Login button
|
||||
let obj_weak = self.obj().downgrade();
|
||||
self.login_button.connect_activated(move |_| {
|
||||
if let Some(dialog) = obj_weak.upgrade() {
|
||||
dialog.imp().on_login_clicked();
|
||||
}
|
||||
});
|
||||
|
||||
// Enter in any row submits the form (connect_entry_activated fires on Return)
|
||||
for weak in [
|
||||
self.server_url_row.downgrade(),
|
||||
self.username_row.downgrade(),
|
||||
] {
|
||||
let obj_weak = self.obj().downgrade();
|
||||
weak.upgrade().unwrap().connect_entry_activated(move |_| {
|
||||
if let Some(dialog) = obj_weak.upgrade() {
|
||||
dialog.imp().on_login_clicked();
|
||||
}
|
||||
});
|
||||
}
|
||||
let obj_weak2 = self.obj().downgrade();
|
||||
self.password_row.connect_entry_activated(move |_| {
|
||||
if let Some(dialog) = obj_weak2.upgrade() {
|
||||
dialog.imp().on_login_clicked();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl LoginDialog {
|
||||
fn on_login_clicked(&self) {
|
||||
let raw_url = self.server_url_row.text().trim().to_string();
|
||||
let username = self.username_row.text().trim().to_string();
|
||||
let password = self.password_row.text().to_string();
|
||||
|
||||
if raw_url.is_empty() || username.is_empty() || password.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepend https:// if no scheme given
|
||||
let server_url = if raw_url.starts_with("http://") || raw_url.starts_with("https://") {
|
||||
raw_url
|
||||
} else {
|
||||
format!("https://{raw_url}")
|
||||
};
|
||||
|
||||
self.obj().close();
|
||||
self.obj().emit_by_name::<()>("logged-in", &[&server_url, &username, &password]);
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for LoginDialog {}
|
||||
impl AdwDialogImpl for LoginDialog {}
|
||||
}
|
||||
27
src/main.rs
Normal file
27
src/main.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
mod api;
|
||||
mod app;
|
||||
mod cache;
|
||||
mod image_cache;
|
||||
mod pending_actions;
|
||||
mod filters;
|
||||
mod preferences_dialog;
|
||||
mod article_row;
|
||||
mod credentials;
|
||||
mod login_dialog;
|
||||
mod model;
|
||||
mod runtime;
|
||||
mod window;
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
// In development builds, point GSettings at the locally compiled schema.
|
||||
if cfg!(debug_assertions) {
|
||||
std::env::set_var("GSETTINGS_SCHEMA_DIR", env!("GSETTINGS_SCHEMA_DIR"));
|
||||
}
|
||||
|
||||
// Start the tokio multi-thread runtime before the GTK app so that
|
||||
// reqwest/hyper can find it when API futures are spawned.
|
||||
runtime::init();
|
||||
|
||||
let app = app::FeedTheMonkeyApp::new();
|
||||
app.run()
|
||||
}
|
||||
76
src/model.rs
Normal file
76
src/model.rs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Article {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub feed_title: String,
|
||||
pub author: String,
|
||||
pub link: String,
|
||||
pub published: i64,
|
||||
pub content: String,
|
||||
pub excerpt: String,
|
||||
pub unread: bool,
|
||||
}
|
||||
|
||||
// ── GObject wrapper ──────────────────────────────────────────────────────────
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct ArticleObject(ObjectSubclass<imp::ArticleObject>);
|
||||
}
|
||||
|
||||
impl ArticleObject {
|
||||
pub fn new(article: Article) -> Self {
|
||||
let obj: Self = glib::Object::new();
|
||||
*obj.imp().article.borrow_mut() = article;
|
||||
obj
|
||||
}
|
||||
|
||||
pub fn article(&self) -> std::cell::Ref<'_, Article> {
|
||||
self.imp().article.borrow()
|
||||
}
|
||||
|
||||
pub fn set_unread(&self, unread: bool) {
|
||||
self.imp().article.borrow_mut().unread = unread;
|
||||
self.notify("unread");
|
||||
}
|
||||
}
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ArticleObject {
|
||||
pub article: RefCell<Article>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for ArticleObject {
|
||||
const NAME: &'static str = "ArticleObject";
|
||||
type Type = super::ArticleObject;
|
||||
}
|
||||
|
||||
impl ObjectImpl for ArticleObject {
|
||||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
use std::sync::OnceLock;
|
||||
static PROPS: OnceLock<Vec<glib::ParamSpec>> = OnceLock::new();
|
||||
PROPS.get_or_init(|| {
|
||||
vec![
|
||||
glib::ParamSpecBoolean::builder("unread")
|
||||
.read_only()
|
||||
.build(),
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
match pspec.name() {
|
||||
"unread" => self.article.borrow().unread.to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
65
src/pending_actions.rs
Normal file
65
src/pending_actions.rs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::api::Api;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Action {
|
||||
Read,
|
||||
Unread,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct PendingAction {
|
||||
pub action: Action,
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
fn path() -> PathBuf {
|
||||
glib::user_cache_dir()
|
||||
.join("net.jeena.FeedTheMonkey")
|
||||
.join("pending_sync.json")
|
||||
}
|
||||
|
||||
fn load() -> Vec<PendingAction> {
|
||||
let Ok(data) = std::fs::read_to_string(path()) else { return Vec::new() };
|
||||
serde_json::from_str(&data).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn save(actions: &[PendingAction]) {
|
||||
let dir = path();
|
||||
std::fs::create_dir_all(dir.parent().unwrap()).ok();
|
||||
if let Ok(s) = serde_json::to_string(actions) {
|
||||
std::fs::write(path(), s).ok();
|
||||
}
|
||||
}
|
||||
|
||||
/// Queue an action for an article. If the same article already has a pending
|
||||
/// action, it is replaced with the new one (last writer wins).
|
||||
pub fn add(action: Action, id: &str) {
|
||||
let mut actions = load();
|
||||
actions.retain(|a| a.id != id);
|
||||
actions.push(PendingAction { action, id: id.to_string() });
|
||||
save(&actions);
|
||||
}
|
||||
|
||||
/// Send all queued actions to the server. Successfully synced actions are
|
||||
/// removed; failed ones remain in the queue for the next attempt.
|
||||
pub async fn flush(api: &Api, write_token: &str) {
|
||||
let actions = load();
|
||||
if actions.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut remaining = Vec::new();
|
||||
for pending in actions {
|
||||
let result = match pending.action {
|
||||
Action::Read => api.mark_read(write_token, &pending.id).await,
|
||||
Action::Unread => api.mark_unread(write_token, &pending.id).await,
|
||||
};
|
||||
if result.is_err() {
|
||||
remaining.push(pending);
|
||||
}
|
||||
}
|
||||
save(&remaining);
|
||||
}
|
||||
80
src/preferences_dialog.rs
Normal file
80
src/preferences_dialog.rs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct PreferencesDialog(ObjectSubclass<imp::PreferencesDialog>)
|
||||
@extends libadwaita::Dialog, gtk4::Widget,
|
||||
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl PreferencesDialog {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::builder().build()
|
||||
}
|
||||
}
|
||||
|
||||
pub mod imp {
|
||||
use super::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
use libadwaita::subclass::prelude::*;
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/net/jeena/FeedTheMonkey/ui/preferences_dialog.ui")]
|
||||
pub struct PreferencesDialog {
|
||||
#[template_child]
|
||||
pub cache_images_row: TemplateChild<libadwaita::SwitchRow>,
|
||||
#[template_child]
|
||||
pub filters_text_view: TemplateChild<gtk4::TextView>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for PreferencesDialog {
|
||||
const NAME: &'static str = "PreferencesDialog";
|
||||
type Type = super::PreferencesDialog;
|
||||
type ParentType = libadwaita::Dialog;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for PreferencesDialog {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
|
||||
// Cache images switch
|
||||
self.cache_images_row.set_active(settings.boolean("cache-images"));
|
||||
let s = settings.clone();
|
||||
self.cache_images_row.connect_active_notify(move |row| {
|
||||
s.set_boolean("cache-images", row.is_active()).ok();
|
||||
});
|
||||
|
||||
// Content filters text view
|
||||
self.filters_text_view.buffer().set_text(&settings.string("content-filters"));
|
||||
let obj_weak = self.obj().downgrade();
|
||||
self.filters_text_view.buffer().connect_changed(move |_| {
|
||||
if let Some(obj) = obj_weak.upgrade() {
|
||||
obj.imp().save_filters();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl PreferencesDialog {
|
||||
fn save_filters(&self) {
|
||||
let buf = self.filters_text_view.buffer();
|
||||
let text = buf.text(&buf.start_iter(), &buf.end_iter(), false);
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
settings.set_string("content-filters", &text).ok();
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for PreferencesDialog {}
|
||||
impl AdwDialogImpl for PreferencesDialog {}
|
||||
}
|
||||
50
src/runtime.rs
Normal file
50
src/runtime.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use std::sync::OnceLock;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
static RT: OnceLock<Runtime> = OnceLock::new();
|
||||
|
||||
pub fn init() {
|
||||
RT.get_or_init(|| {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("failed to build tokio runtime")
|
||||
});
|
||||
}
|
||||
|
||||
/// Spawn `future` on the tokio runtime. When it completes, `callback`
|
||||
/// is invoked on the GLib main context (GTK main thread).
|
||||
///
|
||||
/// Works by routing the result through a tokio oneshot channel; the
|
||||
/// receiving end is awaited by `glib::spawn_future_local`, which runs
|
||||
/// on the GLib event loop but does no I/O, so it never needs tokio's
|
||||
/// reactor itself.
|
||||
pub fn spawn<F, T, C>(future: F, callback: C)
|
||||
where
|
||||
F: std::future::Future<Output = T> + Send + 'static,
|
||||
T: Send + 'static,
|
||||
C: FnOnce(T) + 'static,
|
||||
{
|
||||
let (tx, rx) = tokio::sync::oneshot::channel::<T>();
|
||||
|
||||
RT.get().expect("runtime not initialised").spawn(async move {
|
||||
let result = future.await;
|
||||
let _ = tx.send(result);
|
||||
});
|
||||
|
||||
// The receive future only polls a mutex-protected flag — no I/O,
|
||||
// so running it on the GLib event loop is fine.
|
||||
glib::spawn_future_local(async move {
|
||||
if let Ok(value) = rx.await {
|
||||
callback(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Fire-and-forget: spawn on the tokio runtime, no callback.
|
||||
pub fn spawn_bg<F>(future: F)
|
||||
where
|
||||
F: std::future::Future<Output = ()> + Send + 'static,
|
||||
{
|
||||
RT.get().expect("runtime not initialised").spawn(future);
|
||||
}
|
||||
974
src/window.rs
Normal file
974
src/window.rs
Normal file
|
|
@ -0,0 +1,974 @@
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
use webkit6::prelude::{PolicyDecisionExt, WebViewExt};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct FeedTheMonkeyWindow(ObjectSubclass<imp::FeedTheMonkeyWindow>)
|
||||
@extends libadwaita::ApplicationWindow, gtk4::ApplicationWindow, gtk4::Window, gtk4::Widget,
|
||||
@implements gio::ActionGroup, gio::ActionMap, gtk4::Accessible, gtk4::Buildable,
|
||||
gtk4::ConstraintTarget, gtk4::Native, gtk4::Root, gtk4::ShortcutManager;
|
||||
}
|
||||
|
||||
impl FeedTheMonkeyWindow {
|
||||
pub fn new(app: &libadwaita::Application) -> Self {
|
||||
glib::Object::builder()
|
||||
.property("application", app)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
pub mod imp {
|
||||
use super::*;
|
||||
use crate::api::Api;
|
||||
use crate::credentials;
|
||||
use crate::login_dialog::LoginDialog;
|
||||
use crate::model::ArticleObject;
|
||||
use gtk4::CompositeTemplate;
|
||||
use libadwaita::prelude::*;
|
||||
use libadwaita::subclass::prelude::*;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/net/jeena/FeedTheMonkey/ui/window.ui")]
|
||||
pub struct FeedTheMonkeyWindow {
|
||||
#[template_child]
|
||||
pub toast_overlay: TemplateChild<libadwaita::ToastOverlay>,
|
||||
#[template_child]
|
||||
pub paned: TemplateChild<gtk4::Paned>,
|
||||
#[template_child]
|
||||
pub sidebar_toolbar: TemplateChild<libadwaita::ToolbarView>,
|
||||
#[template_child]
|
||||
pub refresh_stack: TemplateChild<gtk4::Stack>,
|
||||
#[template_child]
|
||||
pub refresh_button: TemplateChild<gtk4::Button>,
|
||||
#[template_child]
|
||||
pub article_menu_button: TemplateChild<gtk4::MenuButton>,
|
||||
#[template_child]
|
||||
pub content_refresh_stack: TemplateChild<gtk4::Stack>,
|
||||
#[template_child]
|
||||
pub content_menu_button: TemplateChild<gtk4::MenuButton>,
|
||||
#[template_child]
|
||||
pub sidebar_content: TemplateChild<gtk4::Stack>,
|
||||
#[template_child]
|
||||
pub article_list_view: TemplateChild<gtk4::ListView>,
|
||||
#[template_child]
|
||||
pub content_stack: TemplateChild<gtk4::Stack>,
|
||||
#[template_child]
|
||||
pub web_view: TemplateChild<webkit6::WebView>,
|
||||
#[template_child]
|
||||
pub error_status: TemplateChild<libadwaita::StatusPage>,
|
||||
|
||||
pub filter_rules: RefCell<Vec<crate::filters::Rule>>,
|
||||
pub api: RefCell<Option<Api>>,
|
||||
pub write_token: RefCell<Option<String>>,
|
||||
pub article_store: RefCell<Option<gio::ListStore>>,
|
||||
pub selection: RefCell<Option<gtk4::SingleSelection>>,
|
||||
pub current_article_id: RefCell<Option<String>>,
|
||||
pub mark_unread_guard: RefCell<bool>,
|
||||
pub pending_restore_id: RefCell<Option<String>>,
|
||||
pub sidebar_zoom_css: std::cell::OnceCell<gtk4::CssProvider>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for FeedTheMonkeyWindow {
|
||||
const NAME: &'static str = "FeedTheMonkeyWindow";
|
||||
type Type = super::FeedTheMonkeyWindow;
|
||||
type ParentType = libadwaita::ApplicationWindow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
klass.install_action("win.reload", None, |win, _, _| win.imp().do_reload());
|
||||
klass.install_action("win.logout", None, |win, _, _| win.imp().do_logout());
|
||||
klass.install_action("win.mark-unread", None, |win, _, _| win.imp().do_mark_unread());
|
||||
klass.install_action("win.mark-article-unread", Some(glib::VariantTy::STRING), |win, _, param| {
|
||||
if let Some(id) = param.and_then(|p| p.get::<String>()) {
|
||||
win.imp().do_mark_article_unread(id);
|
||||
}
|
||||
});
|
||||
klass.install_action("win.open-in-browser", None, |win, _, _| {
|
||||
win.imp().do_open_in_browser()
|
||||
});
|
||||
klass.install_action("win.next-article", None, |win, _, _| {
|
||||
win.imp().navigate_by(1)
|
||||
});
|
||||
klass.install_action("win.prev-article", None, |win, _, _| {
|
||||
win.imp().navigate_by(-1)
|
||||
});
|
||||
klass.install_action("win.zoom-in", None, |win, _, _| win.imp().zoom(1.1));
|
||||
klass.install_action("win.zoom-out", None, |win, _, _| win.imp().zoom(1.0 / 1.1));
|
||||
klass.install_action("win.zoom-reset", None, |win, _, _| win.imp().zoom_reset());
|
||||
klass.install_action("win.toggle-fullscreen", None, |win, _, _| {
|
||||
if win.is_fullscreen() {
|
||||
win.unfullscreen();
|
||||
} else {
|
||||
win.fullscreen();
|
||||
}
|
||||
});
|
||||
klass.install_action("win.toggle-sidebar", None, |win, _, _| {
|
||||
win.imp().do_toggle_sidebar();
|
||||
});
|
||||
klass.install_action("win.preferences", None, |win, _, _| {
|
||||
let dialog = crate::preferences_dialog::PreferencesDialog::new();
|
||||
let win_weak = win.downgrade();
|
||||
dialog.connect_closed(move |_| {
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
let imp = win.imp();
|
||||
*imp.filter_rules.borrow_mut() = crate::filters::load_rules();
|
||||
imp.reload_current_article();
|
||||
}
|
||||
});
|
||||
dialog.present(Some(win.upcast_ref::<gtk4::Widget>()));
|
||||
});
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for FeedTheMonkeyWindow {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
self.setup_window_state();
|
||||
self.setup_list();
|
||||
self.setup_webview();
|
||||
self.setup_sidebar_toggle();
|
||||
self.setup_capture_keys();
|
||||
self.restore_from_cache();
|
||||
self.auto_login();
|
||||
self.web_view.grab_focus();
|
||||
}
|
||||
}
|
||||
|
||||
impl FeedTheMonkeyWindow {
|
||||
// ── Window state ─────────────────────────────────────────────────────
|
||||
|
||||
fn setup_window_state(&self) {
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
let window = self.obj();
|
||||
window.set_title(Some("FeedTheMonkey"));
|
||||
let w = settings.int("window-width");
|
||||
let h = settings.int("window-height");
|
||||
window.set_default_size(w, h);
|
||||
if settings.boolean("window-maximized") {
|
||||
window.maximize();
|
||||
}
|
||||
|
||||
self.paned.set_position(settings.int("sidebar-width"));
|
||||
let zoom = settings.double("zoom-level");
|
||||
self.web_view.set_zoom_level(zoom);
|
||||
|
||||
// Set up sidebar font zoom CSS provider
|
||||
let zoom_css = gtk4::CssProvider::new();
|
||||
gtk4::style_context_add_provider_for_display(
|
||||
>k4::gdk::Display::default().unwrap(),
|
||||
&zoom_css,
|
||||
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
self.sidebar_zoom_css.set(zoom_css).ok();
|
||||
self.update_sidebar_zoom(zoom);
|
||||
|
||||
// Persist sidebar width while dragging; collapse when dragged too narrow.
|
||||
let s2 = settings.clone();
|
||||
let win_weak = self.obj().downgrade();
|
||||
self.paned.connect_notify_local(Some("position"), move |paned, _| {
|
||||
let Some(win) = win_weak.upgrade() else { return };
|
||||
let imp = win.imp();
|
||||
if !imp.sidebar_toolbar.is_visible() { return; }
|
||||
let pos = paned.position();
|
||||
if pos < 150 {
|
||||
// Defer so we don't change widget visibility mid-drag.
|
||||
let win_weak2 = win_weak.clone();
|
||||
glib::idle_add_local_once(move || {
|
||||
if let Some(win) = win_weak2.upgrade() {
|
||||
win.imp().set_sidebar_visible(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
s2.set_int("sidebar-width", pos).ok();
|
||||
}
|
||||
});
|
||||
|
||||
let s = settings.clone();
|
||||
window.connect_close_request(move |win| {
|
||||
if !win.is_maximized() {
|
||||
s.set_int("window-width", win.width()).ok();
|
||||
s.set_int("window-height", win.height()).ok();
|
||||
}
|
||||
s.set_boolean("window-maximized", win.is_maximized()).ok();
|
||||
glib::Propagation::Proceed
|
||||
});
|
||||
}
|
||||
|
||||
// ── List view ─────────────────────────────────────────────────────────
|
||||
|
||||
fn setup_list(&self) {
|
||||
let store = gio::ListStore::new::<ArticleObject>();
|
||||
let selection = gtk4::SingleSelection::new(Some(store.clone()));
|
||||
selection.set_autoselect(false);
|
||||
selection.set_can_unselect(true);
|
||||
*self.article_store.borrow_mut() = Some(store);
|
||||
|
||||
let factory = gtk4::SignalListItemFactory::new();
|
||||
factory.connect_setup(|_, item| {
|
||||
let item = item.downcast_ref::<gtk4::ListItem>().unwrap();
|
||||
let row = crate::article_row::ArticleRow::new();
|
||||
item.set_child(Some(&row));
|
||||
});
|
||||
factory.connect_bind(|_, item| {
|
||||
let item = item.downcast_ref::<gtk4::ListItem>().unwrap();
|
||||
if let Some(obj) = item.item().and_downcast::<ArticleObject>() {
|
||||
let row = item.child().and_downcast::<crate::article_row::ArticleRow>().unwrap();
|
||||
row.bind(&obj);
|
||||
}
|
||||
});
|
||||
factory.connect_unbind(|_, item| {
|
||||
let item = item.downcast_ref::<gtk4::ListItem>().unwrap();
|
||||
if let Some(row) = item.child().and_downcast::<crate::article_row::ArticleRow>() {
|
||||
row.unbind();
|
||||
}
|
||||
});
|
||||
|
||||
self.article_list_view.set_factory(Some(&factory));
|
||||
self.article_list_view.set_model(Some(&selection));
|
||||
|
||||
let win_weak = self.obj().downgrade();
|
||||
selection.connect_selected_item_notify(move |sel| {
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
if let Some(obj) = sel.selected_item().and_downcast::<ArticleObject>() {
|
||||
win.imp().on_article_selected(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
*self.selection.borrow_mut() = Some(selection);
|
||||
}
|
||||
|
||||
fn on_article_selected(&self, obj: ArticleObject) {
|
||||
// Mark the previous article as read — both on the server and in the
|
||||
// sidebar — now that the user has navigated away from it.
|
||||
if !*self.mark_unread_guard.borrow() {
|
||||
if let Some(prev_id) = self.current_article_id.borrow().clone() {
|
||||
if prev_id != obj.article().id {
|
||||
self.mark_read_in_list(&prev_id);
|
||||
self.bg_mark_read(prev_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
*self.mark_unread_guard.borrow_mut() = false;
|
||||
|
||||
let article = obj.article().clone();
|
||||
let same_article = self.current_article_id.borrow().as_deref() == Some(&*article.id);
|
||||
*self.current_article_id.borrow_mut() = Some(article.id.clone());
|
||||
|
||||
self.article_menu_button.set_visible(true);
|
||||
|
||||
// Skip WebView reload when re-selecting the same article (e.g. after
|
||||
// a server refresh) so the user's scroll position is preserved.
|
||||
if !same_article {
|
||||
self.load_article_in_webview(&article);
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark an article as read in the sidebar list (UI only).
|
||||
fn mark_read_in_list(&self, article_id: &str) {
|
||||
if let Some(store) = self.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == article_id {
|
||||
obj.set_unread(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn reload_current_article(&self) {
|
||||
let id = self.current_article_id.borrow().clone();
|
||||
let Some(id) = id else { return };
|
||||
if let Some(store) = self.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == id {
|
||||
self.load_article_in_webview(&obj.article().clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_article_in_webview(&self, article: &crate::model::Article) {
|
||||
let rules = self.filter_rules.borrow();
|
||||
let content = crate::filters::apply(&rules, &article.id, &article.link, &article.content);
|
||||
let json = serde_json::json!({
|
||||
"id": article.id,
|
||||
"title": article.title,
|
||||
"feed_title": article.feed_title,
|
||||
"link": article.link,
|
||||
"updated": article.published,
|
||||
"content": content,
|
||||
"author": article.author,
|
||||
"unread": article.unread,
|
||||
});
|
||||
let js = format!("window.setArticle({})", json);
|
||||
self.web_view.evaluate_javascript(&js, None, None, gio::Cancellable::NONE, |_| {});
|
||||
self.content_stack.set_visible_child_name("webview");
|
||||
}
|
||||
|
||||
// ── WebView ───────────────────────────────────────────────────────────
|
||||
|
||||
fn setup_webview(&self) {
|
||||
let wv = &*self.web_view;
|
||||
if let Some(ctx) = wv.web_context() {
|
||||
crate::image_cache::register_scheme(&ctx);
|
||||
}
|
||||
|
||||
// Load content.html from GResource, inlining the CSS so WebKit
|
||||
// doesn't need to fetch it over a custom scheme.
|
||||
let load = |path: &str| {
|
||||
String::from_utf8(
|
||||
gio::resources_lookup_data(path, gio::ResourceLookupFlags::NONE)
|
||||
.unwrap()
|
||||
.to_vec(),
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
let css = load("/net/jeena/FeedTheMonkey/html/content.css");
|
||||
let html = load("/net/jeena/FeedTheMonkey/html/content.html")
|
||||
.replace("/*INJECT_CSS*/", &css);
|
||||
wv.load_html(&html, Some("feedthemonkey://localhost/"));
|
||||
|
||||
// Apply Adwaita color scheme: set data-dark on <html> so CSS
|
||||
// custom properties (--bg, --fg, etc.) resolve to the right values.
|
||||
let style_manager = libadwaita::StyleManager::default();
|
||||
let wv_weak = wv.downgrade();
|
||||
let apply_scheme = move |sm: &libadwaita::StyleManager| {
|
||||
let is_dark = sm.is_dark();
|
||||
let js = format!("setDark({})", if is_dark { "true" } else { "false" });
|
||||
if let Some(wv) = wv_weak.upgrade() {
|
||||
wv.evaluate_javascript(&js, None, None, gio::Cancellable::NONE, |_| {});
|
||||
}
|
||||
};
|
||||
// Apply now (after load-changed fires, see below) and on every change
|
||||
let sm_clone = style_manager.clone();
|
||||
let wv_weak2 = wv.downgrade();
|
||||
let win_weak = self.obj().downgrade();
|
||||
wv.connect_load_changed(move |_, event| {
|
||||
if event == webkit6::LoadEvent::Finished {
|
||||
apply_scheme(&sm_clone);
|
||||
// Restore cached article now that window.setArticle() exists.
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
let imp = win.imp();
|
||||
if let Some(id) = imp.pending_restore_id.borrow_mut().take() {
|
||||
if let Some(store) = imp.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == id {
|
||||
let article = obj.article().clone();
|
||||
*imp.current_article_id.borrow_mut() = Some(article.id.clone());
|
||||
imp.article_menu_button.set_visible(true);
|
||||
imp.load_article_in_webview(&article);
|
||||
imp.content_stack.set_visible_child_name("webview");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let wv_weak3 = wv.downgrade();
|
||||
style_manager.connect_notify_local(Some("dark"), move |sm, _| {
|
||||
let is_dark = sm.is_dark();
|
||||
let js = format!("setDark({})", if is_dark { "true" } else { "false" });
|
||||
if let Some(wv) = wv_weak3.upgrade() {
|
||||
wv.evaluate_javascript(&js, None, None, gio::Cancellable::NONE, |_| {});
|
||||
}
|
||||
});
|
||||
let _ = wv_weak2; // suppress unused warning
|
||||
|
||||
// Disable the default WebKit context menu (right-click) — the
|
||||
// reload/inspect items don't make sense in an embedded reader.
|
||||
wv.connect_context_menu(|_, _, _| true);
|
||||
|
||||
// Handle navigation policy
|
||||
let win_weak = self.obj().downgrade();
|
||||
wv.connect_decide_policy(move |_, decision, decision_type| {
|
||||
if decision_type != webkit6::PolicyDecisionType::NavigationAction {
|
||||
return false;
|
||||
}
|
||||
let nav = decision.downcast_ref::<webkit6::NavigationPolicyDecision>().unwrap();
|
||||
let uri = nav.navigation_action()
|
||||
.and_then(|a| a.request())
|
||||
.and_then(|r| r.uri())
|
||||
.unwrap_or_default();
|
||||
|
||||
if uri.starts_with("feedthemonkey://localhost/") || uri.is_empty() {
|
||||
return false; // allow initial load
|
||||
}
|
||||
|
||||
// Handle in-page keyboard navigation commands (not user-gesture links)
|
||||
if uri.starts_with("feedthemonkey:") {
|
||||
nav.ignore();
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
match uri.as_str() {
|
||||
"feedthemonkey:previous" => win.imp().navigate_by(-1),
|
||||
"feedthemonkey:next" => win.imp().navigate_by(1),
|
||||
"feedthemonkey:open" => win.imp().do_open_in_browser(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only open external URLs in the browser when the user explicitly
|
||||
// clicked a link (NavigationType::LinkClicked). Everything else —
|
||||
// iframe/embed loads, programmatic navigation — stays in the WebView.
|
||||
let is_link_click = nav.navigation_action()
|
||||
.map(|a| a.navigation_type() == webkit6::NavigationType::LinkClicked)
|
||||
.unwrap_or(false);
|
||||
|
||||
if is_link_click {
|
||||
nav.ignore();
|
||||
open_uri(&uri);
|
||||
true
|
||||
} else {
|
||||
false // let iframes/embeds load normally
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── Sidebar toggle ────────────────────────────────────────────────────
|
||||
|
||||
fn setup_sidebar_toggle(&self) {}
|
||||
|
||||
fn do_toggle_sidebar(&self) {
|
||||
self.set_sidebar_visible(!self.sidebar_toolbar.is_visible());
|
||||
}
|
||||
|
||||
fn set_sidebar_visible(&self, visible: bool) {
|
||||
self.sidebar_toolbar.set_visible(visible);
|
||||
// Mirror refresh stack state and primary menu in the content header
|
||||
// when the sidebar is hidden, so those controls remain accessible.
|
||||
self.content_refresh_stack.set_visible(!visible);
|
||||
self.content_menu_button.set_visible(!visible);
|
||||
if visible {
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
let saved = settings.int("sidebar-width");
|
||||
self.paned.set_position(if saved > 0 { saved } else { 280 });
|
||||
}
|
||||
}
|
||||
|
||||
// ── Capture-phase key handler ─────────────────────────────────────────
|
||||
// ShortcutScope::Global doesn't reliably intercept keys when a ListView
|
||||
// has focus (the list view consumes them first). A Capture-phase
|
||||
// EventControllerKey on the window fires before any widget sees the event.
|
||||
|
||||
fn setup_capture_keys(&self) {
|
||||
let controller = gtk4::EventControllerKey::new();
|
||||
controller.set_propagation_phase(gtk4::PropagationPhase::Capture);
|
||||
let win_weak = self.obj().downgrade();
|
||||
controller.connect_key_pressed(move |_, key, _, mods| {
|
||||
use gtk4::gdk::Key;
|
||||
if !mods.is_empty() {
|
||||
return glib::Propagation::Proceed;
|
||||
}
|
||||
let Some(win) = win_weak.upgrade() else {
|
||||
return glib::Propagation::Proceed;
|
||||
};
|
||||
// Don't steal keys from text inputs (login dialog, etc.)
|
||||
let focused: Option<gtk4::Widget> = gtk4::prelude::GtkWindowExt::focus(&win);
|
||||
if focused.is_some_and(|w| {
|
||||
w.is::<gtk4::Text>() || w.is::<gtk4::Entry>() || w.is::<gtk4::SearchEntry>()
|
||||
}) {
|
||||
return glib::Propagation::Proceed;
|
||||
}
|
||||
match key {
|
||||
Key::Left | Key::k => {
|
||||
win.imp().navigate_by(-1);
|
||||
glib::Propagation::Stop
|
||||
}
|
||||
Key::Right | Key::j => {
|
||||
win.imp().navigate_by(1);
|
||||
glib::Propagation::Stop
|
||||
}
|
||||
_ => glib::Propagation::Proceed,
|
||||
}
|
||||
});
|
||||
self.obj().add_controller(controller);
|
||||
}
|
||||
|
||||
// ── Cache ─────────────────────────────────────────────────────────────
|
||||
|
||||
fn restore_from_cache(&self) {
|
||||
let Some(cache) = crate::cache::load() else { return };
|
||||
if cache.articles.is_empty() { return; }
|
||||
|
||||
let store = self.article_store.borrow();
|
||||
let store = store.as_ref().unwrap();
|
||||
|
||||
for a in &cache.articles {
|
||||
store.append(&ArticleObject::new(a.clone()));
|
||||
}
|
||||
|
||||
// Find and scroll to the previously selected item immediately so
|
||||
// the list looks right, but defer loading the article into the
|
||||
// WebView until the base HTML has finished loading (see setup_webview).
|
||||
let mut select_idx = 0u32;
|
||||
if !cache.selected_id.is_empty() {
|
||||
for i in 0..store.n_items() {
|
||||
if store.item(i).and_downcast::<ArticleObject>()
|
||||
.map(|o| o.article().id == cache.selected_id)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
select_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*self.pending_restore_id.borrow_mut() = Some(cache.selected_id);
|
||||
}
|
||||
|
||||
let sel = self.selection.borrow();
|
||||
let sel = sel.as_ref().unwrap();
|
||||
*self.mark_unread_guard.borrow_mut() = true;
|
||||
sel.set_selected(select_idx);
|
||||
self.article_list_view.scroll_to(select_idx, gtk4::ListScrollFlags::SELECT, None);
|
||||
self.sidebar_content.set_visible_child_name("list");
|
||||
}
|
||||
|
||||
fn save_cache(&self) {
|
||||
let store = self.article_store.borrow();
|
||||
let Some(store) = store.as_ref() else { return };
|
||||
let articles: Vec<crate::model::Article> = (0..store.n_items())
|
||||
.filter_map(|i| store.item(i).and_downcast::<ArticleObject>())
|
||||
.map(|o| o.article().clone())
|
||||
.collect();
|
||||
let selected_id = self.current_article_id.borrow().clone().unwrap_or_default();
|
||||
crate::cache::save(&articles, &selected_id);
|
||||
}
|
||||
|
||||
// ── Login ─────────────────────────────────────────────────────────────
|
||||
|
||||
fn auto_login(&self) {
|
||||
if let Some((server_url, username, password)) = credentials::load_credentials() {
|
||||
self.do_login(server_url, username, password, false);
|
||||
} else {
|
||||
self.show_login_dialog();
|
||||
}
|
||||
}
|
||||
|
||||
fn show_login_dialog(&self) {
|
||||
let dialog = LoginDialog::new();
|
||||
let win = self.obj();
|
||||
let win_weak = win.downgrade();
|
||||
dialog.connect_local("logged-in", false, move |args| {
|
||||
let server_url = args[1].get::<String>().unwrap();
|
||||
let username = args[2].get::<String>().unwrap();
|
||||
let password = args[3].get::<String>().unwrap();
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
win.imp().do_login(server_url, username, password, true);
|
||||
}
|
||||
None
|
||||
});
|
||||
dialog.present(Some(win.upcast_ref::<gtk4::Widget>()));
|
||||
}
|
||||
|
||||
fn do_login(&self, server_url: String, username: String, password: String, store: bool) {
|
||||
let is_auto = !store;
|
||||
let win_weak = self.obj().downgrade();
|
||||
crate::runtime::spawn(
|
||||
async move { Api::login(&server_url, &username, &password).await
|
||||
.map(|api| (api, server_url, username, password)) },
|
||||
move |result| {
|
||||
let Some(win) = win_weak.upgrade() else { return };
|
||||
match result {
|
||||
Ok((api, server_url, username, password)) => {
|
||||
if store {
|
||||
credentials::store_credentials(&server_url, &username, &password);
|
||||
}
|
||||
// Fetch write token in background (non-critical)
|
||||
let api_clone = api.clone();
|
||||
let win_weak2 = win.downgrade();
|
||||
crate::runtime::spawn(
|
||||
async move { api_clone.fetch_write_token().await },
|
||||
move |wt_result| {
|
||||
if let Some(win) = win_weak2.upgrade() {
|
||||
match wt_result {
|
||||
Ok(wt) => *win.imp().write_token.borrow_mut() = Some(wt),
|
||||
Err(e) => eprintln!("Write token error: {e}"),
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
*win.imp().api.borrow_mut() = Some(api);
|
||||
win.imp().fetch_articles();
|
||||
}
|
||||
Err(e) => {
|
||||
let has_cache = win.imp().article_store.borrow()
|
||||
.as_ref().map(|s| s.n_items() > 0).unwrap_or(false);
|
||||
if is_auto && has_cache {
|
||||
// Offline with cached articles — just show a toast.
|
||||
let toast = libadwaita::Toast::new("Offline — showing cached articles");
|
||||
win.imp().toast_overlay.add_toast(toast);
|
||||
} else {
|
||||
win.imp().show_login_dialog();
|
||||
win.imp().show_error_dialog("Login Failed", &e);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn show_error_dialog(&self, title: &str, body: &str) {
|
||||
let dialog = libadwaita::AlertDialog::new(Some(title), Some(body));
|
||||
dialog.add_response("ok", "_OK");
|
||||
dialog.set_default_response(Some("ok"));
|
||||
dialog.present(Some(self.obj().upcast_ref::<gtk4::Widget>()));
|
||||
}
|
||||
|
||||
fn do_logout(&self) {
|
||||
let win_weak = self.obj().downgrade();
|
||||
let dialog = libadwaita::AlertDialog::new(
|
||||
Some("Log Out?"),
|
||||
Some("Are you sure you want to log out?"),
|
||||
);
|
||||
dialog.add_response("cancel", "_Cancel");
|
||||
dialog.add_response("logout", "_Log Out");
|
||||
dialog.set_response_appearance("logout", libadwaita::ResponseAppearance::Destructive);
|
||||
dialog.set_default_response(Some("cancel"));
|
||||
dialog.connect_response(None, move |_, response| {
|
||||
if response == "logout" {
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
credentials::clear_credentials();
|
||||
*win.imp().api.borrow_mut() = None;
|
||||
*win.imp().write_token.borrow_mut() = None;
|
||||
if let Some(store) = win.imp().article_store.borrow().as_ref() {
|
||||
store.remove_all();
|
||||
}
|
||||
win.imp().sidebar_content.set_visible_child_name("placeholder");
|
||||
win.imp().article_menu_button.set_visible(false);
|
||||
win.imp().show_login_dialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.present(Some(self.obj().upcast_ref::<gtk4::Widget>()));
|
||||
}
|
||||
|
||||
// ── Fetch articles ────────────────────────────────────────────────────
|
||||
|
||||
fn do_reload(&self) {
|
||||
self.fetch_articles();
|
||||
}
|
||||
|
||||
fn fetch_articles(&self) {
|
||||
let api = self.api.borrow().clone();
|
||||
let Some(api) = api else { return };
|
||||
|
||||
// Reload filter rules on every refresh so edits take effect immediately.
|
||||
let filter_text = {
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
settings.string("content-filters").to_string()
|
||||
};
|
||||
*self.filter_rules.borrow_mut() = crate::filters::parse(&filter_text);
|
||||
|
||||
self.refresh_stack.set_visible_child_name("spinner");
|
||||
self.content_refresh_stack.set_visible_child_name("spinner");
|
||||
|
||||
// Only show the loading screen if there's nothing to show yet.
|
||||
let has_articles = self.article_store.borrow()
|
||||
.as_ref().map(|s| s.n_items() > 0).unwrap_or(false);
|
||||
if !has_articles {
|
||||
self.sidebar_content.set_visible_child_name("loading");
|
||||
}
|
||||
|
||||
let saved_id = self.current_article_id.borrow().clone();
|
||||
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
let cache_images = settings.boolean("cache-images")
|
||||
&& !gio::NetworkMonitor::default().is_network_metered();
|
||||
|
||||
let write_token = self.write_token.borrow().clone();
|
||||
let win_weak = self.obj().downgrade();
|
||||
crate::runtime::spawn(
|
||||
async move {
|
||||
// Flush any read/unread actions that failed to sync earlier.
|
||||
if let Some(ref wt) = write_token {
|
||||
crate::pending_actions::flush(&api, wt).await;
|
||||
}
|
||||
let articles = api.fetch_unread().await?;
|
||||
// Apply filters before image-cache processing so that rules
|
||||
// such as /thumbs/ → / rewrite the original URLs before they
|
||||
// are percent-encoded into feedthemonkey-img:// scheme URIs.
|
||||
let rules = crate::filters::parse(&filter_text);
|
||||
let articles: Vec<_> = articles
|
||||
.into_iter()
|
||||
.map(|mut a| {
|
||||
a.content = crate::filters::apply(&rules, &a.id, &a.link, &a.content);
|
||||
a
|
||||
})
|
||||
.collect();
|
||||
let articles = if cache_images {
|
||||
let processed = crate::image_cache::process(articles);
|
||||
crate::runtime::spawn_bg(crate::image_cache::prefetch(processed.clone()));
|
||||
processed
|
||||
} else {
|
||||
articles
|
||||
};
|
||||
Ok::<_, String>(articles)
|
||||
},
|
||||
move |result| {
|
||||
let Some(win) = win_weak.upgrade() else { return };
|
||||
let imp = win.imp();
|
||||
match result {
|
||||
Ok(articles) => {
|
||||
let store = imp.article_store.borrow();
|
||||
let store = store.as_ref().unwrap();
|
||||
let sel = imp.selection.borrow();
|
||||
let sel = sel.as_ref().unwrap();
|
||||
|
||||
store.remove_all();
|
||||
for a in &articles {
|
||||
store.append(&ArticleObject::new(a.clone()));
|
||||
}
|
||||
|
||||
crate::image_cache::cleanup(&articles);
|
||||
|
||||
let n = store.n_items();
|
||||
if n == 0 {
|
||||
imp.sidebar_content.set_visible_child_name("empty");
|
||||
*imp.current_article_id.borrow_mut() = None;
|
||||
imp.article_menu_button.set_visible(false);
|
||||
imp.content_stack.set_visible_child_name("empty");
|
||||
crate::cache::save(&articles, "");
|
||||
} else {
|
||||
// Try to re-select the same article the user was reading.
|
||||
let found_idx = saved_id.as_ref().and_then(|id| {
|
||||
(0..n).find(|&i| {
|
||||
store.item(i).and_downcast::<ArticleObject>()
|
||||
.map(|o| o.article().id == *id)
|
||||
.unwrap_or(false)
|
||||
})
|
||||
});
|
||||
|
||||
if let Some(idx) = found_idx {
|
||||
// Article still unread — re-select it without
|
||||
// reloading the WebView (preserves scroll position).
|
||||
*imp.mark_unread_guard.borrow_mut() = true;
|
||||
sel.set_selected(idx);
|
||||
imp.article_list_view.scroll_to(
|
||||
idx,
|
||||
gtk4::ListScrollFlags::SELECT,
|
||||
None,
|
||||
);
|
||||
crate::cache::save(&articles,
|
||||
saved_id.as_deref().unwrap_or(""));
|
||||
} else if saved_id.is_some() {
|
||||
// Article was read elsewhere — keep it in the
|
||||
// WebView so the user can finish reading but
|
||||
// leave the sidebar list unselected.
|
||||
crate::cache::save(&articles, "");
|
||||
} else {
|
||||
// No previous article (first load) — select the
|
||||
// first article.
|
||||
sel.set_selected(0);
|
||||
imp.article_list_view.scroll_to(
|
||||
0,
|
||||
gtk4::ListScrollFlags::SELECT,
|
||||
None,
|
||||
);
|
||||
crate::cache::save(&articles, "");
|
||||
}
|
||||
imp.sidebar_content.set_visible_child_name("list");
|
||||
}
|
||||
|
||||
// Always notify the user that the fetch finished.
|
||||
let msg = if n == 1 {
|
||||
String::from("1 unread article")
|
||||
} else {
|
||||
format!("{n} unread articles")
|
||||
};
|
||||
let toast = libadwaita::Toast::new(&msg);
|
||||
imp.toast_overlay.add_toast(toast);
|
||||
}
|
||||
Err(e) => {
|
||||
// If we already have cached articles, just show a toast.
|
||||
let has_articles = imp.article_store.borrow()
|
||||
.as_ref().map(|s| s.n_items() > 0).unwrap_or(false);
|
||||
if has_articles {
|
||||
let toast = libadwaita::Toast::new(&format!("Refresh failed: {e}"));
|
||||
imp.toast_overlay.add_toast(toast);
|
||||
} else {
|
||||
imp.error_status.set_description(Some(&e));
|
||||
imp.sidebar_content.set_visible_child_name("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
imp.refresh_stack.set_visible_child_name("button");
|
||||
imp.content_refresh_stack.set_visible_child_name("button");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ── Read state ────────────────────────────────────────────────────────
|
||||
|
||||
fn bg_mark_read(&self, item_id: String) {
|
||||
let api = self.api.borrow().clone();
|
||||
let wt = self.write_token.borrow().clone();
|
||||
if let (Some(api), Some(wt)) = (api, wt) {
|
||||
crate::runtime::spawn_bg(async move {
|
||||
if api.mark_read(&wt, &item_id).await.is_err() {
|
||||
crate::pending_actions::add(
|
||||
crate::pending_actions::Action::Read,
|
||||
&item_id,
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Offline or write token not yet available — queue for later.
|
||||
crate::pending_actions::add(
|
||||
crate::pending_actions::Action::Read,
|
||||
&item_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn do_mark_unread(&self) {
|
||||
let id = self.current_article_id.borrow().clone();
|
||||
let Some(id) = id else { return };
|
||||
self.do_mark_article_unread(id);
|
||||
}
|
||||
|
||||
fn do_mark_article_unread(&self, id: String) {
|
||||
// Find the ArticleObject in the store and set unread=true.
|
||||
if let Some(store) = self.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == id {
|
||||
obj.set_unread(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is the currently displayed article, guard against it
|
||||
// being immediately re-marked read when the selection fires.
|
||||
if self.current_article_id.borrow().as_deref() == Some(&*id) {
|
||||
*self.mark_unread_guard.borrow_mut() = true;
|
||||
}
|
||||
|
||||
let api = self.api.borrow().clone();
|
||||
let wt = self.write_token.borrow().clone();
|
||||
if let (Some(api), Some(wt)) = (api, wt) {
|
||||
let id_clone = id.clone();
|
||||
crate::runtime::spawn_bg(async move {
|
||||
if api.mark_unread(&wt, &id_clone).await.is_err() {
|
||||
crate::pending_actions::add(
|
||||
crate::pending_actions::Action::Unread,
|
||||
&id_clone,
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
crate::pending_actions::add(
|
||||
crate::pending_actions::Action::Unread,
|
||||
&id,
|
||||
);
|
||||
}
|
||||
|
||||
let toast = libadwaita::Toast::new("Marked as unread");
|
||||
self.toast_overlay.add_toast(toast);
|
||||
}
|
||||
|
||||
// ── Navigation ────────────────────────────────────────────────────────
|
||||
|
||||
pub fn navigate_by(&self, delta: i32) {
|
||||
let sel = self.selection.borrow();
|
||||
let Some(sel) = sel.as_ref() else { return };
|
||||
let n = sel.n_items();
|
||||
if n == 0 { return }
|
||||
let current = sel.selected();
|
||||
let next = if current == gtk4::INVALID_LIST_POSITION {
|
||||
// Nothing selected — pick the first or last article.
|
||||
if delta > 0 { 0 } else { n - 1 }
|
||||
} else if delta > 0 {
|
||||
(current + 1).min(n - 1)
|
||||
} else {
|
||||
current.saturating_sub(1)
|
||||
};
|
||||
if next != current {
|
||||
sel.set_selected(next);
|
||||
self.article_list_view.scroll_to(next, gtk4::ListScrollFlags::SELECT, None);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Open in browser ───────────────────────────────────────────────────
|
||||
|
||||
fn do_open_in_browser(&self) {
|
||||
let id = self.current_article_id.borrow().clone();
|
||||
let Some(id) = id else { return };
|
||||
if let Some(store) = self.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == id {
|
||||
let link = obj.article().link.clone();
|
||||
if !link.is_empty() {
|
||||
open_uri(&link);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Zoom ──────────────────────────────────────────────────────────────
|
||||
|
||||
fn update_sidebar_zoom(&self, level: f64) {
|
||||
if let Some(css) = self.sidebar_zoom_css.get() {
|
||||
css.load_from_string(&format!(
|
||||
".sidebar-content {{ font-size: {level}em; }}"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn zoom(&self, factor: f64) {
|
||||
let wv = &*self.web_view;
|
||||
let new_level = (wv.zoom_level() * factor).clamp(0.25, 5.0);
|
||||
wv.set_zoom_level(new_level);
|
||||
self.update_sidebar_zoom(new_level);
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
settings.set_double("zoom-level", new_level).ok();
|
||||
}
|
||||
|
||||
fn zoom_reset(&self) {
|
||||
self.web_view.set_zoom_level(1.0);
|
||||
self.update_sidebar_zoom(1.0);
|
||||
let settings = gio::Settings::new("net.jeena.FeedTheMonkey");
|
||||
settings.set_double("zoom-level", 1.0).ok();
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for FeedTheMonkeyWindow {}
|
||||
|
||||
impl WindowImpl for FeedTheMonkeyWindow {
|
||||
fn close_request(&self) -> glib::Propagation {
|
||||
self.save_cache();
|
||||
// Cancel any in-flight requests by dropping the Api
|
||||
*self.api.borrow_mut() = None;
|
||||
self.parent_close_request()
|
||||
}
|
||||
}
|
||||
|
||||
impl ApplicationWindowImpl for FeedTheMonkeyWindow {}
|
||||
impl AdwApplicationWindowImpl for FeedTheMonkeyWindow {}
|
||||
}
|
||||
|
||||
fn open_uri(uri: &str) {
|
||||
let launcher = gtk4::UriLauncher::new(uri);
|
||||
launcher.launch(gtk4::Window::NONE, gio::Cancellable::NONE, |_| {});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue