diff --git a/.gitignore b/.gitignore index 2cc921d..3ef0d07 100755 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ blog-database .buil* Package.resolved PADockerfile_build +.swiftpm diff --git a/Package.swift b/Package.swift index 94e6afd..2deb6b0 100755 --- a/Package.swift +++ b/Package.swift @@ -1,13 +1,26 @@ -// Generated automatically by Perfect Assistant Application -// Date: 2017-10-10 14:39:41 +0000 +// swift-tools-version: 5.7.1 + import PackageDescription let package = Package( name: "Perfect-Blog-Mustache", - targets: [], dependencies: [ - .Package(url: "https://github.com/PerfectlySoft/Perfect-SQLite.git", majorVersion: 3), - .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3), - .Package(url: "https://github.com/PerfectlySoft/Perfect-Mustache.git", majorVersion: 3), - .Package(url: "https://github.com/iamjono/SwiftString.git", majorVersion: 2), - ] + .package(url: "https://github.com/PerfectlySoft/Perfect-SQLite.git", from: "3.0.0"), + .package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"), + .package(url: "https://github.com/PerfectlySoft/Perfect-Mustache.git", from: "3.0.0"), + .package(url: "https://github.com/iamjono/SwiftString.git", from: "2.0.0"), + ], + targets: [ + .executableTarget( + name: "Blog", + dependencies: [ + .product(name: "PerfectSQLite", package: "Perfect-SQLite"), + .product(name: "PerfectHTTPServer", package: "Perfect-HTTPServer"), + .product(name: "PerfectMustache", package: "Perfect-Mustache"), + .product(name: "SwiftString", package: "SwiftString"), + ], + resources: [ + .copy("Resources"), + ] + ) + ] ) diff --git a/Sources/Database.swift b/Sources/Blog/Database.swift similarity index 100% rename from Sources/Database.swift rename to Sources/Blog/Database.swift diff --git a/Sources/Handlers.swift b/Sources/Blog/Handlers.swift similarity index 100% rename from Sources/Handlers.swift rename to Sources/Blog/Handlers.swift diff --git a/webroot/emptyStory.mustache b/Sources/Blog/Resources/emptyStory.mustache similarity index 100% rename from webroot/emptyStory.mustache rename to Sources/Blog/Resources/emptyStory.mustache diff --git a/webroot/index.mustache b/Sources/Blog/Resources/index.mustache similarity index 100% rename from webroot/index.mustache rename to Sources/Blog/Resources/index.mustache diff --git a/webroot/perfect-2.0.png b/Sources/Blog/Resources/perfect-2.0.png similarity index 100% rename from webroot/perfect-2.0.png rename to Sources/Blog/Resources/perfect-2.0.png diff --git a/webroot/story.mustache b/Sources/Blog/Resources/story.mustache similarity index 100% rename from webroot/story.mustache rename to Sources/Blog/Resources/story.mustache diff --git a/webroot/style.mustache b/Sources/Blog/Resources/style.mustache similarity index 100% rename from webroot/style.mustache rename to Sources/Blog/Resources/style.mustache diff --git a/Sources/emptyStory.swift b/Sources/Blog/emptyStory.swift similarity index 100% rename from Sources/emptyStory.swift rename to Sources/Blog/emptyStory.swift diff --git a/Sources/main.swift b/Sources/Blog/main.swift similarity index 93% rename from Sources/main.swift rename to Sources/Blog/main.swift index 4df393b..79d0f1d 100755 --- a/Sources/main.swift +++ b/Sources/Blog/main.swift @@ -20,13 +20,14 @@ import PerfectLib import PerfectHTTP import PerfectHTTPServer import PerfectMustache +import Foundation // Create HTTP server. let server = HTTPServer() // Set the webroot directory so static files such as the logo, can be served -server.documentRoot = "./webroot" - +server.documentRoot = Bundle.module.bundlePath + "/Contents/Resources/Resources" +print(server.documentRoot) // Create the container variable for routes to be added to. var routes = Routes() @@ -62,7 +63,7 @@ routes.add(method: .get, uris: ["/story","/story/{titleSanitized}"], handler: { // Setting the response content type explicitly to text/html response.setHeader(.contentType, value: "text/html") - if titleSanitized.characters.count > 0 { + if titleSanitized.count > 0 { // Setting the body response to the generated list via Mustache mustacheRequest( request: request,