parent
88364fc096
commit
401d5ef679
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"originHash" : "39da4f005434f990c0dece54faba957e7edc27104875be011d48221ad538739d",
|
||||
"originHash" : "d54afbeb9301d3df649cfb4bef5794fb7abe1c6aa826c3651df7253a5656b124",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "async-http-client",
|
||||
|
|
@ -28,6 +28,33 @@
|
|||
"version" : "4.15.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent.git",
|
||||
"state" : {
|
||||
"revision" : "223b27d04ab2b51c25503c9922eecbcdf6c12f89",
|
||||
"version" : "4.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent-kit.git",
|
||||
"state" : {
|
||||
"revision" : "8baacd7e8f7ebf68886c496b43bbe6cdcc5b57e0",
|
||||
"version" : "1.52.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent-postgres-driver",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent-postgres-driver.git",
|
||||
"state" : {
|
||||
"revision" : "095bc5a17ab3363167f4becb270b6f8eb790481c",
|
||||
"version" : "2.10.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "leaf",
|
||||
"kind" : "remoteSourceControl",
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "ManagableUsers",
|
||||
name: "ManageableUsers",
|
||||
platforms: [
|
||||
.macOS(.v13)
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "ManagableUsers",
|
||||
targets: ["ManagableUsers"]
|
||||
name: "ManageableUsers",
|
||||
targets: ["ManageableUsers"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
|
|
@ -28,7 +28,7 @@ let package = Package(
|
|||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "ManagableUsers",
|
||||
name: "ManageableUsers",
|
||||
dependencies: [
|
||||
.product(name: "Fluent", package: "fluent"),
|
||||
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
|
||||
|
|
@ -43,7 +43,7 @@ let package = Package(
|
|||
.executableTarget(
|
||||
name: "SampleApp",
|
||||
dependencies: [
|
||||
.target(name: "ManagableUsers"),
|
||||
.target(name: "ManageableUsers"),
|
||||
],
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
|
|
|
|||
18
README.md
18
README.md
|
|
@ -1,4 +1,4 @@
|
|||
# ManagableUsers
|
||||
# ManageableUsers
|
||||
|
||||
A package providing basic user management when using the Vapor web framework and a PostgreSQL database.
|
||||
|
||||
|
|
@ -76,34 +76,34 @@ Create a new Vapor project, or reuse an existing one.
|
|||
|
||||
### Dependencies
|
||||
|
||||
Add dependency on `managable-users` by adding the package to `Package.swift` as
|
||||
Add dependency on `manageable-users` by adding the package to `Package.swift` as
|
||||
```swift
|
||||
.package(url: "https://git.carlberg.org/public/manageable-users.git", from: "1.0.0"),
|
||||
```
|
||||
|
||||
…and adding to the executable target's dependencies as
|
||||
```swift
|
||||
.product(name: "ManagableUsers", package: "managable-users"),
|
||||
.product(name: "ManageableUsers", package: "manageable-users"),
|
||||
``
|
||||
|
||||
Copy the contents of the `Resources/Views` folder from the `managable-users` into the `Resources/Views` folder
|
||||
Copy the contents of the `Resources/Views` folder from the `manageable-users` into the `Resources/Views` folder
|
||||
in the new project, and also copy the contents of the `Public` folder into the `Public` folder.
|
||||
|
||||
In the `configure.swift` file, add the import
|
||||
```swift
|
||||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
```
|
||||
|
||||
…and add
|
||||
```swift
|
||||
try await ManagableUsers.configure (app)
|
||||
try await ManageableUsers.configure (app)
|
||||
```
|
||||
|
||||
into the `configure()` function.
|
||||
|
||||
In the `routes.swift` file, add the import
|
||||
```swift
|
||||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
```
|
||||
|
||||
…and replace everything in the `routes()` function with
|
||||
|
|
@ -137,13 +137,13 @@ To use a consistent look, use `base.leaf` in your Leaf templates for pages.
|
|||
To add items to the main menu, do that in `configure.swift` by replacing
|
||||
|
||||
```swift
|
||||
try await ManagableUsers.configure (app)
|
||||
try await ManageableUsers.configure (app)
|
||||
```
|
||||
|
||||
with something like
|
||||
|
||||
```swift
|
||||
try await ManagableUsers.configure(app, mainMenu: [MenuItem (section: "inventory", path: "inventory", name: "Inventory")])
|
||||
try await ManageableUsers.configure(app, mainMenu: [MenuItem (section: "inventory", path: "inventory", name: "Inventory")])
|
||||
```
|
||||
|
||||
For `MenuItem`
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import Fluent
|
|||
import FluentPostgresDriver
|
||||
import SwiftSMTPVapor
|
||||
|
||||
public struct ManagableUsers {
|
||||
public struct ManageableUsers {
|
||||
public static func configure (_ app: Application, mainMenu: [MenuItem] = [], homePageName: String = "Home", userAdminPageName: String = "User Administration") async throws {
|
||||
app.databases.use(DatabaseConfigurationFactory.postgres(configuration: .init(
|
||||
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
import Vapor
|
||||
|
||||
public func configure (_ app: Application) async throws {
|
||||
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
||||
|
||||
try await ManagableUsers.configure (app)
|
||||
try await ManageableUsers.configure (app)
|
||||
|
||||
try routes(app)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
import Vapor
|
||||
|
||||
func routes(_ app: Application) throws {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
@testable import SampleApp
|
||||
import VaporTesting
|
||||
import SQLKit
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
@testable import SampleApp
|
||||
import ManagableUsers
|
||||
import ManageableUsers
|
||||
import VaporTesting
|
||||
import SQLKit
|
||||
import Testing
|
||||
|
|
|
|||
Loading…
Reference in New Issue