Commit Graph

130 Commits

Author SHA1 Message Date
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
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
Matt Baer bf44236748 Bump version to 0.2.1 2018-11-12 21:02:45 -05:00
Matt Baer 002d0e6309 Bump version to 0.2 2018-11-11 18:37:30 -05:00
Matt Baer 7bc873580c Move key generation to app from keys.sh
This eliminates an external dependency needed for install, and ensures
the app can run on Windows.
2018-11-11 17:52:24 -05:00
Matt Baer 1cb593fd8c Fix unnecessarily connecting to DB after multi-user config 2018-11-10 20:43:00 -05:00
Matt Baer ae019e4dc3 Show error when ListenAndServe fails
and exit with 1
2018-11-10 20:41:35 -05:00
Matt Baer a6478f1b1d Create blog during config for single-user blogs 2018-11-09 22:16:13 -05:00
Matt Baer 5a062eb437 Include flashes on signup page 2018-11-09 21:14:22 -05:00
Matt Baer be31da2fe7 Tweak capitalization / spacing in Write Freely name
This affects nodeinfo and ActivityPub requests
2018-11-08 13:37:42 -05:00
Matt Baer 55ada67170 Fill in remaining missing pieces
- Database schema changes, removing obsolete custom domain-related code
- Missing user structs
- Setup verbiage changes
- Missing routes
- Missing error messages
2018-11-08 01:33:26 -05:00
Matt Baer 86e7ba2579 Add editor
This includes the '/' route handler
2018-11-08 00:11:42 -05:00
Matt Baer a30fc5b52b Add handler, page, template loading 2018-11-07 23:50:50 -05:00
Matt Baer a3b7b260c5 Add debugging flag
This also includes a new Dev config options
2018-11-07 22:13:16 -05:00
Matt Baer cc224db6e6 Add interactive configuration
This adds a new --config flag and rearranges some config fields.
2018-10-25 09:15:10 -04:00
Matt Baer 6bdb7a1c1c Output config saving errors 2018-10-24 14:21:42 -04:00
Matt Baer 1a6f61690e Add NodeInfo endpoints
Includes new instance stats and the new option to show user stats, as
well.
2018-10-17 19:25:09 -04:00
Matt Baer 0c1e1dd57e Add data layer
This includes config changes, collections, posts, some post rendering
funcs, and actual database connection when the server starts up.
2018-10-16 22:31:27 -04:00
Matt Baer 62abc11142 Add web session management 2018-10-16 20:31:07 -04:00
Matt Baer af601d7b0c Add --create-config flag to generate default config 2018-10-16 16:57:55 -04:00
Matt Baer 16473c97b7 Create basic server
Includes app config and some initialization
2018-10-15 14:44:15 -04:00