summaryrefslogtreecommitdiff
path: root/README
blob: b292f73fa79e6dc49bf0635d55c8df0c18664026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
                                                  .. -*- mode: rst -*-
Pancake
=======

This is a CLI/Emacs web/gopher/file browser.

It utilizes pandoc and external downloaders such as curl, adding
support for Gopher directories and plain text files, and invoking
external applications (e.g., image and PDF viewers) depending on its
configuration.

User interaction capabilities are rather basic, as it is intended to
be combined with software that provides better user interfaces – such
as emacs, rlwrap, tmux, screen.


Installation
------------

Retrieval
~~~~~~~~~

There is a few ways to get a recent version of pancake:

- source and binary distributions:
  https://defanor.uberspace.net/projects/pancake/
- git repository: https://git.uberspace.net/pancake/
- github: https://github.com/defanor/pancake/


Pancake
~~~~~~~

``cabal install`` would build and install pancake and its
documentation. Alternatively, basic Debian packages and binary
releases are available.


Emacs interface
~~~~~~~~~~~~~~~

``M-x package-install-file RET /path/to/pancake.el RET``. To set it as
your default emacs browser::

  (require 'pancake)
  (setq browse-url-browser-function 'pancake-browse-url)

To load and show all images automatically (not just after saving them
manually)::

  (add-hook 'pancake-display-hook 'pancake-load-images)

Though it might be desirable to write a wrapper to only show those on
specific websites, e.g. webcomics, and perhaps specific images only.

Commands
--------

:quit or EOF: quit pancake, cleaning the cache
:[: back
:]: forward
:reload config: reload config
:help: show a help message
:?: show current URI
:RET (empty): show the next 2/3 of a page, if pagination is enabled
:<URI>: follow an URI, possibly relative to the current one
:<type> <URI>: same as above, but explicitly set a document type
               (html, txt, org, markdown, etc)
:[,]<number>: follow a link
:,: reload current document
:save <URI>[ <path>]: retrieve data and save it
:save [,]<number>[ <path>]: save linked data
:save ,[ <path>]: save current document
:<shortcut> <query>: run a query using a shortcut defined in the
                     configuration (e.g., search)

pancake-mode provides additional aliases and commands, see built-in
emacs documentation (``C-h m``) for those.


Configuration
-------------

Default configuration will be written into XDG configuration
directory, and would look approximately like this (slightly
simplified)::

  externalViewers:
    png: xdg-open "${FILE}"
    hs: emacsclient -n "${FILE}"
  indentDivs: false
  commands:
    gopher: torify curl "${URI}"
    ssh: scp "${URI_REGNAME}:${URI_PATH}" /dev/stdout
  unclutter:
    duckduckgo: ^https://duckduckgo\.com/lite/\?q=
  defaultCommand: ! 'curl --compressed -4 -L -w "

    -pancake-

    uri: %{url_effective}

    type: %{content_type}

    " "${URI}"'
  referenceDigits: 'rstwfpxcvaqzdgb'
  shortcuts:
    g: https://m.gutenberg.org/ebooks/search.mobile/?query=
    ddg: https://duckduckgo.com/lite/?q=
    wt: https://en.m.wiktionary.org/w/index.php?search=
    wa: web-archive:///?url=
    wp: https://en.m.wikipedia.org/wiki/Special:Search?search=
    gp: gopher://gopherpedia.com:70/7/lookup?
    vs: gopher://gopher.floodgap.com/7/v2/vs?
    xiph: http://dir.xiph.org/search?search=
  historyDepth: 100
  paginate: true


Uncluttering
~~~~~~~~~~~~

XSLT can be used to extract useful data from HTML documents. In the
above sample configuration, ``duckduckgo`` is defined along with an
URI regex to determine when it should be applied, and the
corresponding XSLT file should be in
``~/.config/pancake/unclutter/duckduckgo.xsl``::

  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
      <html>
        <body>
          <xsl:for-each select="//tr[not(@class) or @class!='result-sponsored']">
            <xsl:for-each select="td/a[@class='result-link']">
              <br />
              <br />
              <a href="{@href}">
                <xsl:value-of select="." />
              </a>
            </xsl:for-each>
            <xsl:for-each select="td[@class='result-snippet']">
              <br />
              <xsl:value-of select="." />
            </xsl:for-each>
          </xsl:for-each>
        </body>
      </html>
    </xsl:template>
  </xsl:stylesheet>


Screenshots
-----------

.. image:: https://defanor.uberspace.net/projects/pancake/gopher.png
.. image:: https://defanor.uberspace.net/projects/pancake/web-gnu.png
.. image:: https://defanor.uberspace.net/projects/pancake/emacs.png