├── .editorconfig ├── .envrc ├── .github ├── assets │ ├── demo.gif │ └── demo.tape ├── dependabot.yaml └── workflows │ ├── lint.yaml │ └── release.yaml ├── .gitignore ├── .goreleaser.yaml ├── LICENSE ├── README.md ├── cmd ├── context.go ├── help.go ├── keys.go ├── load.go ├── main.go ├── modal.go ├── render.go └── view.go ├── example.toml ├── flake.lock ├── flake.nix ├── go.mod ├── go.sum ├── lib ├── config.go ├── feeds.go ├── feeds_test.go ├── fetch.go ├── helpers.go ├── logger.go ├── state.go └── style.go ├── main.go └── nix ├── default.nix ├── hm-module.nix └── shell.nix /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.github/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isabelroses/izrss/2bca52ad4b84bcaaddc9a4b09e10e0601f9264d3/.github/assets/demo.gif -------------------------------------------------------------------------------- /.github/assets/demo.tape: -------------------------------------------------------------------------------- 1 | Output demo.gif 2 | 3 | Require echo 4 | 5 | Set Shell "fish" 6 | Set Width 1920 7 | Set Height 1080 8 | Set CursorBlink false 9 | Set Theme "Catppuccin Mocha" 10 | 11 | Set TypingSpeed 200ms 12 | Sleep 500ms 13 | Type "izrss" 14 | Set TypingSpeed 1s 15 | Sleep 500ms 16 | Enter 17 | Sleep 500ms 18 | Type "?" 19 | Sleep 500ms 20 | Enter 21 | Sleep 500ms 22 | Down 4 23 | Type "x" 24 | Sleep 1s 25 | Enter 26 | Sleep 1.5s 27 | Down 15 28 | Type "q" 29 | Sleep 5s 30 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: github-actions 5 | directory: "/" 6 | schedule: 7 | interval: weekly 8 | 9 | - package-ecosystem: gomod 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | open-pull-requests-limit: 10 14 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: lint 2 | 3 | on: 4 | push: 5 | paths: 6 | - '**.go' 7 | pull_request: 8 | paths: 9 | - '**.go' 10 | 11 | jobs: 12 | lint: 13 | name: lint 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | 22 | - uses: actions/setup-go@v5 23 | with: 24 | go-version: stable 25 | 26 | - name: golangci-lint 27 | uses: golangci/golangci-lint-action@v6 28 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: releaser 2 | 3 | permissions: 4 | contents: write 5 | 6 | on: 7 | push: 8 | tags: 9 | - "*" 10 | 11 | jobs: 12 | goreleaser: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | with: 19 | fetch-depth: 0 20 | 21 | - name: Set up Go 22 | uses: actions/setup-go@v5 23 | with: 24 | go-version: stable 25 | 26 | - name: Run GoReleaser 27 | uses: goreleaser/goreleaser-action@v6 28 | with: 29 | distribution: goreleaser 30 | version: latest 31 | args: release --clean 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | vendor 3 | izrss 4 | -------------------------------------------------------------------------------- /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | before: 4 | hooks: 5 | - go mod tidy 6 | 7 | builds: 8 | - env: 9 | - CGO_ENABLED=0 10 | goos: 11 | - linux 12 | - windows 13 | - darwin 14 | ldflags: 15 | - -s -w -X main.Version={{ .Version }} -X main.builtBy=goreleaser 16 | 17 | archives: 18 | - formats: binary 19 | name_template: >- 20 | {{ .ProjectName }}_ 21 | {{- .Version }}_ 22 | {{- title .Os }}_ 23 | {{- if eq .Arch "amd64" }}x86_64 24 | {{- else if eq .Arch "386" }}i386 25 | {{- else }}{{ .Arch }}{{ end }} 26 | {{- if .Arm }}v{{ .Arm }}{{ end }} 27 | 28 | changelog: 29 | use: github 30 | sort: asc 31 | groups: 32 | - title: Features 33 | regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' 34 | order: 0 35 | - title: Preformance Improvements 36 | regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$' 37 | order: 1 38 | - title: "Fixes" 39 | regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' 40 | order: 2 41 | - title: Others 42 | order: 999 43 | filters: 44 | exclude: 45 | - typos 46 | # yaml-language-server: $schema=https://goreleaser.com/static/schema.json 47 | # vim: set ts=2 sw=2 tw=0 fo=cnqoj 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

izrss

3 | 4 |

An RSS feed reader for the terminal.

5 |
6 | 7 |   8 | 9 | ![demo](./.github/assets/demo.gif) 10 | 11 | ### Usage & Customization 12 | 13 | The main bulk of customization is done via the `~/.config/izrss/config.toml` file. You can find an example file here [config.toml](./example.toml). 14 | 15 | The rest of the config is done via using the environment variables `GLAMOUR_STYLE`. 16 | For a good example see: [catppuccin/glamour](https://github.com/catppuccin/glamour) 17 | 18 | Then run `izrss` to read the feeds. 19 | 20 | ### Installation 21 | 22 |
23 | 24 | 25 | 26 | #### With Nix flakes and home-manager 27 | 28 | 29 | 30 | ```nix 31 | { 32 | inputs = { 33 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 34 | 35 | home-manager = { 36 | url = "github:nix-community/home-manager"; 37 | inputs.nixpkgs.follows = "nixpkgs"; 38 | }; 39 | 40 | izrss.url = "github:isabelroses/izrss"; 41 | }; 42 | 43 | outputs = { self, nixpkgs, home-manager, izrss }: { 44 | homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration { 45 | modules = [ 46 | home-manager.homeManagerModules.default 47 | izrss.homeManagerModules.default 48 | { 49 | programs.izrss = { 50 | enable = true; 51 | settings.urls = [ 52 | "https://isabelroses.com/rss.xml" 53 | "https://uncenter.dev/feed.xml" 54 | ]; 55 | }; 56 | } 57 | ]; 58 | }; 59 | } 60 | } 61 | ``` 62 | 63 |
64 | 65 |
66 | 67 | 68 | 69 | #### With Nix flakes 70 | 71 | 72 | 73 | ```nix 74 | { 75 | inputs = { 76 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 77 | izrss.url = "github:isabelroses/izrss"; 78 | }; 79 | 80 | outputs = { self, nixpkgs, izrss }: { 81 | nixosConfigurations.example = nixpkgs.lib.nixosSystem { 82 | system = "x86_64-linux"; 83 | modules = [{ 84 | environment.systemPackages = [ 85 | inputs.izrss.packages.${pkgs.system}.default 86 | ]; 87 | }]; 88 | }; 89 | } 90 | } 91 | ``` 92 | 93 |
94 | -------------------------------------------------------------------------------- /cmd/context.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/isabelroses/izrss/lib" 5 | ) 6 | 7 | type context struct { 8 | prev string 9 | curr string 10 | feeds lib.Feeds 11 | post lib.Post 12 | feed lib.Feed 13 | } 14 | 15 | func (m *Model) swapPage(next string) { 16 | m.context.prev = m.context.curr 17 | m.context.curr = next 18 | if m.context.prev == "reader" { 19 | m.viewport.Height = m.viewport.Height + 2 20 | } 21 | } 22 | 23 | func (m *Model) SetFeeds(feeds lib.Feeds) { 24 | m.context.feeds = feeds 25 | } 26 | -------------------------------------------------------------------------------- /cmd/help.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | // modified from https://github.com/charmbracelet/bubbles/blob/master/help/help.go 4 | // I did this so it would be easier to pass context to the help model 5 | 6 | import ( 7 | "strings" 8 | 9 | "github.com/charmbracelet/bubbles/key" 10 | tea "github.com/charmbracelet/bubbletea" 11 | "github.com/charmbracelet/lipgloss" 12 | "github.com/isabelroses/izrss/lib" 13 | ) 14 | 15 | // KeyMap is a map of keybindings used to generate help. Since it's an 16 | // interface it can be any type, though struct or a map[string][]key.Binding 17 | // are likely candidates. 18 | // 19 | // Note that if a key is disabled (via key.Binding.SetEnabled) it will not be 20 | // rendered in the help view, so in theory generated help should self-manage. 21 | type KeyMap interface { 22 | // ShortHelp returns a slice of bindings to be displayed in the short 23 | // version of the help. The help bubble will render help in the order in 24 | // which the help items are returned here. 25 | ShortHelp(m Model) []key.Binding 26 | 27 | // FullHelp returns an extended group of help items, grouped by columns. 28 | // The help bubble will render the help in the order in which the help 29 | // items are returned here. 30 | FullHelp(m Model) [][]key.Binding 31 | } 32 | 33 | // KeyModel contains the state of the help view. 34 | type KeyModel struct { 35 | Style lipgloss.Style 36 | ShortSeparator string 37 | FullSeparator string 38 | Ellipsis string 39 | Width int 40 | ShowAll bool 41 | } 42 | 43 | // New creates a new help view with some useful defaults. 44 | func NewHelp() KeyModel { 45 | return KeyModel{ 46 | ShortSeparator: " • ", 47 | FullSeparator: " • ", 48 | Ellipsis: "…", 49 | Style: lib.HelpStyle, 50 | } 51 | } 52 | 53 | // Update helps satisfy the Bubble Tea Model interface. It's a no-op. 54 | func (m KeyModel) Update(_ tea.Msg) (KeyModel, tea.Cmd) { 55 | return m, nil 56 | } 57 | 58 | // View renders the help view's current state. 59 | func (km KeyModel) View(k KeyMap, m Model) string { 60 | if km.ShowAll { 61 | return km.FullHelpView(k.FullHelp(m)) 62 | } 63 | return km.ShortHelpView(k.ShortHelp(m)) 64 | } 65 | 66 | // ShortHelpView renders a single line help view from a slice of keybindings. 67 | // If the line is longer than the maximum width it will be gracefully 68 | // truncated, showing only as many help items as possible. 69 | func (m KeyModel) ShortHelpView(bindings []key.Binding) string { 70 | if len(bindings) == 0 { 71 | return "" 72 | } 73 | 74 | var b strings.Builder 75 | var totalWidth int 76 | separator := m.Style.Inline(true).Render(m.ShortSeparator) 77 | 78 | for i, kb := range bindings { 79 | if !kb.Enabled() { 80 | continue 81 | } 82 | 83 | var sep string 84 | if totalWidth > 0 && i < len(bindings) { 85 | sep = separator 86 | } 87 | 88 | str := sep + 89 | m.Style.Inline(true).Render(kb.Help().Key) + " " + 90 | m.Style.Inline(true).Render(kb.Help().Desc) 91 | 92 | w := lipgloss.Width(str) 93 | 94 | // If adding this help item would go over the available width, stop 95 | // drawing. 96 | if m.Width > 0 && totalWidth+w > m.Width { 97 | // Although if there's room for an ellipsis, print that. 98 | tail := " " + m.Style.Inline(true).Render(m.Ellipsis) 99 | tailWidth := lipgloss.Width(tail) 100 | 101 | if totalWidth+tailWidth < m.Width { 102 | b.WriteString(tail) 103 | } 104 | 105 | break 106 | } 107 | 108 | totalWidth += w 109 | b.WriteString(str) 110 | } 111 | 112 | return b.String() 113 | } 114 | 115 | // FullHelpView renders help columns from a slice of key binding slices. Each 116 | // top level slice entry renders into a column. 117 | func (m KeyModel) FullHelpView(groups [][]key.Binding) string { 118 | if len(groups) == 0 { 119 | return "" 120 | } 121 | 122 | // Linter note: at this time we don't think it's worth the additional 123 | // code complexity involved in preallocating this slice. 124 | //nolint:prealloc 125 | var ( 126 | out []string 127 | 128 | totalWidth int 129 | sep = m.Style.Render(m.FullSeparator) 130 | sepWidth = lipgloss.Width(sep) 131 | ) 132 | 133 | // Iterate over groups to build columns 134 | for i, group := range groups { 135 | if group == nil || !shouldRenderColumn(group) { 136 | continue 137 | } 138 | 139 | var ( 140 | keys []string 141 | descriptions []string 142 | ) 143 | 144 | // Separate keys and descriptions into different slices 145 | for _, kb := range group { 146 | if !kb.Enabled() { 147 | continue 148 | } 149 | keys = append(keys, kb.Help().Key) 150 | descriptions = append(descriptions, kb.Help().Desc) 151 | } 152 | 153 | col := lipgloss.JoinHorizontal(lipgloss.Top, 154 | m.Style.Render(strings.Join(keys, "\n")), 155 | m.Style.Render(" "), 156 | m.Style.Render(strings.Join(descriptions, "\n")), 157 | ) 158 | 159 | // Column 160 | totalWidth += lipgloss.Width(col) 161 | if m.Width > 0 && totalWidth > m.Width { 162 | break 163 | } 164 | 165 | out = append(out, col) 166 | 167 | // Separator 168 | if i < len(group)-1 { 169 | totalWidth += sepWidth 170 | if m.Width > 0 && totalWidth > m.Width { 171 | break 172 | } 173 | out = append(out, sep) 174 | } 175 | } 176 | 177 | return lipgloss.JoinHorizontal(lipgloss.Top, out...) 178 | } 179 | 180 | func shouldRenderColumn(b []key.Binding) (ok bool) { 181 | for _, v := range b { 182 | if v.Enabled() { 183 | return true 184 | } 185 | } 186 | return false 187 | } 188 | -------------------------------------------------------------------------------- /cmd/keys.go: -------------------------------------------------------------------------------- 1 | // Package cmd contains all the command functions 2 | package cmd 3 | 4 | import ( 5 | "log" 6 | 7 | "github.com/charmbracelet/bubbles/key" 8 | tea "github.com/charmbracelet/bubbletea" 9 | "github.com/charmbracelet/lipgloss" 10 | 11 | "github.com/isabelroses/izrss/lib" 12 | ) 13 | 14 | type keyMap struct { 15 | Up key.Binding 16 | Down key.Binding 17 | JumpUp key.Binding 18 | JumpDown key.Binding 19 | Back key.Binding 20 | Help key.Binding 21 | Quit key.Binding 22 | Open key.Binding 23 | Refresh key.Binding 24 | RefreshAll key.Binding 25 | Search key.Binding 26 | ToggleRead key.Binding 27 | ReadAll key.Binding 28 | } 29 | 30 | func (k keyMap) ShortHelp(m Model) []key.Binding { 31 | var help []key.Binding 32 | 33 | if m.context.curr == "reader" { 34 | help = []key.Binding{k.Open, k.ToggleRead, k.Quit} 35 | } else { 36 | help = []key.Binding{k.Help, k.Quit} 37 | } 38 | 39 | return help 40 | } 41 | 42 | func (k keyMap) FullHelp(m Model) [][]key.Binding { 43 | var help [][]key.Binding 44 | 45 | switch m.context.curr { 46 | case "home": 47 | help = [][]key.Binding{ 48 | {k.Up, k.Down}, 49 | {k.JumpUp, k.JumpDown}, 50 | {k.Back, k.Open}, 51 | {k.Search, k.ReadAll}, 52 | {k.Refresh, k.RefreshAll}, 53 | {k.Help, k.Quit}, 54 | } 55 | case "content": 56 | help = [][]key.Binding{ 57 | {k.Up, k.Down}, 58 | {k.JumpUp, k.JumpDown}, 59 | {k.Back, k.Open}, 60 | {k.Search}, 61 | {k.Refresh, k.RefreshAll}, 62 | {k.ToggleRead, k.ReadAll}, 63 | {k.Help, k.Quit}, 64 | } 65 | case "mixed": 66 | help = [][]key.Binding{ 67 | {k.Up, k.Down}, 68 | {k.JumpUp, k.JumpDown}, 69 | {k.Back, k.Open}, 70 | {k.Search, k.ToggleRead}, 71 | // {k.Refresh, k.RefreshAll}, 72 | {k.Help, k.Quit}, 73 | } 74 | case "reader": 75 | help = [][]key.Binding{} 76 | } 77 | 78 | return help 79 | } 80 | 81 | // TODO: refator this so its per page and not global 82 | func (m Model) handleKeys(msg tea.KeyMsg) (Model, tea.Cmd) { 83 | // handle page specific keys 84 | switch m.context.curr { 85 | case "home": 86 | switch { 87 | case key.Matches(msg, m.keys.Open): 88 | m.loadContent(m.table.Cursor()) 89 | m.table.SetCursor(0) 90 | m.viewport.SetYOffset(0) 91 | 92 | case key.Matches(msg, m.keys.Refresh): 93 | id := m.table.Cursor() 94 | feed := &m.context.feeds[id] 95 | lib.FetchURL(feed.URL, false) 96 | feed.Posts = lib.GetPosts(feed.URL) 97 | err := m.context.feeds.ReadTracking() 98 | if err != nil { 99 | log.Fatal(err) 100 | } 101 | m.loadHome() 102 | m.table.MoveDown(id) 103 | 104 | case key.Matches(msg, m.keys.RefreshAll): 105 | m.context.feeds = lib.GetAllContent(lib.UserConfig.Urls, false) 106 | err := m.context.feeds.ReadTracking() 107 | if err != nil { 108 | log.Fatal(err) 109 | } 110 | m.loadHome() 111 | 112 | case key.Matches(msg, m.keys.ReadAll): 113 | lib.ReadAll(m.context.feeds, m.table.Cursor()) 114 | m.loadHome() 115 | err := m.context.feeds.WriteTracking() 116 | if err != nil { 117 | log.Fatalf("Could not write tracking data: %s", err) 118 | } 119 | } 120 | 121 | case "content": 122 | switch { 123 | case key.Matches(msg, m.keys.Refresh): 124 | feed := &m.context.feed 125 | feed.Posts = lib.GetPosts(feed.URL) 126 | err := m.context.feeds.ReadTracking() 127 | if err != nil { 128 | log.Fatal(err) 129 | } 130 | m.loadContent(m.context.feed.ID) 131 | 132 | case key.Matches(msg, m.keys.Back): 133 | m.loadHome() 134 | m.table.SetCursor(m.context.feed.ID) 135 | m.viewport.SetYOffset(0) 136 | 137 | case key.Matches(msg, m.keys.Open): 138 | m.loadReader() 139 | 140 | case key.Matches(msg, m.keys.ToggleRead): 141 | lib.ToggleRead(m.context.feeds, m.context.feed.ID, m.table.Cursor()) 142 | m.loadContent(m.context.feed.ID) 143 | err := m.context.feeds.WriteTracking() 144 | if err != nil { 145 | log.Fatalf("Could not write tracking data: %s", err) 146 | } 147 | 148 | case key.Matches(msg, m.keys.ReadAll): 149 | lib.ReadAll(m.context.feeds, m.context.feed.ID) 150 | m.loadContent(m.context.feed.ID) 151 | err := m.context.feeds.WriteTracking() 152 | if err != nil { 153 | log.Fatalf("Could not write tracking data: %s", err) 154 | } 155 | } 156 | 157 | case "mixed": 158 | switch { 159 | case key.Matches(msg, m.keys.Open): 160 | m.loadReader() 161 | 162 | case key.Matches(msg, m.keys.ToggleRead): 163 | lib.ToggleRead(m.context.feeds, m.context.feed.ID, m.table.Cursor()) 164 | m.loadMixed() 165 | err := m.context.feeds.WriteTracking() 166 | if err != nil { 167 | log.Fatalf("Could not write tracking data: %s", err) 168 | } 169 | 170 | case key.Matches(msg, m.keys.ReadAll): 171 | lib.ReadAll(m.context.feeds, m.context.feed.ID) 172 | m.loadMixed() 173 | err := m.context.feeds.WriteTracking() 174 | if err != nil { 175 | log.Fatalf("Could not write tracking data: %s", err) 176 | } 177 | } 178 | 179 | case "reader": 180 | switch { 181 | case key.Matches(msg, m.keys.Back): 182 | if m.context.prev == "mixed" { 183 | m.loadMixed() 184 | } else { 185 | m.loadContent(m.context.feed.ID) 186 | } 187 | m.table.SetCursor(m.context.post.ID) 188 | m.viewport.SetYOffset(0) 189 | 190 | case key.Matches(msg, m.keys.Open): 191 | err := lib.OpenURL(m.context.post.Link) 192 | if err != nil { 193 | log.Panic(err) 194 | } 195 | 196 | case key.Matches(msg, m.keys.ToggleRead): 197 | lib.ToggleRead(m.context.feeds, m.context.feed.ID, m.context.post.ID) 198 | m.loadContent(m.context.feed.ID) 199 | err := m.context.feeds.WriteTracking() 200 | if err != nil { 201 | log.Fatalf("Could not write tracking data: %s", err) 202 | } 203 | } 204 | 205 | case "search": 206 | switch msg.String() { 207 | case "enter": 208 | m.loadSearchValues() 209 | 210 | case "ctrl+c", "esc", "/": 211 | m.loadContent(m.table.Cursor()) 212 | m.table.Focus() 213 | m.filter.Blur() 214 | } 215 | } 216 | 217 | // handle global keys 218 | switch { 219 | case key.Matches(msg, m.keys.JumpUp): 220 | m.table.MoveUp(5) 221 | case key.Matches(msg, m.keys.JumpDown): 222 | m.table.MoveDown(5) 223 | 224 | case key.Matches(msg, m.keys.Search): 225 | if m.context.curr != "search" { 226 | m.loadSearch() 227 | } 228 | 229 | case key.Matches(msg, m.keys.Help): 230 | m.help.ShowAll = !m.help.ShowAll 231 | m.table.SetHeight(m.viewport.Height - lipgloss.Height(m.help.View(m.keys, m))) 232 | 233 | case key.Matches(msg, m.keys.Quit): 234 | err := m.context.feeds.WriteTracking() 235 | if err != nil { 236 | log.Fatalf("Could not write tracking data: %s", err) 237 | } 238 | return m, tea.Quit 239 | } 240 | 241 | return m, nil 242 | } 243 | 244 | var keys = keyMap{ 245 | Up: key.NewBinding( 246 | key.WithKeys("up", "k"), 247 | key.WithHelp("↑/k", "move up"), 248 | ), 249 | Down: key.NewBinding( 250 | key.WithKeys("down", "j"), 251 | key.WithHelp("↓/j", "move down"), 252 | ), 253 | JumpUp: key.NewBinding( 254 | key.WithKeys("shift+up", "K"), 255 | key.WithHelp("↑/k", "jump move up"), 256 | ), 257 | JumpDown: key.NewBinding( 258 | key.WithKeys("shift+down", "J"), 259 | key.WithHelp("↓/j", "jump move down"), 260 | ), 261 | Back: key.NewBinding( 262 | key.WithKeys("left", "h", "shift+tab"), 263 | key.WithHelp("←/h", "back"), 264 | ), 265 | Open: key.NewBinding( 266 | key.WithKeys("enter", "o", "right", "l", "tab"), 267 | key.WithHelp("o/enter", "open"), 268 | ), 269 | Help: key.NewBinding( 270 | key.WithKeys("?"), 271 | key.WithHelp("?", "toggle help"), 272 | ), 273 | Quit: key.NewBinding( 274 | key.WithKeys("q", "esc", "ctrl+c"), 275 | key.WithHelp("q/esc", "quit"), 276 | ), 277 | Refresh: key.NewBinding( 278 | key.WithKeys("r"), 279 | key.WithHelp("r", "refresh"), 280 | ), 281 | RefreshAll: key.NewBinding( 282 | key.WithKeys("R"), 283 | key.WithHelp("R", "refresh all"), 284 | ), 285 | Search: key.NewBinding( 286 | key.WithKeys("/"), 287 | key.WithHelp("/", "search"), 288 | ), 289 | ToggleRead: key.NewBinding( 290 | key.WithKeys("x"), 291 | key.WithHelp("x", "toggle read"), 292 | ), 293 | ReadAll: key.NewBinding( 294 | key.WithKeys("X"), 295 | key.WithHelp("X", "mark all as read"), 296 | ), 297 | } 298 | -------------------------------------------------------------------------------- /cmd/load.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strconv" 7 | "strings" 8 | 9 | "github.com/charmbracelet/bubbles/table" 10 | 11 | "github.com/isabelroses/izrss/lib" 12 | ) 13 | 14 | // load the home view, this conists of the list of feeds 15 | func (m *Model) loadHome() { 16 | columns := []table.Column{ 17 | {Title: "Unread", Width: 10}, 18 | {Title: "Title", Width: m.table.Width() - 10}, 19 | } 20 | 21 | rows := []table.Row{} 22 | for _, Feed := range m.context.feeds { 23 | totalUnread := strconv.Itoa(Feed.GetTotalUnreads()) 24 | fraction := fmt.Sprintf("%s/%d", totalUnread, len(Feed.Posts)) 25 | rows = append(rows, table.Row{fraction, Feed.Title}) 26 | } 27 | 28 | m.swapPage("home") 29 | m.loadNewTable(columns, rows) 30 | } 31 | 32 | func (m *Model) loadMixed() { 33 | columns := []table.Column{ 34 | {Title: "", Width: 2}, 35 | {Title: "Date", Width: 15}, 36 | {Title: "Title", Width: m.table.Width() - 17}, 37 | } 38 | 39 | posts := []lib.Post{} 40 | for _, feed := range m.context.feeds { 41 | posts = append(posts, feed.Posts...) 42 | } 43 | 44 | err := lib.SortPosts(posts) 45 | if err != nil { 46 | log.Printf("Failed to sort %s", err) 47 | } 48 | 49 | rows := make([]table.Row, len(posts)) 50 | for i, post := range posts { 51 | read := lib.ReadSymbol(post.Read) 52 | rows[i] = table.Row{read, post.Date, post.Title} 53 | } 54 | 55 | m.context.feed = lib.Feed{Title: "Mixed", Posts: posts, ID: 0, URL: ""} 56 | 57 | m.loadNewTable(columns, rows) 58 | m.swapPage("mixed") 59 | } 60 | 61 | func (m *Model) loadContent(id int) { 62 | feed := m.context.feeds[id] 63 | feed.ID = id 64 | 65 | columns := []table.Column{ 66 | {Title: "", Width: 2}, 67 | {Title: "Date", Width: 15}, 68 | {Title: "Title", Width: m.table.Width() - 17}, 69 | } 70 | 71 | rows := []table.Row{} 72 | for _, post := range feed.Posts { 73 | readsym := lib.ReadSymbol(post.Read) 74 | rows = append(rows, table.Row{readsym, post.Date, post.Title}) 75 | } 76 | 77 | m.loadNewTable(columns, rows) 78 | m.swapPage("content") 79 | m.context.feed = feed 80 | } 81 | 82 | func (m *Model) loadSearch() { 83 | m.swapPage("search") 84 | 85 | m.table.Blur() 86 | 87 | m.filter.Focus() 88 | m.filter.SetValue("") 89 | } 90 | 91 | func (m Model) loadSearchValues() { 92 | search := m.filter.Value() 93 | 94 | var filteredPosts []lib.Post 95 | rows := []table.Row{} 96 | 97 | for _, feed := range m.context.feeds { 98 | for _, post := range feed.Posts { 99 | if strings.Contains(strings.ToLower(post.Content), strings.ToLower(search)) { 100 | filteredPosts = append(filteredPosts, post) 101 | rows = append(rows, table.Row{post.Date, post.Title}) 102 | } 103 | } 104 | } 105 | 106 | columns := []table.Column{ 107 | {Title: "Date", Width: 15}, 108 | {Title: "Title", Width: m.table.Width() - 15}, 109 | } 110 | 111 | m.loadNewTable(columns, rows) 112 | m.swapPage("content") 113 | m.context.feed.Posts = filteredPosts 114 | m.table.Focus() 115 | m.filter.Blur() 116 | m.table.SetCursor(0) 117 | } 118 | 119 | func (m *Model) loadNewTable(columns []table.Column, rows []table.Row) { 120 | t := &m.table 121 | 122 | // NOTE: clear the rows first to prevent panic 123 | t.SetRows([]table.Row{}) 124 | 125 | t.SetColumns(columns) 126 | t.SetRows(rows) 127 | } 128 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "log" 5 | "sync" 6 | 7 | "github.com/charmbracelet/bubbles/viewport" 8 | tea "github.com/charmbracelet/bubbletea" 9 | "github.com/charmbracelet/glamour" 10 | "github.com/charmbracelet/lipgloss" 11 | 12 | "github.com/isabelroses/izrss/lib" 13 | ) 14 | 15 | // Update will regnerate the model on each run 16 | func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { 17 | var ( 18 | cmd tea.Cmd 19 | cmds []tea.Cmd 20 | ) 21 | 22 | switch msg := msg.(type) { 23 | case tea.WindowSizeMsg: 24 | m = m.handleWindowSize(msg) 25 | case tea.KeyMsg: 26 | m, cmd = m.handleKeys(msg) 27 | cmds = append(cmds, cmd) 28 | } 29 | 30 | m, cmd = m.updateViewport(msg) 31 | cmds = append(cmds, cmd) 32 | 33 | return m, tea.Batch(cmds...) 34 | } 35 | 36 | func (m Model) handleWindowSize(msg tea.WindowSizeMsg) Model { 37 | framew, frameh := lib.MainStyle.GetFrameSize() 38 | 39 | height := msg.Height - frameh 40 | width := msg.Width - framew 41 | 42 | m.table.SetWidth(width) 43 | m.table.SetHeight(height - lipgloss.Height(m.help.View(m.keys, m))) 44 | 45 | if !m.ready { 46 | m.viewport = viewport.New(width, height) 47 | 48 | // we make this part mutli-threaded otherwise its really slow 49 | var wg sync.WaitGroup 50 | wg.Add(1) 51 | go func() { 52 | defer wg.Done() 53 | var glamWidth glamour.TermRendererOption 54 | switch lib.UserConfig.Reader.Size.(type) { 55 | case string: 56 | switch lib.UserConfig.Reader.Size { 57 | case "full", "fullscreen": 58 | glamWidth = glamour.WithWordWrap(width) 59 | case "most": 60 | glamWidth = glamour.WithWordWrap(int(float64(width) * 0.75)) 61 | case "recomended": 62 | glamWidth = glamour.WithWordWrap(80) 63 | } 64 | 65 | case int64: 66 | w := int(lib.UserConfig.Reader.Size.(int64)) 67 | glamWidth = glamour.WithWordWrap(w) 68 | default: 69 | log.Fatalf("invalid reader size: %v", lib.UserConfig.Reader.Size) 70 | } 71 | 72 | var glamTheme glamour.TermRendererOption 73 | if lib.UserConfig.Reader.Theme == "environment" { 74 | glamTheme = glamour.WithEnvironmentConfig() 75 | } else if lib.UserConfig.Reader.Theme != "" { 76 | glamTheme = glamour.WithStylePath(lib.UserConfig.Reader.Theme) 77 | } else { 78 | glamTheme = glamour.WithAutoStyle() 79 | } 80 | 81 | m.glam, _ = glamour.NewTermRenderer( 82 | glamTheme, 83 | glamWidth, 84 | glamour.WithChromaFormatter("terminal256"), 85 | ) 86 | }() 87 | 88 | if lib.UserConfig.Home == "mixed" { 89 | m.loadMixed() 90 | } else { 91 | m.loadHome() 92 | } 93 | 94 | wg.Wait() 95 | m.ready = true 96 | } else { 97 | m.viewport.Width = width 98 | m.viewport.Height = height 99 | } 100 | 101 | return m 102 | } 103 | 104 | func (m Model) updateViewport(msg tea.Msg) (Model, tea.Cmd) { 105 | var ( 106 | cmd tea.Cmd 107 | cmds []tea.Cmd 108 | ) 109 | 110 | m.help, cmd = m.help.Update(msg) 111 | cmds = append(cmds, cmd) 112 | m.table, cmd = m.table.Update(msg) 113 | cmds = append(cmds, cmd) 114 | 115 | if m.context.curr != "reader" && m.context.curr != "search" { 116 | view := lipgloss.JoinVertical( 117 | lipgloss.Top, 118 | m.table.View(), 119 | m.help.View(m.keys, m), 120 | ) 121 | m.viewport.SetContent(view) 122 | } else if m.context.curr == "search" { 123 | m.filter, cmd = m.filter.Update(msg) 124 | cmds = append(cmds, cmd) 125 | 126 | view := lipgloss.JoinVertical( 127 | lipgloss.Top, 128 | m.filter.View(), 129 | m.table.View(), 130 | m.help.View(m.keys, m), 131 | ) 132 | 133 | m.viewport.SetContent(view) 134 | } 135 | 136 | // HACK: if the previous was mixed we never marked the post as read 137 | if m.context.curr == "reader" && m.context.prev == "mixed" && m.viewport.ScrollPercent() >= lib.UserConfig.Reader.ReadThreshold { 138 | lib.MarkRead(m.context.feeds, m.context.feed.ID, m.context.post.ID) 139 | } 140 | 141 | m.viewport, cmd = m.viewport.Update(msg) 142 | cmds = append(cmds, cmd) 143 | 144 | return m, tea.Batch(cmds...) 145 | } 146 | -------------------------------------------------------------------------------- /cmd/modal.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/charmbracelet/bubbles/table" 5 | "github.com/charmbracelet/bubbles/textinput" 6 | "github.com/charmbracelet/bubbles/viewport" 7 | tea "github.com/charmbracelet/bubbletea" 8 | "github.com/charmbracelet/glamour" 9 | "github.com/charmbracelet/lipgloss" 10 | 11 | "github.com/isabelroses/izrss/lib" 12 | ) 13 | 14 | // Model is the main model for the application 15 | type Model struct { 16 | help KeyModel 17 | keys keyMap 18 | glam *glamour.TermRenderer 19 | context context 20 | viewport viewport.Model 21 | filter textinput.Model 22 | table table.Model 23 | ready bool 24 | } 25 | 26 | // Init sets the initial state of the model 27 | func (m Model) Init() tea.Cmd { 28 | lib.SetupLogger() 29 | 30 | return tea.Batch( 31 | tea.SetWindowTitle("izrss"), 32 | ) 33 | } 34 | 35 | // NewModel creates a new model with sensible defaults 36 | func NewModel() Model { 37 | t := table.New(table.WithFocused(true)) 38 | t.SetStyles(lib.TableStyle()) 39 | 40 | f := textinput.New() 41 | f.Prompt = "Filter: " 42 | f.PromptStyle = lipgloss.NewStyle(). 43 | Bold(true). 44 | Foreground(lipgloss.Color("229")) 45 | 46 | return Model{ 47 | context: context{}, 48 | viewport: viewport.Model{}, 49 | table: t, 50 | ready: false, 51 | help: NewHelp(), 52 | keys: keys, 53 | filter: f, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /cmd/render.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "log" 5 | 6 | tomd "github.com/JohannesKaufmann/html-to-markdown" 7 | ) 8 | 9 | var htom = tomd.NewConverter("", true, nil) 10 | 11 | func (m *Model) loadReader() { 12 | id := m.table.Cursor() 13 | post := m.context.feed.Posts[id] 14 | post.ID = id 15 | 16 | m.swapPage("reader") 17 | m.context.post = post 18 | m.viewport.YPosition = 0 // reset the viewport position 19 | 20 | // render the post 21 | fromMd, err := htom.ConvertString(post.Content) 22 | if err != nil { 23 | log.Fatalf("could not convert html to markdown: %v", err) 24 | } 25 | 26 | out, err := m.glam.Render(fromMd) 27 | if err != nil { 28 | log.Fatalf("could not render markdown: %v", err) 29 | } 30 | 31 | m.viewport.SetContent(out) 32 | m.viewport.Height = m.viewport.Height - 2 33 | } 34 | -------------------------------------------------------------------------------- /cmd/view.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/charmbracelet/lipgloss" 7 | 8 | "github.com/isabelroses/izrss/lib" 9 | ) 10 | 11 | // View renders the model as a string 12 | func (m Model) View() string { 13 | out := "" 14 | 15 | if !m.ready { 16 | out = "Initializing..." 17 | } else if m.context.curr == "reader" { 18 | out = lib.MainStyle.Render( 19 | lipgloss.JoinVertical( 20 | lipgloss.Top, 21 | fmt.Sprintf("%s - %3.f%%", m.context.post.Title, m.viewport.ScrollPercent()*100), 22 | m.viewport.View(), 23 | m.help.View(m.keys, m), 24 | ), 25 | ) 26 | } else { 27 | out = lib.MainStyle.Render(m.viewport.View()) 28 | } 29 | 30 | return out 31 | } 32 | -------------------------------------------------------------------------------- /example.toml: -------------------------------------------------------------------------------- 1 | # all examples in this file differ from the default settings 2 | # to show how this file may be changed for a better user experince 3 | 4 | # this should follow the Go reference time format 5 | # see for more information 6 | dateformat = "2006/01/02" 7 | 8 | # a list of urls to fetch rss feeds from 9 | urls = [ 10 | "https://isabelroses.com/feed.xml", 11 | "https://robinroses.xyz/feed.xml", 12 | ] 13 | 14 | # there are settings that only apply to the reader view 15 | [reader] 16 | # this value should be a float between 0 and 1, this tracks how much 17 | # of the screen should be scrolled when the article is marked as read 18 | read_threshold = 0.75 19 | 20 | # this value can be "most", "recommended" or "full" and controls the 21 | # width of the article should be displayed to the users screen 22 | # this value can also be an int, however this is not recommended as 23 | # it will not be responsive to screen sizes 24 | size = "full" 25 | 26 | # this value can be "environment" or a path to a glamour file otherwise this 27 | # will default auto style based on the terminal 28 | theme = "environment" 29 | 30 | # these values can be any format that lipgloss supports 31 | # see 32 | [colors] 33 | text = "#D6CBB4" 34 | inverttext = "#252B2E" 35 | subtext = "#6E8585" 36 | accent = "#B2C98F" 37 | borders = "#46545B" 38 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1742069588, 6 | "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-unstable", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "izrss - A RSS reader for the terminal"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 5 | 6 | outputs = 7 | { self, nixpkgs, ... }: 8 | let 9 | systems = [ 10 | "x86_64-linux" 11 | "x86_64-darwin" 12 | "i686-linux" 13 | "aarch64-linux" 14 | "aarch64-darwin" 15 | ]; 16 | forAllSystems = 17 | function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system}); 18 | in 19 | { 20 | packages = forAllSystems (pkgs: { 21 | default = self.packages.${pkgs.stdenv.hostPlatform.system}.izrss; 22 | izrss = pkgs.callPackage ./nix/default.nix { version = self.shortRev or "unstable"; }; 23 | }); 24 | 25 | overlays.default = final: _: { 26 | izrss = final.callPackage ./nix/default.nix { version = self.shortRev or "unstable"; }; 27 | }; 28 | 29 | devShells = forAllSystems (pkgs: { 30 | default = pkgs.callPackage ./nix/shell.nix { }; 31 | }); 32 | 33 | homeManagerModules.default = ./nix/hm-module.nix; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/isabelroses/izrss 2 | 3 | go 1.23.0 4 | 5 | toolchain go1.24.1 6 | 7 | require ( 8 | github.com/JohannesKaufmann/html-to-markdown v1.6.0 9 | github.com/adrg/xdg v0.5.3 10 | github.com/charmbracelet/bubbles v0.20.0 11 | github.com/charmbracelet/bubbletea v1.3.4 12 | github.com/charmbracelet/lipgloss v1.1.0 13 | github.com/mmcdole/gofeed v1.3.0 14 | github.com/pelletier/go-toml/v2 v2.2.3 15 | github.com/urfave/cli/v2 v2.27.6 16 | ) 17 | 18 | require ( 19 | github.com/PuerkitoBio/goquery v1.10.2 // indirect 20 | github.com/alecthomas/chroma/v2 v2.15.0 // indirect 21 | github.com/andybalholm/cascadia v1.3.3 // indirect 22 | github.com/atotto/clipboard v0.1.4 // indirect 23 | github.com/aymerick/douceur v0.2.0 // indirect 24 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect 25 | github.com/charmbracelet/x/ansi v0.8.0 // indirect 26 | github.com/charmbracelet/x/cellbuf v0.0.13 // indirect 27 | github.com/charmbracelet/x/term v0.2.1 // indirect 28 | github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect 29 | github.com/dlclark/regexp2 v1.11.5 // indirect 30 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect 31 | github.com/gorilla/css v1.0.1 // indirect 32 | github.com/json-iterator/go v1.1.12 // indirect 33 | github.com/microcosm-cc/bluemonday v1.0.27 // indirect 34 | github.com/mmcdole/goxpp v1.1.1 // indirect 35 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 36 | github.com/modern-go/reflect2 v1.0.2 // indirect 37 | github.com/russross/blackfriday/v2 v2.1.0 // indirect 38 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect 39 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect 40 | github.com/yuin/goldmark v1.7.8 // indirect 41 | github.com/yuin/goldmark-emoji v1.0.5 // indirect 42 | golang.org/x/net v0.37.0 // indirect 43 | golang.org/x/term v0.30.0 // indirect 44 | ) 45 | 46 | require ( 47 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 48 | github.com/charmbracelet/glamour v0.9.0 49 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect 50 | github.com/mattn/go-isatty v0.0.20 // indirect 51 | github.com/mattn/go-localereader v0.0.1 // indirect 52 | github.com/mattn/go-runewidth v0.0.16 // indirect 53 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 54 | github.com/muesli/cancelreader v0.2.2 // indirect 55 | github.com/muesli/reflow v0.3.0 // indirect 56 | github.com/muesli/termenv v0.16.0 // indirect 57 | github.com/rivo/uniseg v0.4.7 // indirect 58 | golang.org/x/sync v0.12.0 // indirect 59 | golang.org/x/sys v0.31.0 // indirect 60 | golang.org/x/text v0.23.0 // indirect 61 | ) 62 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/JohannesKaufmann/html-to-markdown v1.6.0 h1:04VXMiE50YYfCfLboJCLcgqF5x+rHJnb1ssNmqpLH/k= 2 | github.com/JohannesKaufmann/html-to-markdown v1.6.0/go.mod h1:NUI78lGg/a7vpEJTz/0uOcYMaibytE4BUOQS8k78yPQ= 3 | github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk= 4 | github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= 5 | github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= 6 | github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= 7 | github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= 8 | github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= 9 | github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= 10 | github.com/alecthomas/chroma/v2 v2.15.0 h1:LxXTQHFoYrstG2nnV9y2X5O94sOBzf0CIUpSTbpxvMc= 11 | github.com/alecthomas/chroma/v2 v2.15.0/go.mod h1:gUhVLrPDXPtp/f+L1jo9xepo9gL4eLwRuGAunSZMkio= 12 | github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= 13 | github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= 14 | github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= 15 | github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= 16 | github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= 17 | github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= 18 | github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= 19 | github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= 20 | github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= 21 | github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= 22 | github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= 23 | github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= 24 | github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= 25 | github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= 26 | github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= 27 | github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= 28 | github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= 29 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= 30 | github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= 31 | github.com/charmbracelet/glamour v0.9.0 h1:1Hm3wxww7qXvGI+Fb3zDmIZo5oDOvVOWJ4OrIB+ef7c= 32 | github.com/charmbracelet/glamour v0.9.0/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= 33 | github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= 34 | github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= 35 | github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= 36 | github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= 37 | github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= 38 | github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= 39 | github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= 40 | github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= 41 | github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= 42 | github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= 43 | github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= 44 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 45 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 46 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 47 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 48 | github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= 49 | github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= 50 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= 51 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= 52 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 53 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 54 | github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= 55 | github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= 56 | github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= 57 | github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= 58 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 59 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 60 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 61 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 62 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 63 | github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= 64 | github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= 65 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 66 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 67 | github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= 68 | github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= 69 | github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= 70 | github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= 71 | github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 72 | github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= 73 | github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= 74 | github.com/mmcdole/gofeed v1.3.0 h1:5yn+HeqlcvjMeAI4gu6T+crm7d0anY85+M+v6fIFNG4= 75 | github.com/mmcdole/gofeed v1.3.0/go.mod h1:9TGv2LcJhdXePDzxiuMnukhV2/zb6VtnZt1mS+SjkLE= 76 | github.com/mmcdole/goxpp v1.1.1 h1:RGIX+D6iQRIunGHrKqnA2+700XMCnNv0bAOOv5MUhx8= 77 | github.com/mmcdole/goxpp v1.1.1/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= 78 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 79 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 80 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 81 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 82 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 83 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= 84 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= 85 | github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= 86 | github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= 87 | github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= 88 | github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= 89 | github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= 90 | github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= 91 | github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= 92 | github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= 93 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 94 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 95 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 96 | github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 97 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 98 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 99 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 100 | github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= 101 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 102 | github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= 103 | github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI= 104 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 105 | github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= 106 | github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= 107 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 108 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 109 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 110 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 111 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 112 | github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= 113 | github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= 114 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= 115 | github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= 116 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= 117 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= 118 | github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 119 | github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= 120 | github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= 121 | github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= 122 | github.com/yuin/goldmark-emoji v1.0.5 h1:EMVWyCGPlXJfUXBXpuMu+ii3TIaxbVBnEX9uaDC4cIk= 123 | github.com/yuin/goldmark-emoji v1.0.5/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= 124 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 125 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 126 | golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= 127 | golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= 128 | golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= 129 | golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= 130 | golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= 131 | golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= 132 | golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= 133 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= 134 | golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 135 | golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= 136 | golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 137 | golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 138 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 139 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 140 | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 141 | golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 142 | golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= 143 | golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= 144 | golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= 145 | golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= 146 | golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= 147 | golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= 148 | golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= 149 | golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= 150 | golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= 151 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 152 | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 153 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 154 | golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= 155 | golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 156 | golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 157 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 158 | golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= 159 | golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 160 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 161 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 162 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 163 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 164 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 165 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 166 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 167 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 168 | golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 169 | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 170 | golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 171 | golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 172 | golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 173 | golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 174 | golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 175 | golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= 176 | golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 177 | golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= 178 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 179 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 180 | golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 181 | golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= 182 | golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= 183 | golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= 184 | golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 185 | golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= 186 | golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= 187 | golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= 188 | golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= 189 | golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= 190 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 191 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 192 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 193 | golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 194 | golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 195 | golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 196 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 197 | golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 198 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 199 | golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= 200 | golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= 201 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 202 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 203 | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= 204 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= 205 | golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= 206 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= 207 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 208 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 209 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 210 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 211 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 212 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 213 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 214 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 215 | -------------------------------------------------------------------------------- /lib/config.go: -------------------------------------------------------------------------------- 1 | // Package lib common library functions 2 | package lib 3 | 4 | import ( 5 | "log" 6 | "os" 7 | 8 | "github.com/adrg/xdg" 9 | "github.com/pelletier/go-toml/v2" 10 | ) 11 | 12 | func getConfigFile(file string) string { 13 | configFile, err := xdg.ConfigFile("izrss/" + file) 14 | if err != nil { 15 | log.Fatalf("could not find config file: %v", err) 16 | } 17 | return configFile 18 | } 19 | 20 | // LoadConfig loads the users configuration file and applies it to the config struct 21 | func LoadConfig(config string) { 22 | if config == "" { 23 | config = getConfigFile("config.toml") 24 | } 25 | // ignore error since we can just use the default config 26 | configRaw, _ := os.ReadFile(config) 27 | 28 | if err := toml.Unmarshal(configRaw, &UserConfig); err != nil { 29 | log.Fatalf("could not unmarshal config: %v", err) 30 | } 31 | } 32 | 33 | // UserConfig is the global user configuration 34 | var UserConfig = config{ 35 | Home: "home", 36 | DateFormat: "02/01/2006", 37 | Urls: []string{}, 38 | Reader: reader{ 39 | Size: "recomended", 40 | ReadThreshold: 0.8, 41 | Theme: "", 42 | }, 43 | Colors: colors{ 44 | Text: "#cdd6f4", 45 | Inverttext: "#1e1e2e", 46 | Subtext: "#a6adc8", 47 | Accent: "#74c7ec", 48 | Borders: "#313244", 49 | }, 50 | } 51 | 52 | // Config is the struct that holds the configuration 53 | type config struct { 54 | Home string `toml:"home"` 55 | Colors colors `toml:"colors"` 56 | Reader reader `toml:"reader"` 57 | DateFormat string `toml:"dateformat"` 58 | Urls []string `toml:"urls"` 59 | } 60 | 61 | type colors struct { 62 | Text string `toml:"text"` 63 | Inverttext string `toml:"inverttext"` 64 | Subtext string `toml:"subtext"` 65 | Accent string `toml:"accent"` 66 | Borders string `toml:"borders"` 67 | } 68 | 69 | type reader struct { 70 | Size any `toml:"size"` 71 | Theme string `toml:"theme"` 72 | ReadThreshold float64 `toml:"read_threshold"` 73 | } 74 | -------------------------------------------------------------------------------- /lib/feeds.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "sort" 5 | "time" 6 | ) 7 | 8 | // Post represents a single post in a feed 9 | type Post struct { 10 | UUID string `json:"uuid"` 11 | Title string `json:"-"` 12 | Content string `json:"-"` 13 | Link string `json:"-"` 14 | Date string `json:"-"` 15 | ID int `json:"-"` 16 | Read bool `json:"read"` 17 | } 18 | 19 | // Feed represents a single feed 20 | type Feed struct { 21 | Title string `json:"-"` 22 | URL string `json:"URL"` 23 | Posts []Post `json:"posts"` 24 | ID int `json:"-"` 25 | } 26 | 27 | // Feeds represents a collection of feeds 28 | type Feeds []Feed 29 | 30 | func (f Feeds) sort(urls []string) Feeds { 31 | // Create a map to store the index of each string in the url array 32 | urlMap := make(map[string]int) 33 | for i, str := range urls { 34 | urlMap[str] = i 35 | } 36 | 37 | // Sort the second set of strings based on the index in the first array 38 | sort.SliceStable(f, func(i, j int) bool { 39 | return urlMap[f[i].URL] < urlMap[f[j].URL] 40 | }) 41 | 42 | return f 43 | } 44 | 45 | // GetTotalUnreads returns the total number of unread posts in a feed 46 | func (f Feed) GetTotalUnreads() int { 47 | total := 0 48 | for _, post := range f.Posts { 49 | if !post.Read { 50 | total++ 51 | } 52 | } 53 | return total 54 | } 55 | 56 | // GetTotalUnreads returns the total number of unread posts in all feeds 57 | func (f Feeds) GetTotalUnreads() int { 58 | total := 0 59 | for _, feed := range f { 60 | total += feed.GetTotalUnreads() 61 | } 62 | return total 63 | } 64 | 65 | // silly leah thinks this is chatgpt-ed but NO. I wrote this myself. I'm just that good. 66 | // also a bit of nix inspired me to write this `foldl recursiveUpdate { } importedLibs` 67 | // okay maybe it was beacuse of the comments not actually the code, kinda fair. 68 | func (feeds *Feeds) mergeFeeds(otherFeeds Feeds) { 69 | // Create a map to hold posts' read state from feeds1 by their UUID for quick lookup 70 | readStatusMap := make(map[string]bool) 71 | 72 | // Iterate through otherFeeds and map their posts by UUID 73 | for _, feed := range otherFeeds { 74 | for _, post := range feed.Posts { 75 | readStatusMap[post.UUID] = post.Read 76 | } 77 | } 78 | 79 | // Iterate through feeds and merge their posts into feeds1 based on UUID 80 | for i := range *feeds { 81 | for j := range (*feeds)[i].Posts { 82 | if readStatus, exists := readStatusMap[(*feeds)[i].Posts[j].UUID]; exists { 83 | (*feeds)[i].Posts[j].Read = readStatus 84 | } 85 | } 86 | } 87 | } 88 | 89 | // SortPostsByDate sorts an array of Post structs by the Date field. 90 | func SortPosts(posts []Post) error { 91 | dateFormat := UserConfig.DateFormat 92 | 93 | sort.Slice(posts, func(i, j int) bool { 94 | // Parse the dates for the current comparison 95 | dateI, errI := time.Parse(dateFormat, posts[i].Date) 96 | dateJ, errJ := time.Parse(dateFormat, posts[j].Date) 97 | 98 | if errI != nil || errJ != nil { 99 | return false 100 | } 101 | 102 | // Compare the parsed dates 103 | return dateI.After(dateJ) 104 | }) 105 | 106 | return nil 107 | } 108 | -------------------------------------------------------------------------------- /lib/feeds_test.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestMergeFeeds(t *testing.T) { 8 | // Test case 1: Feeds with no common posts 9 | feeds1 := Feeds{ 10 | {Posts: []Post{ 11 | {UUID: "1", Read: false}, 12 | {UUID: "2", Read: true}, 13 | }}, 14 | } 15 | feeds2 := Feeds{ 16 | {Posts: []Post{ 17 | {UUID: "3", Read: false}, 18 | {UUID: "4", Read: true}, 19 | }}, 20 | } 21 | 22 | feeds1.mergeFeeds(feeds2) 23 | 24 | // Ensure feeds1 remains unchanged 25 | if feeds1[0].Posts[0].Read != false || feeds1[0].Posts[1].Read != true { 26 | t.Errorf("Expected no change in feeds1") 27 | } 28 | 29 | // Ensure feeds2 remains unchanged 30 | if feeds2[0].Posts[0].Read != false || feeds2[0].Posts[1].Read != true { 31 | t.Errorf("Expected no change in feeds2") 32 | } 33 | 34 | // Test case 2: Feeds with common posts 35 | feeds3 := Feeds{ 36 | {Posts: []Post{ 37 | {UUID: "1", Read: true}, 38 | {UUID: "2", Read: true}, 39 | }}, 40 | } 41 | feeds4 := Feeds{ 42 | {Posts: []Post{ 43 | {UUID: "1", Read: false}, 44 | {UUID: "2", Read: false}, 45 | }}, 46 | } 47 | 48 | feeds3.mergeFeeds(feeds4) 49 | 50 | // Ensure that the "Read" state for posts in common gets merged 51 | if feeds3[0].Posts[0].Read == true && feeds3[0].Posts[1].Read == true { 52 | t.Errorf("Expected merged read states") 53 | } 54 | 55 | // Test case 3: Feeds with identical posts and same read state 56 | feeds5 := Feeds{ 57 | {Posts: []Post{ 58 | {UUID: "1", Read: true}, 59 | {UUID: "2", Read: false}, 60 | }}, 61 | } 62 | feeds6 := Feeds{ 63 | {Posts: []Post{ 64 | {UUID: "1", Read: true}, 65 | {UUID: "2", Read: false}, 66 | }}, 67 | } 68 | 69 | feeds5.mergeFeeds(feeds6) 70 | 71 | // Ensure that the feed remains unchanged as the states were the same 72 | if feeds5[0].Posts[0].Read != true || feeds5[0].Posts[1].Read != false { 73 | t.Errorf("Expected no change when posts have the same read state") 74 | } 75 | 76 | // Test case 4: Feeds with posts but no common posts 77 | feeds7 := Feeds{ 78 | {Posts: []Post{ 79 | {UUID: "1", Read: false}, 80 | {UUID: "2", Read: false}, 81 | }}, 82 | } 83 | feeds8 := Feeds{ 84 | {Posts: []Post{ 85 | {UUID: "3", Read: true}, 86 | {UUID: "4", Read: true}, 87 | }}, 88 | } 89 | 90 | feeds7.mergeFeeds(feeds8) 91 | 92 | // Ensure that the posts in feeds7 are not modified and posts in feeds8 are unaffected 93 | if feeds7[0].Posts[0].Read != false || feeds7[0].Posts[1].Read != false { 94 | t.Errorf("Expected no change in feeds7") 95 | } 96 | if feeds8[0].Posts[0].Read != true || feeds8[0].Posts[1].Read != true { 97 | t.Errorf("Expected no change in feeds8") 98 | } 99 | 100 | // Test case 4: Feeds with posts but no common posts 101 | feeds9 := Feeds{ 102 | {Posts: []Post{ 103 | {UUID: "1", Read: false}, 104 | {UUID: "2", Read: false}, 105 | }}, 106 | } 107 | feeds10 := Feeds{ 108 | {Posts: []Post{ 109 | {UUID: "3", Read: true}, 110 | }}, 111 | } 112 | 113 | feeds9.mergeFeeds(feeds10) 114 | } 115 | -------------------------------------------------------------------------------- /lib/fetch.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | "log" 8 | "net/http" 9 | "os" 10 | "sync" 11 | "time" 12 | 13 | "github.com/adrg/xdg" 14 | "github.com/mmcdole/gofeed" 15 | ) 16 | 17 | // FetchURL fetches the content of a URL and returns it as a byte slice 18 | func FetchURL(url string, preferCache bool) []byte { 19 | fileStr := "izrss/" + URLToDir(url) 20 | file, err := xdg.CacheFile(fileStr) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | 25 | if data, errr := os.ReadFile(file); errr == nil && preferCache { 26 | return data 27 | } 28 | 29 | resp, err := http.Get(url) 30 | if err != nil { 31 | return nil 32 | } 33 | defer resp.Body.Close() 34 | 35 | body, err := io.ReadAll(resp.Body) 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | 40 | err = os.WriteFile(file, body, 0644) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | return body 46 | } 47 | 48 | // GetContentForURL fetches the content of a URL and returns it as a Feed 49 | func GetContentForURL(url string, preferCache bool) Feed { 50 | feed := setupReader(url, preferCache) 51 | 52 | if feed == nil { 53 | return Feed{ 54 | Title: fmt.Sprintf("Error loading %s", url), 55 | URL: url, 56 | Posts: []Post{}, 57 | } 58 | } 59 | 60 | feedRet := Feed{ 61 | Title: feed.Title, 62 | URL: url, 63 | Posts: []Post{}, 64 | } 65 | 66 | // could be deduplicated but unsure what the best way to do that is 67 | for _, item := range feed.Items { 68 | post := createPost(item) 69 | 70 | feedRet.Posts = append(feedRet.Posts, post) 71 | } 72 | 73 | return feedRet 74 | } 75 | 76 | // GetPosts fetches the content of a URL and returns it as a slice of Posts 77 | func GetPosts(url string) []Post { 78 | feed := setupReader(url, false) 79 | posts := []Post{} 80 | 81 | if feed == nil { 82 | return posts 83 | } 84 | 85 | for _, item := range feed.Items { 86 | post := createPost(item) 87 | posts = append(posts, post) 88 | } 89 | 90 | return posts 91 | } 92 | 93 | func createPost(item *gofeed.Item) Post { 94 | content := "" 95 | if item.Content != "" { 96 | content = item.Content 97 | } else if item.Description != "" { 98 | content = item.Description 99 | } else { 100 | content = "This post does not contain any content.\nPress \"o\" to open the post in your preferred browser" 101 | } 102 | 103 | post := Post{ 104 | Title: item.Title, 105 | Content: content, 106 | Link: item.Link, 107 | Date: ConvertDate(item.Published), 108 | UUID: item.GUID, 109 | } 110 | 111 | return post 112 | } 113 | 114 | func setupReader(url string, preferCache bool) *gofeed.Feed { 115 | fp := gofeed.NewParser() 116 | 117 | file := string(FetchURL(url, preferCache)) 118 | 119 | if file == "" { 120 | return nil 121 | } 122 | 123 | feed, err := fp.ParseString(file) 124 | if err != nil { 125 | log.Printf("could not parse feed: %v", url) 126 | } 127 | 128 | return feed 129 | } 130 | 131 | // GetAllContent fetches the content of all URLs and returns it as a slice of Feeds 132 | func GetAllContent(urls []string, preferCache bool) Feeds { 133 | if !preferCache { 134 | err := WriteCacheTime() 135 | if err != nil { 136 | log.Fatalf("could not check cache: %v", err) 137 | } 138 | } 139 | 140 | // Create a wait group to wait for all goroutines to finish 141 | var wg sync.WaitGroup 142 | 143 | // Create a channel to receive responses 144 | responses := make(chan Feed, len(urls)) 145 | 146 | // Loop through the URLs and start a goroutine for each 147 | for _, url := range urls { 148 | wg.Add(1) 149 | go fetchContent(url, preferCache, &wg, responses) 150 | } 151 | 152 | // Close the responses channel when all goroutines are done 153 | go func() { 154 | wg.Wait() 155 | close(responses) 156 | }() 157 | 158 | feeds := Feeds{} 159 | for response := range responses { 160 | feeds = append(feeds, response) 161 | } 162 | 163 | return feeds.sort(urls) 164 | } 165 | 166 | func fetchContent(url string, preferCache bool, wg *sync.WaitGroup, ch chan<- Feed) { 167 | // Call the GetContentForURL function 168 | posts := GetContentForURL(url, preferCache) 169 | 170 | // Decrement the wait group counter when the function exits 171 | defer wg.Done() 172 | 173 | // Send the response through the channel 174 | ch <- posts 175 | } 176 | 177 | func CheckCache() bool { 178 | fileStr := getStateFile("fetch.json") 179 | if _, err := os.Stat(fileStr); os.IsNotExist(err) { 180 | err := WriteCacheTime() 181 | if err != nil { 182 | log.Fatalf("could not write tracking file: %v", err) 183 | } 184 | } 185 | 186 | file, err := os.ReadFile(fileStr) 187 | if err != nil { 188 | log.Fatalf("could not read tracking file: %v", err) 189 | } 190 | 191 | last := &time.Time{} 192 | err = json.Unmarshal(file, last) 193 | if err != nil { 194 | log.Fatalf("could not unmarshal tracking file: %v", err) 195 | } 196 | 197 | if time.Since(*last) > 24*time.Hour { 198 | return false 199 | } 200 | 201 | return true 202 | } 203 | 204 | func WriteCacheTime() error { 205 | json, err := json.Marshal(time.Now()) 206 | if err != nil { 207 | return err 208 | } 209 | return os.WriteFile(getStateFile("fetch.json"), json, 0644) 210 | } 211 | -------------------------------------------------------------------------------- /lib/helpers.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "os/exec" 5 | "runtime" 6 | "strings" 7 | "time" 8 | ) 9 | 10 | // OpenURL opens the specified URL in the default browser of the user. 11 | // https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang 12 | func OpenURL(url string) error { 13 | var cmd string 14 | var args []string 15 | 16 | switch runtime.GOOS { 17 | case "windows": 18 | cmd = "cmd" 19 | args = []string{"/c", "start", url} 20 | case "darwin": 21 | cmd = "open" 22 | args = []string{url} 23 | default: 24 | // Check if running under WSL 25 | if isWSL() { 26 | // Use 'cmd.exe /c start' to open the URL in the default Windows browser 27 | cmd = "cmd.exe" 28 | args = []string{"/c", "start", url} 29 | } else { 30 | // Use xdg-open on native Linux environments 31 | cmd = "xdg-open" 32 | args = []string{url} 33 | } 34 | } 35 | 36 | return exec.Command(cmd, args...).Start() 37 | } 38 | 39 | // isWSL checks if the Go program is running inside Windows Subsystem for Linux 40 | func isWSL() bool { 41 | releaseData, err := exec.Command("uname", "-r").Output() 42 | if err != nil { 43 | return false 44 | } 45 | return strings.Contains(strings.ToLower(string(releaseData)), "microsoft") 46 | } 47 | 48 | // ConvertDate converts a date string to the user's preferred date format 49 | func ConvertDate(dateString string) string { 50 | layoutList := []string{ 51 | "Mon, 02 Jan 2006 15:04:05 -0700", 52 | "Mon, 02 Jan 2006 15:04:05 MST", 53 | "Monday, 02-Jan-06 15:04:05 MST", 54 | "02 Jan 2006 15:04:05 -0700", 55 | "02 Jan 2006 15:04:05 +0000", 56 | "02 Jan 2006 15:04:05 MST", 57 | "02-Jan-06 15:04:05 MST", 58 | "2006-02-01T15:04:05", 59 | "2006-01-02T15:04:05", 60 | "January 02, 2006", 61 | "02/Jan/2006", 62 | "02-Jan-2006", 63 | "2006-01-02", 64 | "01/02/2006", 65 | time.RFC3339, 66 | } 67 | 68 | var parsedDate time.Time 69 | var err error 70 | 71 | for _, layout := range layoutList { 72 | parsedDate, err = time.Parse(layout, dateString) 73 | if err == nil { 74 | break 75 | } 76 | } 77 | 78 | if err != nil { 79 | return dateString 80 | } 81 | 82 | date := parsedDate.Format(UserConfig.DateFormat) 83 | 84 | return date 85 | } 86 | 87 | // URLToDir converts a URL to a directory name 88 | // https://isabelroses.com/feed.xml -> isabelroses_com_feed.xml 89 | func URLToDir(url string) string { 90 | url = strings.ReplaceAll(url, "https://", "") 91 | url = strings.ReplaceAll(url, "http://", "") 92 | url = strings.ReplaceAll(url, "/", "_") 93 | // replace all dots but the last one 94 | dots := strings.Count(url, ".") - 1 95 | url = strings.Replace(url, ".", "_", dots) 96 | return url 97 | } 98 | 99 | func ReadSymbol(read bool) string { 100 | if read { 101 | return "" 102 | } 103 | return "•" 104 | } 105 | -------------------------------------------------------------------------------- /lib/logger.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func SetupLogger() { 9 | file, err := os.OpenFile(getStateFile("izrss.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | 14 | log.SetOutput(file) 15 | } 16 | -------------------------------------------------------------------------------- /lib/state.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "encoding/json" 5 | "log" 6 | "os" 7 | 8 | "github.com/adrg/xdg" 9 | ) 10 | 11 | // ToggleRead toggles the read status of a post 12 | func ToggleRead(feeds Feeds, feedID int, postID int) Feeds { 13 | postr := &feeds[feedID].Posts[postID] 14 | postr.Read = !postr.Read 15 | return feeds 16 | } 17 | 18 | // ReadAll marks all posts in a feed as read 19 | func ReadAll(feeds Feeds, feedID int) Feeds { 20 | for i := range feeds[feedID].Posts { 21 | feeds[feedID].Posts[i].Read = true 22 | } 23 | return feeds 24 | } 25 | 26 | // MarkRead marks a post as read 27 | func MarkRead(feeds Feeds, feedID int, postID int) Feeds { 28 | postr := &feeds[feedID].Posts[postID] 29 | postr.Read = true 30 | return feeds 31 | } 32 | 33 | // WriteTracking saves the tracking state to a JSON file 34 | func (feeds Feeds) WriteTracking() error { 35 | json, err := json.Marshal(feeds) 36 | if err != nil { 37 | return err 38 | } 39 | return os.WriteFile(getStateFile("tracking.json"), json, 0644) 40 | } 41 | 42 | // ReadTracking reads the tracking state from a JSON file 43 | func (feeds *Feeds) ReadTracking() error { 44 | fileStr := getStateFile("tracking.json") 45 | if _, err := os.Stat(fileStr); os.IsNotExist(err) { 46 | err := feeds.WriteTracking() 47 | if err != nil { 48 | log.Fatalf("could not write tracking file: %v", err) 49 | } 50 | } 51 | 52 | file, err := os.ReadFile(fileStr) 53 | if err != nil { 54 | return err 55 | } 56 | 57 | var trackingData Feeds 58 | err = json.Unmarshal(file, &trackingData) 59 | if err != nil { 60 | return err 61 | } 62 | 63 | feeds.mergeFeeds(trackingData) 64 | 65 | return nil 66 | } 67 | 68 | func getStateFile(file string) string { 69 | stateFile, err := xdg.StateFile("izrss/" + file) 70 | if err != nil { 71 | log.Fatalf("could not find state file: %v", err) 72 | } 73 | return stateFile 74 | } 75 | -------------------------------------------------------------------------------- /lib/style.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import ( 4 | "github.com/charmbracelet/bubbles/table" 5 | "github.com/charmbracelet/lipgloss" 6 | ) 7 | 8 | var ( 9 | // MainStyle is the main style for the application 10 | MainStyle = lipgloss.NewStyle(). 11 | Foreground(lipgloss.Color(UserConfig.Colors.Text)). 12 | Border(lipgloss.RoundedBorder(), true). 13 | BorderForeground(lipgloss.Color(UserConfig.Colors.Borders)). 14 | Padding(0, 1). 15 | Margin(0) 16 | 17 | // HelpStyle is the style for the help keybinds menu 18 | HelpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(UserConfig.Colors.Subtext)) 19 | ) 20 | 21 | // TableStyle returns the style for the table 22 | func TableStyle() table.Styles { 23 | return table.Styles{ 24 | Header: lipgloss.NewStyle().Bold(true), 25 | Cell: lipgloss.NewStyle(), 26 | Selected: lipgloss.NewStyle(). 27 | Foreground(lipgloss.Color(UserConfig.Colors.Inverttext)). 28 | Background(lipgloss.Color(UserConfig.Colors.Accent)), 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Package main is the entry point for the application 2 | package main 3 | 4 | import ( 5 | "fmt" 6 | "log" 7 | "os" 8 | 9 | tea "github.com/charmbracelet/bubbletea" 10 | "github.com/urfave/cli/v2" 11 | 12 | "github.com/isabelroses/izrss/cmd" 13 | "github.com/isabelroses/izrss/lib" 14 | ) 15 | 16 | var version = "unstable" 17 | 18 | func main() { 19 | cli.AppHelpTemplate = fmt.Sprintf(`%s 20 | CUSTOMIZATION: 21 | The main bulk of customization is done via the "~/.config/izrss/config.toml" file. You can find an example file on the github page. 22 | 23 | The rest of the config is done via using the environment variables "GLAMOUR_STYLE". 24 | For a good example see: `, 25 | cli.AppHelpTemplate, 26 | ) 27 | 28 | app := &cli.App{ 29 | Name: "izrss", 30 | Version: version, 31 | Authors: []*cli.Author{{ 32 | Name: "Isabel Roses", 33 | Email: "isabel@isabelroses.com", 34 | }}, 35 | Usage: "An RSS feed reader for the terminal.", 36 | 37 | Flags: []cli.Flag{ 38 | &cli.StringFlag{ 39 | Name: "config", 40 | Value: "", 41 | Usage: "the path to your config file", 42 | }, 43 | &cli.BoolFlag{ 44 | Name: "count-unread", 45 | Usage: "count the number of unread posts", 46 | }, 47 | }, 48 | 49 | Action: func(c *cli.Context) error { 50 | lib.LoadConfig(c.String("config")) 51 | 52 | if len(lib.UserConfig.Urls) == 0 { 53 | fmt.Println("No urls were found in config file, please add some and try again") 54 | fmt.Println("You can find an example config file on the github page") 55 | os.Exit(1) 56 | } 57 | 58 | feeds := lib.GetAllContent(lib.UserConfig.Urls, lib.CheckCache()) 59 | err := feeds.ReadTracking() 60 | if err != nil { 61 | log.Fatalf("could not read tracking file: %v", err) 62 | } 63 | 64 | if c.Bool("count-unread") { 65 | totalUnread := feeds.GetTotalUnreads() 66 | fmt.Print(totalUnread) 67 | os.Exit(0) 68 | } 69 | 70 | m := cmd.NewModel() 71 | m.SetFeeds(feeds) 72 | 73 | p := tea.NewProgram(m, tea.WithAltScreen()) 74 | if _, err := p.Run(); err != nil { 75 | log.Fatal(err) 76 | } 77 | 78 | return nil 79 | }, 80 | } 81 | 82 | if err := app.Run(os.Args); err != nil { 83 | log.Fatal(err) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /nix/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | buildGoModule, 4 | version ? "unstable", 5 | }: 6 | buildGoModule { 7 | pname = "izrss"; 8 | inherit version; 9 | 10 | src = lib.fileset.toSource { 11 | root = ../.; 12 | fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) ( 13 | lib.fileset.unions [ 14 | ../go.mod 15 | ../go.sum 16 | ../main.go 17 | ../lib 18 | ../cmd 19 | ] 20 | ); 21 | }; 22 | 23 | vendorHash = "sha256-2L/EUoPbz6AZqv84XPhiZhImOL4wyBOzx6Od4+nTJeY="; 24 | 25 | ldflags = [ 26 | "-s" 27 | "-w" 28 | "-X main.version=${version}" 29 | ]; 30 | 31 | meta = { 32 | description = "A RSS feed reader for the terminal"; 33 | homepage = "https://github.com/isabelroses/izrss"; 34 | license = lib.licenses.gpl3Plus; 35 | maintainers = with lib.maintainers; [ isabelroses ]; 36 | mainProgram = "izrss"; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /nix/hm-module.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | config, 5 | ... 6 | }: 7 | let 8 | inherit (lib) 9 | mkIf 10 | mkOption 11 | mkEnableOption 12 | ; 13 | 14 | settingsFormat = pkgs.formats.toml { }; 15 | 16 | cfg = config.programs.izrss; 17 | in 18 | { 19 | _class = "homeManager"; 20 | 21 | meta.maintainers = [ lib.maintainers.isabelroses ]; 22 | 23 | options.programs.izrss = { 24 | enable = mkEnableOption "A fast and once simple cli todo tool"; 25 | 26 | package = mkOption { 27 | type = lib.types.package; 28 | default = pkgs.callPackage ./default.nix { }; 29 | description = "The izrss package"; 30 | }; 31 | 32 | settings = mkOption { 33 | inherit (settingsFormat) type; 34 | default = { }; 35 | example = lib.literalExpression '' 36 | dateformat = "02/01/2006"; 37 | 38 | colors = { 39 | text = "#cdd6f4"; 40 | inverttext = "#1e1e2e"; 41 | subtext = "#a6adc8"; 42 | accent = "#74c7ec"; 43 | borders = "#313244"; 44 | }; 45 | 46 | urls = [ 47 | "http://example.com" 48 | ]; 49 | ''; 50 | description = '' 51 | Configuration written to {file}`$XDG_CONFIG_HOME/izrss/config.toml`. 52 | 53 | See for the documentation. 54 | ''; 55 | }; 56 | }; 57 | 58 | imports = [ 59 | (lib.mkRenamedOptionModule 60 | [ 61 | "programs" 62 | "izrss" 63 | "urls" 64 | ] 65 | [ 66 | "programs" 67 | "izrss" 68 | "settings" 69 | "urls" 70 | ] 71 | ) 72 | ]; 73 | 74 | config = mkIf cfg.enable { 75 | home.packages = [ cfg.package ]; 76 | 77 | xdg.configFile."izrss/config.toml" = mkIf (cfg.settings != { }) { 78 | source = settingsFormat.generate "izrss-config.toml" cfg.settings; 79 | }; 80 | }; 81 | } 82 | -------------------------------------------------------------------------------- /nix/shell.nix: -------------------------------------------------------------------------------- 1 | { 2 | go, 3 | gopls, 4 | gofumpt, 5 | hyperfine, 6 | goreleaser, 7 | callPackage, 8 | }: 9 | let 10 | mainPkg = callPackage ./default.nix { }; 11 | in 12 | mainPkg.overrideAttrs (oa: { 13 | nativeBuildInputs = [ 14 | go 15 | gopls 16 | gofumpt 17 | hyperfine # lets benchmark 18 | goreleaser 19 | ] ++ (oa.nativeBuildInputs or [ ]); 20 | }) 21 | --------------------------------------------------------------------------------