Commit Graph

69 Commits

Author SHA1 Message Date
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 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 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 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
Matt Baer 9016f87041 Add --reset-pass option for admin pass reset
Usage: writefreely --reset-pass <username>

This closes #25, closes T534
2018-11-14 15:03:22 -05:00
Matt Baer b1686b1d46 Add --init-db flag to create schema in app
Part of T530
2018-11-13 13:04:52 -05:00