Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnt committed Jan 17, 2021
0 parents commit bcd73ae
Show file tree
Hide file tree
Showing 40 changed files with 3,409 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignOperands: true
AlignTrailingComments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AlwaysBreakAfterReturnType: AllDefinitions
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Allman
SpaceBeforeParens: Never
IncludeBlocks: Regroup
ReflowComments: false
SortIncludes: true
UseTab: ForIndentation
IndentWidth: 2
TabWidth: 2
ColumnLimit: 100

NamespaceIndentation: All
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://EditorConfig.org
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
indent_size = tab
max_line_length = 100
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/badwolf
/locale
37 changes: 37 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
image: archlinux/base:latest

before_script:
- pacman -Syu --noconfirm make clang

stages:
- lint
- test
- analysis

test:
stage: test
script:
- pacman -Syu --noconfirm webkit2gtk pkg-config gettext gcc
- make CC=gcc test
- make clean
- make CC=clang test
- make install

format:
stage: lint
script:
- pacman -Syu --noconfirm git
- make format
- git diff --exit-code

scan-build:
stage: analysis
script:
- pacman -Syu --noconfirm webkit2gtk pkg-config gettext gcc
- scan-build --use-cc=gcc -o scan-build-gcc make
- make clean
- scan-build --use-cc=clang -o scan-build-clang make
artifacts:
paths:
- scan-build-gcc/*
- scan-build-clang/*
26 changes: 26 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2019-2020, Badwolf Authors <https://hacktivis.me/projects/badwolf>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the <ORGANIZATION> nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions KnowledgeBase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Similar WebKitGTK+ browser: https://www.uninformativ.de/git/lariza/
- WebKit2 Extensions Tutorial: https://blogs.igalia.com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/
- https://trac.torproject.org/projects/tor/wiki/doc/ImportantGoogleChromeBugs / https://trac.torproject.org/projects/tor/ticket/1925
- https://webkit.org/blog/3476/content-blockers-first-look/
100 changes: 100 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# POSIX-ish Makefile with extensions common to *BSD and GNU such as:
# - Usage of backticks for shell evaluation
# - Usage of ?= for defining variables when not already defined
# - Usage of += for appending to a variable

PACKAGE = Badwolf
VERSION = 1.0.3
VERSION_FULL = $(VERSION)`./version.sh`

PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
DOCDIR ?= $(PREFIX)/share/doc/badwolf-$(VERSION)
DATADIR ?= $(PREFIX)/share/badwolf
APPSDIR ?= $(PREFIX)/share/applications

CC ?= cc
CFLAGS ?= -g -Wall -Wextra -Wconversion -Wsign-conversion -O2
DBG ?=
PKGCONFIG ?= pkg-config
MSGFMT ?= msgfmt
INKSCAPE ?= inkscape

# for i in 24 32 48 64 128 256; do echo icons/hicolor/${i}x${i}/apps/badwolf.png; done | tr '\n' ' '
ICON_SIZES = icons/hicolor/24x24/apps/badwolf.png icons/hicolor/32x32/apps/badwolf.png icons/hicolor/48x48/apps/badwolf.png icons/hicolor/64x64/apps/badwolf.png icons/hicolor/128x128/apps/badwolf.png icons/hicolor/256x256/apps/badwolf.png

DEPS = gtk+-3.0 webkit2gtk-4.0 libsoup-2.4
SRCS = uri.c uri_test.c keybindings.c downloads.c badwolf.c
OBJS = uri.o keybindings.o downloads.o badwolf.o
OBJS_test = uri_test.o
EXE = lrrh
EXE_test = uri_test
TRANS = fr.mo pt_BR.mo tr.mo
DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt

CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\"
CDEPS += `$(PKGCONFIG) --cflags $(DEPS)`
LIBS = `$(PKGCONFIG) --libs $(DEPS)`

all: $(EXE) $(TRANS) po/messages.pot

icons: $(ICON_SIZES)

icons/hicolor/scalable/apps/badwolf.svg: badwolf.svg
mkdir -p icons/hicolor/scalable/apps
scour --no-line-breaks --enable-id-stripping --remove-metadata $< $@

icons/hicolor/%/apps/badwolf.png: icons/hicolor/scalable/apps/badwolf.svg
mkdir -p `dirname $@`
$(INKSCAPE) `echo $@ | cut -d/ -f3 | ./icons_size.sh` $< -o $@

po/messages.pot: $(SRCS)
xgettext --keyword=_ --language=C --from-code=UTF-8 -o $@ --add-comments --sort-output --copyright-holder="Badwolf Authors <https://hacktivis.me/projects/badwolf>" --package-name="$(PACKAGE)" --package-version="$(VERSION_FULL)" --msgid-bugs-address="[email protected]" $(SRCS)

po/%.po: po/messages.pot
msgmerge --update --backup=off $@ $<

${TRANS}: po/${@:.mo=.po}
mkdir -p locale/${@:.mo=}/LC_MESSAGES
$(MSGFMT) -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po}

lrrh: $(OBJS)
$(CC) -std=c11 -o $@ $(OBJS) $(LDFLAGS) $(LIBS)

.c:
$(CC) -std=c11 $(CFLAGS) $(CDEPS) $(LDFLAGS) $(LIBS) -o $@ $<

.c.o:
$(CC) -std=c11 $(CFLAGS) $(CDEPS) -c -o $@ $<

uri_test: uri.o uri_test.o
$(CC) -std=c11 -o $@ uri.o uri_test.o $(LDFLAGS) $(LIBS)
$(DBG) ./$@

.PHONY: test
test: $(EXE_test)

.PHONY: install
install: all
mkdir -p $(DESTDIR)$(BINDIR)
cp -p badwolf $(DESTDIR)$(BINDIR)/
mkdir -p $(DESTDIR)$(MANDIR)/man1
cp -p badwolf.1 $(DESTDIR)$(MANDIR)/man1/
mkdir -p $(DESTDIR)$(DATADIR)/locale
cp -r locale/ $(DESTDIR)$(DATADIR)/
cp interface.css $(DESTDIR)$(DATADIR)/
mkdir -p $(DESTDIR)$(APPSDIR)
cp -p badwolf.desktop $(DESTDIR)$(APPSDIR)/
mkdir -p $(DESTDIR)$(DOCDIR)
cp -p $(DOCS) $(DESTDIR)$(DOCDIR)/
mkdir -p $(DESTDIR)$(PREFIX)/share
cp -r icons $(DESTDIR)$(PREFIX)/share/
@printf '\nNote: An example AppArmor profile has been installed at '$(DOCDIR)/usr.bin.badwolf'\n'

.PHONY: clean
clean:
rm -fr locale $(OBJS) $(OBJS_test) $(EXE) $(EXE_test)

format: *.c *.h
clang-format -style=file -assume-filename=.clang-format -i *.c *.h
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# BadWolf
Minimalist and privacy-oriented WebKitGTK+ browser.

Homepage: <https://hacktivis.me/projects/badwolf>

```
Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
SPDX-License-Identifier: BSD-3-Clause
```

The name is a reference to BBC’s Doctor Who Tv serie, I took it simply because I wanted to have a specie in the name, like some other web browsers do, but doesn’t go into the “gentle” zone.

## Differencies
Comparing from other small WebKit browsers for unixes found in the wild:

- Independent of environment, should just work if GTK and WebKitGTK does
- Storing data should be:
- explicit and optionnal (ie. Applying preferences doesn't imply Saving to disk)
- not queryabe by WebKit (so the web can't use it)
- done in a standard format (like XBEL for bookmarks)
- Static UI, no element should be added at runtime, this is to avoid potential tracking via viewport changes
- Small codebase, should be possible to read and understand it completely over an afternoon.
- Does not use modal editing (from vi) as that was designed for editing, not browsing
- UTF-8 encoding by default

Motivation from other clients <https://hacktivis.me/articles/www-client%20are%20broken>

## Contributing
### Translations
You need to have gettext installed. If you want a GUI, poedit exists and Weblate is a good web platform that I might consider hosting at some point.

- Syncing POT file with the source code: ``make po/messages.pot``
- Syncing PO file with the POT file: ``make po/de.po``
- Initialising a new PO file (example for German, `de_DE`): ``msginit -l de_DE -i po/messages.pot -o po/de.po``

## Contacts / Discussions
- IRC: `#badwolf-browser` on FreeNode
- Matrix (bridge): <https://matrix.to/#/#freenode_#badwolf-browser:matrix.org>

## Repositories
### git
- Main: <https://hacktivis.me/git/badwolf/>, <git://hacktivis.me/git/badwolf.git>
- Mirror: <https://gitlab.com/lanodan/badWolf.git>, this one can also be used if you prefer tickets/PRs over emails

### release assets
- Main: <https://hacktivis.me/releases/>
- Mirror: <https://gitlab.com/lanodan/badWolf/tags>

- `*.tar.*` files are tarballs archives to be extracted with a program like `tar(1)`, GNU tar and LibArchive bsdtar are known to work.
- `*.sig` files are OpenPGP signatures done with my [key](https://hacktivis.me/key.asc)(`DDC9 237C 14CF 6F4D D847 F6B3 90D9 3ACC FEFF 61AE`).
- `*.sign` files are minisign (OpenBSD `signify(1)` compatible) signatures, they key used for it can be found at <https://hacktivis.me/release/signify/> as well as other places (feel free to ping me to get it)

## Manual Installation
Dependencies are:
- C11 Compiler (such as clang or gcc)
- [WebKitGTK](https://webkitgtk.org/), only the latest stable is supported
- POSIX make with extension for shell in variables (works with GNU, {Net,Free,Open}BSD)
- A pkg-config implementation (pkgconf is recommended)
- (optionnal) gettext implementation (such as GNU Gettext)

Compilation is done with `make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support.

You'll also need inkscape (command line only) if you want to regenerate the icons, for example after modifying them or adding a new size. These aren't needed for normal installation as it is bundled.

## Notes
Most of the privacy/security stuff will be done with patches against WebKit as quite a lot isn’t into [WebKitSettings](https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html) and with generic WebKit extensions that should be resuseable.
110 changes: 110 additions & 0 deletions badwolf.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
./" BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
./" Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
./" SPDX-License-Identifier: BSD-3-Clause
.Dd 2019-10-31
.Dt BADWOLF 1
.Sh NAME
.Nm badwolf
.Nd minimalist and privacy-oriented WebkitGTK browser
.Sh SYNOPSIS
.Nm
.Op Ar webkit/gtk options
.Op Ar URLs or paths
.Sh DESCRIPTION
.Nm
is a minimalist browser that cares about privacy, it is based on WebKitGTK and thus also accepts WebKitGTK (and dependencies) flags and environment variables, unfortunately there doesn't seems to be manpages for theses.
.Pp
Runtime configuration specific to
.Nm
will probably get added at a later release.
.Sh KEYBINDINGS
The following section lists the keybinding by their action, each item is described by the widget the focus is on or
.Aq any
if it works for the whole window, followed by the keybind it grabs.
.Bl -tag -width Ds
.It webview Ctrl-Scroll
Zooms the webpage in/out.
.It webview Ctrl-0
Resets webpage zoom to 100%.
.It any Ctrl-t
Creates a new tab (in a new session, similar as pressing the button)
.It browser Ctrl-F4, browser Alt-d
Closes the current tab
.It browser Ctrl-f
Focuses on the search entry
.It browser Ctrl-l
Focuses on the location(URL) entry
.It browser Ctrl-Shift-r / Ctrl-r, browser F5
Reloads the content in the current tab (with/without clearing cache)
.It browser Escape
Stops loading the content in the current tab
.It browser F7
Toggles caret browsing.
.It browser F12
Opens the web inspector.
.It browser Ctrl-[ / Ctrl-]
Go back/forward in current tab’s history
.It browser Ctrl-p
Print the current page. (spawns a dialog)
.It any Alt-Left / Alt-Right
Go to the previous/next tab
.It any F1
Shows the about dialog
.It any Alt-n
Where n is any numeric-row key.
Go to the n-th tab, 0 goes to the last one.
.El
.Ss DEFAULT ONES
Here is a incomplete list of the default Webkit/GTK keybindings:
.Bl -tag -width Ds
.It any Ctrl-PageUp / Ctrl-PageDown
Go to the previous/next tab
.It search Ctrl-g / Ctrl-Shift-g
When the search box is focused it goes to the Next/Previous search term.
.It search Escape
Cancels current search
.El
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It Ev BADWOLF_L10N
A colon-separated list in the form lang_COUNTRY where lang is in ISO-639 and COUNTRY in ISO-3166.
For example
.Ic BADWOLF_L10N="en_GB:fr_FR:de_DE" .
When this variable isn't set, spelling isn't activated.
A more generic variable name is also intended to be used in the future.
.El
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa ${XDG_DATA_HOME:-$HOME/.local/share}/badwolf/webkit-web-extensions/
Directory containing the
.Lk https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebExtension.html WebKitWebExtensions
to be loaded into
.Nm . Note: They aren't the JavaScript-based Web-Extensions supported by Firefox or Chrome, but native code in shared objects using the WebKitGTK API.
.Pp
Examples of useful extensions may be found at:
.Bl -item -compact
.Lk https://hacktivis.me/git/badwolf-extensions
.Lk https://github.com/jun7/wyebadblock
.El
.It Pa ${DATADIR:-/usr/local/share}/badwolf/interface.css
.It Pa ${XDG_DATA_HOME:-$HOME/.local/share}/badwolf/interface.css
CSS files (respectively system and user-level) for styling badwolf interface.
See
.Lk https://developer.gnome.org/gtk3/stable/chap-css-properties.html
for the properties being available.
.Pp
For testing your styles I would recommend using the
.Ev GTK_DEBUG=interactive
environment variable on launching
.Nm
and going to the CSS tab.
.El
.Sh AUTHORS
.An Haelwenn (lanodan) Monnier Aq Mt [email protected]
.Sh BUGS
You can submit contributions or tickets to
.Lk https://gitlab.com/lanodan/badwolf
or
.Mt [email protected] ,
with
.Xr git-send-email 1 for patches.
Loading

0 comments on commit bcd73ae

Please sign in to comment.