Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project updated according new Swift.package configures #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ blog-database
.buil*
Package.resolved
PADockerfile_build
.swiftpm
29 changes: 21 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"),
]
)
]
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions Sources/main.swift → Sources/Blog/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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,
Expand Down