diff --git a/.gitignore b/.gitignore index e1a264d..c3f3d95 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,5 @@ db.sqlite .env.testing /Public /Resources -./feather -docker/datadir -ssh +/Tests/Public +/Tests/Resources diff --git a/Package.resolved b/Package.resolved index 12bb20e..280fd05 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,15 +1,6 @@ { "object": { "pins": [ - { - "package": "ALanguageParser", - "repositoryURL": "https://github.com/matsoftware/accept-language-parser", - "state": { - "branch": null, - "revision": "0a6d89e0159b2f926b35a9f6ee28b6f9c1e84a1b", - "version": "1.0.0" - } - }, { "package": "async-http-client", "repositoryURL": "https://github.com/swift-server/async-http-client.git", @@ -51,8 +42,8 @@ "repositoryURL": "https://github.com/vapor/fluent-kit.git", "state": { "branch": null, - "revision": "d5273e8d050c51dd7e1d3a4dab08fe32ec9ffffa", - "version": "1.20.0" + "revision": "9c7fbdc931ef6afa2dcd45edf253d25cadbbd5fc", + "version": "1.22.0" } }, { @@ -65,21 +56,12 @@ } }, { - "package": "Ink", - "repositoryURL": "https://github.com/JohnSundell/Ink", + "package": "jmespath.swift", + "repositoryURL": "https://github.com/adam-fowler/jmespath.swift.git", "state": { "branch": null, - "revision": "77c3d8953374a9cf5418ef0bd7108524999de85a", - "version": "0.5.1" - } - }, - { - "package": "Kanna", - "repositoryURL": "https://github.com/tid-kijyun/Kanna.git", - "state": { - "branch": null, - "revision": "f9e4922223dd0d3dfbf02ca70812cf5531fc0593", - "version": "5.2.7" + "revision": "4513d319c4aaa6c3b2ac18e1e6566a803515ad91", + "version": "1.0.2" } }, { @@ -109,6 +91,33 @@ "version": "1.3.2" } }, + { + "package": "mail", + "repositoryURL": "https://github.com/binarybirds/mail", + "state": { + "branch": null, + "revision": "f1dc8be5ea3b80952fb000b32d69609961b0b3bf", + "version": "0.0.2" + } + }, + { + "package": "mail-aws-driver", + "repositoryURL": "https://github.com/binarybirds/mail-aws-driver", + "state": { + "branch": null, + "revision": "8fa1e8056a44170f2baef95fb06da609986180e9", + "version": "0.0.1" + } + }, + { + "package": "mail-kit", + "repositoryURL": "https://github.com/binarybirds/mail-kit.git", + "state": { + "branch": null, + "revision": "3432472362c20e1537da8047c134f223b59dadd2", + "version": "0.0.1" + } + }, { "package": "multipart-kit", "repositoryURL": "https://github.com/vapor/multipart-kit.git", @@ -128,21 +137,21 @@ } }, { - "package": "spec", - "repositoryURL": "https://github.com/binarybirds/spec", + "package": "soto", + "repositoryURL": "https://github.com/soto-project/soto.git", "state": { "branch": null, - "revision": "aecab17649ac83133daa98e54620911773227946", - "version": "1.2.2" + "revision": "b98994beabdced18cbedbe50e947e6f2c8e0d602", + "version": "5.12.1" } }, { - "package": "Splash", - "repositoryURL": "https://github.com/JohnSundell/Splash", + "package": "soto-core", + "repositoryURL": "https://github.com/soto-project/soto-core.git", "state": { "branch": null, - "revision": "7f4df436eb78fe64fe2c32c58006e9949fa28ad8", - "version": "0.16.0" + "revision": "a216ea49b9ff2480ccbc5880b1aa648032433798", + "version": "5.9.2" } }, { @@ -195,8 +204,8 @@ "repositoryURL": "https://github.com/binarybirds/swift-html", "state": { "branch": null, - "revision": "cb5a799352660ee5b41d369c9210e5e2dc0f91f9", - "version": "1.6.1" + "revision": "b2620a6747fd664c892cfd20ff38d4c445bfa0d3", + "version": "1.6.8" } }, { @@ -262,15 +271,6 @@ "version": "1.11.4" } }, - { - "package": "UAParserSwift", - "repositoryURL": "https://github.com/malcommac/UAParserSwift", - "state": { - "branch": null, - "revision": "a8057c7cff60db2cdf31d0a0a68ce430754ab64e", - "version": "1.2.1" - } - }, { "package": "vapor", "repositoryURL": "https://github.com/vapor/vapor", diff --git a/Package.swift b/Package.swift index 0d310cf..4b06f8e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,64 +1,33 @@ // swift-tools-version:5.5 import PackageDescription -let isLocalDevMode = false - -var dependencies: [Package.Dependency] = [ - .package(url: "https://github.com/vapor/fluent-sqlite-driver", from: "4.0.0"), - .package(url: "https://github.com/binarybirds/liquid-local-driver", from: "1.3.0"), -] - -if isLocalDevMode { - dependencies += [ - .package(path: "../feather-core"), - .package(path: "../analytics-module"), - .package(path: "../aggregator-module"), - .package(path: "../blog-module"), - .package(path: "../markdown-module"), - .package(path: "../redirect-module"), - .package(path: "../swifty-module"), - ] -} -else { - dependencies += [ - .package(url: "https://github.com/feathercms/feather-core", .branch("dev")), - .package(url: "https://github.com/feathercms/analytics-module", .branch("dev")), - .package(url: "https://github.com/feathercms/aggregator-module", .branch("dev")), - .package(url: "https://github.com/feathercms/blog-module", .branch("dev")), - .package(url: "https://github.com/feathercms/markdown-module", .branch("dev")), - .package(url: "https://github.com/feathercms/redirect-module", .branch("dev")), - .package(url: "https://github.com/feathercms/swifty-module", .branch("dev")), - ] -} - let package = Package( - name: "feather", + name: "app", platforms: [ .macOS(.v12) ], products: [ - .executable(name: "Feather", targets: ["Feather"]), + + ], + dependencies: [ + .package(path: "../feather-core"), + .package(path: "../user-module"), + .package(path: "../web-module"), + .package(url: "https://github.com/vapor/fluent-sqlite-driver", from: "4.0.0"), + .package(url: "https://github.com/binarybirds/liquid-local-driver", from: "1.3.0"), + .package(url: "https://github.com/binarybirds/mail-aws-driver", from: "0.0.1"), ], - dependencies: dependencies, targets: [ - .executableTarget(name: "Feather", dependencies: [ - .product(name: "FeatherCore", package: "feather-core"), + + .executableTarget(name: "App", dependencies: [ + + .product(name: "Feather", package: "feather-core"), + .product(name: "UserModule", package: "user-module"), + .product(name: "WebModule", package: "web-module"), + .product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver"), .product(name: "LiquidLocalDriver", package: "liquid-local-driver"), - .product(name: "AnalyticsModule", package: "analytics-module"), - .product(name: "AggregatorModule", package: "aggregator-module"), - .product(name: "BlogModule", package: "blog-module"), - .product(name: "RedirectModule", package: "redirect-module"), - .product(name: "SwiftyModule", package: "swifty-module"), - .product(name: "MarkdownModule", package: "markdown-module"), - ], exclude: [ - "Modules/README.md", - ], swiftSettings: [ - .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release)) + .product(name: "MailAwsDriver", package: "mail-aws-driver"), ]), -// .testTarget(name: "FeatherTests", dependencies: [ -// .target(name: "Feather"), -// .product(name: "FeatherTest", package: "feather-core") -// ]) ] ) diff --git a/README.md b/README.md old mode 100755 new mode 100644 index b5d0372..93612f5 --- a/README.md +++ b/README.md @@ -1,154 +1,3 @@ -## ⚠️⚠️⚠️ Under construction ⚠️⚠️⚠️ +# Blog module -Feather CMS is currently under construction, just a few things about the new version: - -- 100% async / await support (requires macOS 12+ or Linux) -- Leaf / Tau is completely replaced with [SwiftHtml](https://github.com/binarybirds/swift-html) -- Simplified core library [FeatherCore](https://github.com/feathercms/feather-core) - - -![Feather CMS](https://github.com/FeatherCMS/feather/blob/main/Assets/GitHub-Lead.png?raw=true) - -# Feather CMS 🪶 - -🪶 Feather is a modern Swift-based content management system powered by Vapor 4. - -💬 Click to join the chat on [Discord](https://discord.gg/wMSkxCUXAD). - - -## Requirements - -To use Feather you'll have to install **Swift 5.5** or greater. - -If you need help installing Swift, you should follow the official instructions available on [swift.org](https://swift.org/download/#releases). - - -## Setup & environment - -Clone or download the source files using the [Feather](https://github.com/feathercms/feather/) repository. - -```shell -git clone https://github.com/FeatherCMS/feather.git -``` -Change the current working directory (located under the target setting when using [Xcode](https://theswiftdev.com/beginners-guide-to-server-side-swift-using-vapor-4/)) to the project directory. - -```shell -cd feather -``` - -Create a dotenv file ( `.env` or `.env.development`) based on your environment) and config the following values. - -```shell -# the base path (absolute) of the working directory -FEATHER_WORK_DIR="/path/to/feather/" - -# Optional Feather related env variables - -# the hostname (domain) of your web server, default localhost -FEATHER_HOSTNAME=feathercms.com -# the port to listen on, default 8080 -FEATHER_PORT=80 -# use HTTPS, default false (needs cert & key setup on the Vapor app) -FEATHER_HTTPS=true -# maximum body size for file uploads -FEATHER_MAX_BODY_SIZE=10mb -# disable file middleware, default false (if disabled you can serve files with nginx) -FEATHER_DISABLE_FILE_MIDDLEWARE=true -# disable the session auth middleware for api endpoints (recommended for production) -FEATHER_DISABLE_API_SESSION_MIDDLEWARE=true -``` - -You can run the `make env` command to quickly create a development environment with the curret directory as a base path. - -Start the server using the `swift run Feather` command (alternatively you can use the `make run` command). - - - -### Notes about using Xcode - -- ⚠️ Warning: DO NOT USE the `swift package generate-xcodeproj` command, it's deprecated. -- ⚠️ Make sure that you open the project by double clicking the `Package.swift` file. -- ⚠️ Set the [custom working directory](https://theswiftdev.com/beginners-guide-to-server-side-swift-using-vapor-4/) for the `Feather` scheme to the root of the project directory. -- ⚠️ If needed setup a [post-action script](https://theswiftdev.com/10-short-advices-that-will-make-you-a-better-vapor-developer-right-away/) to automatically shut-down previous server instances (to avoid address in use errors). -- ✅ Build and run the project as usual and enjoy your Feather powered site. - - - -## Configuration - -The [FeatherCore framework](https://github.com/feathercms/feather-core) provides all the necessary API to configure your Feather application. - - - -### Database driver - -By default Feather uses the SQLite driver, but it is possible to use PostgreSQL, MySQL (MariaDB) or even MongoDB as your database driver through the [Fluent](https://docs.vapor.codes/4.0/fluent/overview/) framework. - -You should follow the instructions using the official Vapor docs to setup the right driver, but please note that the preferred drivers are PosgreSQL and SQLite for really small projects and development purposes. - - - -### File storage driver - -The [Liquid framework](https://github.com/binarybirds/liquid/) is an abstract file storage library that works with a local file storage driver, but it is also possible to use Amazon S3 as a cloud-based solution. - -You can replace the default local driver with the [S3 driver](https://github.com/BinaryBirds/liquid-aws-s3-driver), which is powered by the [Soto for AWS](https://github.com/soto-project/soto) SDK. - - - -### Modules - -Feather is a modular CMS system, you can add new modules as Swift package dependencies or place them under the Modules directory. - -Feather gives you just a few **core modules**, they provide basic functionalies such as the route system, web frontend, admin interface or API layer. - -The usage of [other modules](https://github.com/feathercms/?q=-module&type=all&language=swift&sort=name) can be completely customized (just alter the SPM dependency & configuration file). - -💡 Feel free to fork this repository and create your own configuration as per needed. - - -## Using Feather CMS - -### Installation - -The first time when you open your page Feather will run in install mode. - -During this phase (behind the scenes): -- all the required database structures will be created (database migration will run automatically). -- Bundled resources (public files) will be copied to the project folder (if needed). -- All the necesseary models will be installed (persisted) using the configured database driver. -- All the required assets will be uploaded to the file storage (using the configured storage driver). -- The "root" user account will be created, you have to provide yor own credentials during this step. -- Sample content for the blog module will be created (you can opt-out from this). -- You'll be redirected to the welcome page. - -Now you are ready to use your Feather-based website. - - -#### User guide - -You can read more about how to use Feather in the [wiki](https://github.com/FeatherCMS/feather/wiki). - - -## Contribution and support - -🪶 Feather is an open source software and your contributions are more than welcome. - -🔀 If you wish to make a change, please open a [Pull Request](https://github.com/FeatherCMS/feather/pulls). - -🙏 Please don't hesitate to send your feedbacks, thoughts and ideas about Feather. - -## Address already in use error - -You can use the following command to kill the process listening on the 8080 port. - -```shell -lsof -i :8080 -sTCP:LISTEN |awk 'NR > 1 {print $2}'|xargs kill -15 -``` - -Tip: when using Xcode, edit the scheme and add this as a pre-action script. - -## Credits - -- [Vapor](https://vapor.codes/) - underlying framework -- [Feather icons](https://feathericons.com/) - Simply beautiful open source icons +This module is reponsible for providing a simple blog platform for Feather CMS. diff --git a/Sources/Feather/main.swift b/Sources/App/main.swift similarity index 61% rename from Sources/Feather/main.swift rename to Sources/App/main.swift index b0a42d7..a915295 100644 --- a/Sources/Feather/main.swift +++ b/Sources/App/main.swift @@ -1,19 +1,20 @@ // -// main.swift -// Feather +// File.swift +// // -// Created by Tibor Bodecs on 2019. 12. 17.. +// Created by Tibor Bodecs on 2022. 02. 23.. // -@_exported import FeatherCore +@_exported import FeatherRestKit + +import Feather + import FluentSQLiteDriver import LiquidLocalDriver -import AnalyticsModule -import AggregatorModule -import BlogModule -import MarkdownModule -import RedirectModule -import SwiftyModule +import MailAwsDriver + +import WebModule +import UserModule /// https://github.com/vapor/fluent/blob/main/Sources/Fluent/Exports.swift infix operator ~~ @@ -22,7 +23,6 @@ infix operator !~ infix operator !=~ infix operator !~= - public func configure(_ app: Application) throws { app.feather.boot() @@ -31,17 +31,13 @@ public func configure(_ app: Application) throws { app.fileStorages.use(.local(publicUrl: app.feather.baseUrl, publicPath: app.feather.paths.public.path, workDirectory: Feather.Directories.assets), as: .local) - - let modules: [FeatherModule] = [ - AnalyticsBuilder(), - AggregatorBuilder(), - BlogBuilder(), - MarkdownBuilder(), - RedirectBuilder(), - SwiftyBuilder(), - ].map { $0.build() } - - try app.feather.start(modules) + + app.mailProviders.use(.ses(credentialProvider: .default, region: .eucentral1), as: .ses) + + try app.feather.start([ + UserBuilder().build(), + WebBuilder().build(), + ]) } var env = try Environment.detect() diff --git a/Sources/Feather/Modules/README.md b/Sources/Feather/Modules/README.md deleted file mode 100755 index 434db58..0000000 --- a/Sources/Feather/Modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Feather modules 🪶 - -You can place your own local modules here, or you can pick from the official [Feather modules](https://github.com/FeatherCMS/?q=-module&type=all&language=swift&sort=name).