Commit Graph

171 Commits

Author SHA1 Message Date
Matt Baer ff7828c558 Link hashtags to Reader when Chorus mode enabled
instead of linking to posts only on a user's blog.

Ref T681
2019-08-07 09:40:07 -04:00
Matt Baer 1a80cd3c02 Add site-wide navigation on colls when chorus = true
This adds a new config value: `chorus` that signifies an instance is
more about the Reader view than individual blogs / writers. When
enabled, user navigation will show on all pages, including About,
Reader, and Privacy (ref T680).

It also uses different collection templates that keep the instance-wide
navigation at the top of the page, instead of the author's name --
again, branded more for the collective than the individual.

Ref T681
2019-08-07 09:00:16 -04:00
Matt Baer d752d29b4b
Merge pull request #151 from writeas/custom-logging
Let Apper set request log format
2019-08-05 10:58:43 -04:00
Matt Baer 81847fbbcc Land on Blogs page when SimpleNav is enabled
This shows the Blogs page instead of the Editor to logged in users on
the `/` path when the new `simple_nav` config option is enabled.

Ref T680
2019-08-05 09:27:51 -04:00
Matt Baer 5953a50f4a Let Apper set request log format
This adds a new ReqLog() func to the Apper interface that'll return the
log message for incoming requests.

Ref T649
2019-08-01 16:12:22 -04:00
Matt Baer a75b45f060 Support configuring default collection visibility
This adds a new `default_visibility` config value that lets an instance
admin set the visibility of newly created collections.

Ref T675
2019-07-31 22:18:40 -04:00
Matt Baer 3346e735d3 Fix autocert insecure server redirect
This fixes certificate validation, while keeping HTTP -> HTTPS
redirection.

Ref T542
2019-07-20 21:38:02 -04:00
Matt Baer 42386beabc Fix autocert HostPolicy
Previously, this would pass in the instance's full (and invalid) URL.
Now it passes only the host name.

Ref T542
2019-07-20 21:37:27 -04:00
Matt Baer 36fb7ecb2b Support automatically generated certificates
This adds a new config option in the `[server]` section: `autocert`.
When true, WF will automatically generate certificates instead of using
ones from the provided cert path. However, all generated certificates
will be stored in the configured `tls_cert_path`.

Ref T542
2019-07-20 20:49:20 -04:00
Matt Baer 3b079810bb Accept Apper in writefreely.ResetPassword()
instead of *App
2019-07-03 14:39:43 -04:00
Matt Baer 79cf6ce0eb Accept Apper in writefreely.Migrate()
instead of *App
2019-07-03 14:39:05 -04:00
Matt Baer 7aaff778da
Merge pull request #123 from writeas/private-instance
Private instances

Resolves T576
2019-07-01 19:14:20 -04:00
Matt Baer 7240bf0cdc
Merge pull request #131 from writeas/customize-landing
Customize landing page

Resolves T565
2019-07-01 19:12:58 -04:00
Matt Baer 5757407994 Bump version to 0.10.0 2019-07-01 15:20:29 -04:00
Matt Baer 18bafadc43
Merge pull request #127 from writeas/shorter-config-process
Shorter config process
2019-07-01 14:15:41 -04:00
Matt Baer c3f3eb0a65 Rename getLandingPage -> getLandingBody
This makes the naming scheme more consistent with other funcs.

Ref T565
2019-06-27 22:22:21 -04:00
Matt Baer a72ce2ef29 Make landing page dynamic
This enables admins to customize their landing / home page via the Admin
dashboard -- including the text at the top of the page and the section
below it. It keeps the current default text, falling back to it if the
user hasn't overwritten it.

Ref T565
2019-06-27 17:06:37 -04:00
Matt Baer aedb05080c Support ?landing=1 to always show landing page
This supports admins previewing changes to the landing page.

Ref T565
2019-06-27 16:38:24 -04:00
Michael Demetriou 6506709fbc Merge branch 'develop' into shorter-config-process
Move flag parsing to main.go as per the issue description
2019-06-21 12:07:01 +03:00
Michael Demetriou efbef83362 make sure app exits after error in --sections argument 2019-06-21 10:40:40 +03:00
Michael Demetriou 07fe366c15 Fix T657: add --sections argument to allow partial configuration.
Use the split argument list (slice) just for validation purposes
as it's substantially easier to do `.contains` in a string instead
of a slice. As such, pass the `configSections` arguments to
`Configure()` and check the existence of each one before showing
the options to the user.

An empty argument list is replaced by "server db app" so everything
is there negating the need to check anything else in `Configure()`.
In the same vein the default is "server db app".

The parsing is done in `app.go` alongside the other flags instead
of `main.go` as described in T657.
2019-06-20 23:41:03 +03:00
Michael Demetriou 1d5c396327 Add --sections flag to app.go and pass it to setup.go
Add --sections flag to app.go according to T657, parse them
into a string array (check for invalid arguments and abort)
and pass them to Configure(). For now Configure() doesn't do
anything with them yet.
2019-06-20 23:14:36 +03:00
Matt Baer bbd775bcc6 Always initialize database after --config
Previously, this would only run when configuring an instance for
single-user usage. Now it'll also run when configuring for multi-user
usage.

It also adds a log when the database has already been initialized.
2019-06-20 09:04:52 -04:00
Matt Baer bf989eb696 Hide Reader link on private instance when unauth'd
Ref T576
2019-06-16 20:29:31 -04:00
Matt Baer 36b160b706 Add TODO for multierror 2019-06-14 19:12:14 -04:00
Matt Baer f38a135bfa Remove global hostName var
This moves `hostName` to the `Collection` struct, where it's needed. The
field is populated after successful `GetCollection...()` calls.

This isn't the cleanest way to do things, but it accomplishes the goal.
Eventually, we should accept the AppCfg to `GetCollection...()` calls,
or make them `App` methods, instead of `datastore` methods.

Ref T613
2019-06-14 18:54:04 -04:00
Matt Baer 034db22f8c Break functionality out of Serve() func
- Adds a new interface, Apper, that enables loading and persisting
  instance-level data in new ways
- Converts some initialization funcs to methods
- Exports funcs and methods needed for intialization
- In general, moves a ton of stuff around

Overall, this should maintain all existing functionality, but with the
ability to now better manage a WF instance.

Ref T613
2019-06-13 18:50:23 -04:00
Matt Baer ed4aacd1ac Move static file ServeMux to App struct 2019-06-13 18:45:03 -04:00
Matt Baer eb6349f93a Allow compiling without go-sql-driver/mysql pkg
This ensures the writefreely pkg can be used in other applications that
need to load mysql themselves -- this can be done by building with the
tag: wflib

Ref T613
2019-06-13 13:47:27 -04:00
Matt Baer 758269e3d8 Move key generation and Keychain to key pkg
Ref T613
2019-06-13 13:47:28 -04:00
Matt Baer 584fe4fb93 Support changing default landing path
This adds a new `landing` value in the [app] section of config.ini.
If non-empty, unauthenticated users on multi-user instances will be
redirected to the path given there.

This closes T574
2019-06-13 13:47:27 -04:00
Matt Baer 77c8152786 Break up CreateUser credentials into two args
Now the func takes a username and password instead of a single string.
2019-05-12 18:42:57 -04:00
Matt Baer 9e43b04f04 Make Keychain struct public 2019-05-12 17:20:24 -04:00
Matt Baer d8937e89a8 Make App struct public 2019-05-12 17:19:38 -04:00
Matt Baer 9023d4eb3f Move flag parsing to main package
This exposes setup and admin functions in the writefreely package, and
uses them in the main application, initialized by the flag parsing that
now happens there.

This is the first step towards making `writefreely` usable as a
standalone package.
2019-05-10 11:40:35 -04:00
Matt Baer 771c7acf5f Run migrations on db initialization
This makes it so we can keep all schema changes in the `migrations`
module, instead of adding them there *and* in the schema files. It
fixes #92 and should prevent these kinds of issues in the future.
2019-04-15 13:48:19 -04:00
Matt Baer 7ab5350a94 Bump version to 0.9.0 2019-04-11 21:04:48 -04:00
Matt Baer 9cb0f80921 Support changing instance page titles
Now admins can choose a title for their About and Privacy pages; now
editable through the instance page editor.

This adds `title` and `content_type` fields to the `appcontent` table,
requiring a migration by running `writefreely --migrate`

The content_type field specifies that items we're currently storing in
this table are all "page"s; queries for fetching these have been updated
to filter for this type. In the future, this field will be used to
indicate when an item is a stylesheet (ref T563) or other supported
type.

Ref T566
2019-04-11 13:56:07 -04:00
Matt Baer a850fa14cd Move instance page editing to dedicated section
This adds a "Pages" section to the admin part of the site, and enables
admins to edit the pre-defined About and Privacy pages there, instead of
on the dashboard itself.

It also restructures how these pages get sent around in the backend and
lays the groundwork for dynamically adding static pages. The backend
changes were made with more customization in mind, such as an
instance-wide custom stylesheet (T563).

Ref T566
2019-04-06 13:23:22 -04:00
Matt Baer 32e99d0041 Fix hashes in code blocks rendered as hashtags
Previously, our hashtag parser would indiscriminately replace
hashtag-like text with hashtag HTML -- including in places it shouldn't
have, like inside code blocks. Along with the v1.7.0 changes to
writeas/saturday, this fixes that and closes #6.

As a bonus, strings of #spaceless#hashtags#in#a#row are now rendered
correctly.
2019-02-04 17:50:37 +01:00
Matt Baer c2436a43c5 Merge branch 'master' into develop 2019-02-04 10:14:59 +01:00
Matt Baer e5a00e00f5 Bump version to 0.8.1 2019-02-01 15:10:20 +01:00
Matt Baer 261a6fefd6 Merge branch 'master' into develop 2019-01-27 14:54:50 -05:00
Matt Baer cd752858b7 Fix --create-user usage error message 2019-01-26 11:11:17 -05:00
Matt Baer c11ede53d9 Return error from adminCreateUser()
...instead of using os.Exit(). This makes it more apparent what's going
on, less error-prone, and more consistent with other command logic paths.
2019-01-26 11:06:58 -05:00
Matt Baer 08667d8978 Return error from adminInitDatabase()
...instead of doing os.Exit(). This allows the func to be used in many
places (as it is) and handle success results in different ways.

Previously, this caused the single-user configuration process to exit
prematurely. This fixes that and closes #71.
2019-01-26 10:52:11 -05:00
Matt Baer 47d18b2cc4 Merge branch 'master' into develop 2019-01-24 21:11:47 -05:00
Matt Baer 8b94418d3f Bump version to 0.8.0 2019-01-24 17:10:09 -05:00
Matt Baer 3a6118c207 Set up migrations table on initial setup
This includes the appmigrations table in the schema files, and inserts
the current database version when running writefreely --init-db
2019-01-24 17:08:08 -05:00
Matt Baer eb8f56a6e2 Merge branch 'master' into develop 2019-01-20 17:16:17 -05:00
Matt Baer 5de193a64d Generate encryption keys in configured directory
This makes --gen-keys respect the keys_parent_dir config value
2019-01-20 14:18:09 -05:00
Matt Baer 14f0d446e6 Merge branch 'resource-dirs-config' into develop 2019-01-18 19:18:23 -05:00
Matt Baer 5c19d249b6 Log and exit when templates init fails 2019-01-18 19:17:10 -05:00
Matt Baer 53a51be578 Support configuring resource directories
This adds new configuration values that specify the parent directory of
application resources:

- templates_parent_dir
- static_parent_dir
- pages_parent_dir
- keys_parent_dir

For any values not specified, the application will default to the
current directory.

This closes T560
2019-01-18 19:09:27 -05:00
Matt Baer 6c7ee76768 Support configuring resource directories
This adds new configuration values that specify the parent directory of
application resources:

- templates_parent_dir
- static_parent_dir
- pages_parent_dir
- keys_parent_dir

For any values not specified, the application will default to the
current directory.

This closes T560
2019-01-18 18:57:04 -05:00
Matt Baer 820b0ba6b9 Organize flags and add comments 2019-01-18 11:34:25 -05:00
Matt Baer 47b2155f92 Add --migrate command
This runs database migrations and obviates the need for manually running
changes.

Ref T509
2019-01-17 13:53:03 -05:00
Matt Baer a9dff35f70 Bump version to 0.7.1 2019-01-13 09:41:48 -05:00
Matt Baer 062ae0e16a Initialize db on single-user instance config
This fixes the --config step so that when setting up a single-user
instance for the first time (and creating the admin user as part of the
process), the database is automatically initialized before creating that
user.

This removes the need for the --init-db command after --config when
setting up single-user instances.

It fixes #59: "no such table: users" error during the --config step on
single-user instances that haven't previously run --init-db.
2019-01-13 09:08:47 -05:00
Matt Baer caf976a054 Bump version to 0.7.0 2019-01-07 18:49:16 -05:00
Matt Baer 8a555567a6 Fix tagged posts SQLite query
SQLite doesn't have an `RLIKE` function, so the query for hashtagged
posts was failing before. This adds a `regexp` function to SQLite and
correctly retrieves all posts on a blog with the requested hashtag.

This closes #55
2019-01-07 11:55:23 -05:00
Matt Baer a58a756746 Use driver constants in app.go 2019-01-05 17:51:17 -05:00
Aaron Ogle 3722c6ba79
Only check for username and password if driver type is mysql 2019-01-05 14:59:05 -06:00
Matt Baer fca3019e4b Support building without SQLite support
This adds a new `sqlite` build tag that you should include only if you
want SQLite3 support built in. Both `make run` and `make release` create
builds with SQLite included.
2019-01-03 17:57:06 -05:00
Matt Baer 3ae45bc156 Fix spacing around copyright notices 2018-12-31 01:05:26 -05:00
Matt Baer 739afd2310 Embed schema files in binary
This includes schema.sql and sqlite.sql in the release binary, so they
no longer need to be included in the release archives. This reduces the
number of files extracted, but otherwise leaves all functionality as it
was -- especially the --init-db flag.

Ref T536
2018-12-30 20:10:42 -05:00
Matt Baer 1274914207 Add copyright / license notices to .go files 2018-12-24 12:45:15 -05:00
Matt Baer 1439c8c359 Add --create-user option for regular user
This supports creating a regular user via the command-line.
2018-12-22 10:54:08 -05:00
Matt Baer 5e5b283daf Validate username in admin user creation process
This runs usernames through the same checks as the web interface,
ensuring no invalid user is created, such as user_name or userName.

This closes #49
2018-12-19 21:26:13 -05:00
Matt Baer f99244b93f Factor out admin user creation logic 2018-12-17 18:13:26 -05:00
Matt Baer 11de25237d Fix db.Ping() call 2018-12-15 14:14:09 -05:00
Matt Baer 2178b4abf2 Check database connection on startup 2018-12-13 19:15:09 -05:00
Matt Baer 4b8d5e3e37 Bump version to 0.6.0 2018-12-10 16:17:57 -05:00
Matt Baer 25a68d0c0e Add Reader section
This adds a "Reader" section of the site for admins who want to enable
it for their instance. That means visitors can go to /read and see who
has publicly shared their writing. They can also follow all public posts
via RSS by going to /read/feed/. Writers on an instance with this
`local_timeline` setting enabled can publish to the timeline by going
into their blog settings and choosing the "Public" visibility setting.

The `local_timeline` feature is disabled by default, as is the Public
setting on writer blogs. Enabling it adds a "Reader" navigation item and
enables the reader endpoints. This feature will also consume more
memory, as public posts are cached in memory for 10 minutes.

These changes include code ported over from Read.Write.as, and thus
include some experimental features like filtering public posts by tags
and authors. These features aren't well-tested or complete.

Closes T554
2018-12-10 16:08:07 -05:00
Matt Baer 111945bc5d Add new -c [filename] option for supplying config file
This allows users to load a different configuration file instead of the
default config.ini. It works in combination with other configuration
actions, like --config and --create-config.
2018-12-08 17:49:19 -05:00
Matt Baer ba3d6ae64c Support custom SQLite database file name
Ref T529
2018-12-08 13:34:29 -05:00
Matt Baer 7fab11b3c8 Move initial config loading to its own func 2018-12-08 10:39:25 -05:00
Matt Baer afede80e87 Merge branch 'master' into sqlite-support 2018-12-08 10:34:43 -05:00
Matt Baer df4cd9ed00 Add --create-admin option
This enables automated user creation by running:

  writefreely --create-admin username:password

It will fail if an admin (first user) already exists, which makes this
suitable for use on both for single- and multi-user instances.

Closes T544
2018-12-05 21:41:51 -05:00
Matt Baer 8ceb165020 Bump version to 0.5 2018-12-03 18:57:31 -05:00
Matt Baer f04469beee Fix SQLite concurrency issues
A quick test with ApacheBench revealed that SQLite really can't handle
multiple concurrent requests with the default settings, due to a locked
database. This fixes that by following the suggestions here:
https://github.com/mattn/go-sqlite3#faq

Testing with ab -n 100 -c 5 http://localhost:8080/blog/post shows that
this fixes the issue. But we could improve performance by reducing
writes, like what's mentioned in T545.

Part of T529
2018-12-03 12:05:52 -05:00
Matt Baer 61de04338e Extract out common DB connection logic
T529
2018-12-02 17:21:43 -05:00
Ben Overmyer 6cb86214d7 SQLite support added. 2018-12-01 12:07:25 -06:00
Matt Baer fe78d6d47f Re-add https in log message 2018-11-27 10:55:43 -05:00
Ben Overmyer dd5f6870d8 Add SQLite option for database. 2018-11-26 14:11:10 -06:00
Marcel van der Boom 875c758ba2 Also use bind address on standalone redirect 2018-11-26 18:34:09 +01:00
Marcel van der Boom 543f6c9ae3 Allow 'bind' in config to specify bind address
Minimal changes, definitely WIP, to resolve:

- how to support dualstack when not using localhost?
- net/http package uses string, mentions IP address instead of bind,
  need info.
2018-11-26 16:50:36 +01:00
Matt Baer 42a47258da Bump version to 0.4 2018-11-26 08:37:36 -05:00
Matt Baer f0250d501f Move softwareVer to var() block 2018-11-26 08:37:06 -05:00
Matt Baer 09f5953431 Work as a standalone server, including TLS
This supports running the server on port 443, serving secure pages, with
automatic redirects from the insecure site. It also modifies the
configuration process to better guide users through configuring for
running behind a reverse proxy or as a standalone server.

This closes T537
2018-11-21 18:26:19 -05:00
Matt Baer 77e79acd06 Include About/Privacy page content in page description 2018-11-21 15:04:47 -05:00
Matt Baer be2c7ef86b Show instance stats on About page
This also moves the stats database logic out of nodeinfo.go and into
database.go.
2018-11-21 14:08:47 -05:00
Matt Baer b9d7d4ce24 Change default database name to writefreely
(not writeas)
2018-11-21 13:36:00 -05:00
Matt Baer f3df2b4159 Use and validate database type before connecting
Just the start of changes needed for T529.
2018-11-21 13:10:10 -05:00
Marcel van der Boom b030921691 Don't automatically include "v" from git
- "v" should not be part of the version (softwareVer variable is used
  in other places)
- formatting
2018-11-20 18:14:02 +01:00
Marcel van der Boom c25d0bef67 Get versioninfo from the git repository
Sets value of softwareVer during build
2018-11-20 14:21:13 +01:00
Matt Baer bdc4f270f8 Support editing About and Privacy pages from Admin panel
This allows admin to edit these pages from the web, using Markdown. It
also dynamically loads information on those pages now, and makes loading
`pages` templates a little easier to find in the code / more explicit.

It requires this new schema change:

CREATE TABLE IF NOT EXISTS `appcontent` (
  `id` varchar(36) NOT NULL,
  `content` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This closes T533
2018-11-18 21:58:50 -05:00
Matt Baer ad1180f202 Bump version to 0.3 2018-11-16 13:20:40 -05:00
Matt Baer ed1b77ea3b Support outputting version with -v flag 2018-11-15 14:51:03 -05:00
Matt Baer 0eac9251c0 Add location to MySQL connection string
This should address #23
2018-11-14 17:47:58 -05:00