Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Swift 5 (#3)
Browse files Browse the repository at this point in the history
* Swift 5

* Tag 0.3.0

* Fix snippet

* Interpolate
  • Loading branch information
stephencelis authored Mar 26, 2019
1 parent c6a9353 commit 63c20b8
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.2
5.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM norionomura/swift:41
FROM norionomura/swift:swift-5.0-branch

WORKDIR /package

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Point-Free, Inc.
Copyright (c) 2019 Point-Free, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
125 changes: 103 additions & 22 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
{
"object": {
"pins": [
{
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML",
"state": {
"branch": null,
"revision": "54bb8ea6fb693dd3f92a89e5fcc19e199fdeedd0",
"version": "4.3.3"
}
},
{
"package": "Socket",
"repositoryURL": "https://github.com/IBM-Swift/BlueSocket.git",
"state": {
"branch": null,
"revision": "ce36f72f2c36b88f847de50c8c0ed8021ff80097",
"version": "1.0.16"
"revision": "ea61f532dd46c876f7bb8e1f8e849cac96b23b77",
"version": "1.0.45"
}
},
{
"package": "SSLService",
"repositoryURL": "https://github.com/IBM-Swift/BlueSSLService.git",
"state": {
"branch": null,
"revision": "a8e24ec6db452ed202502ebae885b39f43e34d98",
"version": "1.0.16"
"revision": "655299a84254737b55c777c11f0fe5d5915e1f4b",
"version": "1.0.45"
}
},
{
"package": "CCurl",
"repositoryURL": "https://github.com/IBM-Swift/CCurl.git",
"package": "JSONUtilities",
"repositoryURL": "https://github.com/yonaskolb/JSONUtilities.git",
"state": {
"branch": null,
"revision": "2a431e3a5fb8d004aa7d4d1bebb5d511f568c43e",
"version": "1.0.0"
"revision": "db238f4858ac2ac3fff228b5b71ce90488a6a9b3",
"version": "4.1.0"
}
},
{
"package": "Kitura",
"repositoryURL": "https://github.com/IBM-Swift/Kitura.git",
"state": {
"branch": null,
"revision": "38ca4d1c8385ea11ccbc7a0c841aff49accbcf17",
"version": "2.5.1"
"revision": "a56a19f44872dd1920c22cd10cefed20a438f8c8",
"version": "2.5.7"
}
},
{
"package": "Kitura-net",
"repositoryURL": "https://github.com/IBM-Swift/Kitura-net.git",
"state": {
"branch": null,
"revision": "4023a2ea525e0c46d9ea793770d83f75df8a1707",
"version": "2.1.1"
"revision": "d837d453a72fe914b91354708b1afb13a2b411a6",
"version": "2.1.7"
}
},
{
Expand All @@ -60,44 +69,116 @@
"repositoryURL": "https://github.com/IBM-Swift/KituraContracts.git",
"state": {
"branch": null,
"revision": "8e41f3fc81b662722020754f74a8fd8c7bdbbf3b",
"version": "1.1.0"
"revision": "acfad5b37e70590261c1181b1ad29758d20bf167",
"version": "1.1.1"
}
},
{
"package": "LoggerAPI",
"repositoryURL": "https://github.com/IBM-Swift/LoggerAPI.git",
"state": {
"branch": null,
"revision": "5041f2673aa75d6e973d9b6bd3956bc5068387c8",
"version": "1.7.3"
"revision": "d0ccb4158b83f8692531892a9c894bb757593c6f",
"version": "1.8.0"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "e2f5be30e4c8f531c9c1e8765aa7b71c0a45d7a0",
"version": "0.9.2"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/onevcat/Rainbow.git",
"state": {
"branch": null,
"revision": "797a68d0a642609424b08f11eb56974a54d5f6e2",
"version": "3.1.4"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "f14ff47f45642aa5703900980b014c2e9394b6e5",
"version": "0.9.0"
}
},
{
"package": "Html",
"repositoryURL": "https://github.com/pointfreeco/swift-html.git",
"state": {
"branch": null,
"revision": "bb2fac72ec6f0adbe5a74b534d6d265f073b24bf",
"version": "0.1.1"
"revision": "f6fd8c99a790c930d0f22af3a06e02f37131a430",
"version": "0.3.0"
}
},
{
"package": "SnapshotTesting",
"repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state": {
"branch": null,
"revision": "69b48c8487ef8207170aee02485c40f9cafc79c8",
"version": "0.0.1"
"revision": "1fb2e65cf62d2f983b3cab2871cbb218ea9ee9b7",
"version": "1.3.0"
}
},
{
"package": "SwiftCLI",
"repositoryURL": "https://github.com/jakeheis/SwiftCLI.git",
"state": {
"branch": null,
"revision": "5318c37d3cacc8780f50b87a8840a6774320ebdf",
"version": "5.2.2"
}
},
{
"package": "SwiftShell",
"repositoryURL": "https://github.com/kareman/SwiftShell",
"state": {
"branch": null,
"revision": "beebe43c986d89ea5359ac3adcb42dac94e5e08a",
"version": "4.1.2"
}
},
{
"package": "TypeDecoder",
"repositoryURL": "https://github.com/IBM-Swift/TypeDecoder.git",
"state": {
"branch": null,
"revision": "aaf636e64089baf6a710ff5e7dd5f4c8798ff940",
"version": "1.1.0"
"revision": "66550c1643740c58eae87df099c66144a85ae572",
"version": "1.3.2"
}
},
{
"package": "XcodeGen",
"repositoryURL": "https://github.com/yonaskolb/XcodeGen.git",
"state": {
"branch": null,
"revision": "95bc051d268f6b8b924ae9c84e40566efe90cb80",
"version": "2.3.0"
}
},
{
"package": "xcodeproj",
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
"state": {
"branch": null,
"revision": "8e15cc74149ee946b7ae125685177915b4ff7317",
"version": "6.4.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "26ab35f50ea891e8edefcc9d975db2f6b67e1d68",
"version": "1.0.1"
}
}
]
Expand Down
5 changes: 2 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.0

import PackageDescription

Expand All @@ -14,7 +13,7 @@ let package = Package(
targets: ["HtmlKituraSupportExample"]),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-html.git", from: "0.1.1"),
.package(url: "https://github.com/pointfreeco/swift-html.git", from: "0.3.0"),
.package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.5.0")),
],
targets: [
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# swift-html-kitura

[![Swift 4.1](https://img.shields.io/badge/swift-4.1-ED523F.svg?style=flat)](https://swift.org/download/)
[![Swift 5](https://img.shields.io/badge/swift-5-ED523F.svg?style=flat)](https://swift.org/download/)
[![Linux CI](https://img.shields.io/travis/pointfreeco/swift-html-kitura/master.svg?label=linux)](https://travis-ci.org/pointfreeco/swift-html-kitura)
[![@pointfreeco](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/pointfreeco)

Expand All @@ -22,7 +22,7 @@ let router = Router()

router.get("/") { request, response, next in
response.send(
h1(["Hello, type-safe HTML on Kitura!"])
Node.h1("Hello, type-safe HTML on Kitura!")
)
next()
}
Expand Down Expand Up @@ -55,7 +55,7 @@ If you want to use swift-html-kitura in a project that uses [SwiftPM](https://sw

``` swift
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-html-kitura.git", from: "0.1.0")
.package(url: "https://github.com/pointfreeco/swift-html-kitura.git", from: "0.3.0")
]
```

Expand Down
84 changes: 44 additions & 40 deletions Sources/HtmlKituraSupportExample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,77 +41,81 @@ h2 {

router.get("/") { request, response, next in
response.send(
html([
head([style(stylesheet)]),
Node.html(
.head(.style(safe: stylesheet)),

body([
h1(["swift-html-kitura"]),
blockquote([
.body(
.h1("swift-html-kitura"),
.blockquote(
"A Kitura plugin for type-safe, transformable HTML views using ",
a([href("https://github.com/pointfreeco/swift-html")], ["swift-html"])
]),
.a(attributes: [.href("https://github.com/pointfreeco/swift-html")], "swift-html")
),

h2(["Motivation"]),
p(["""
.h2("Motivation"),
.p("""
The most popular choice for rendering HTML in a Kitura web app is to use the Stencil templating language,
but it exposes your application to runtime errors and invalid HTML. Our plugin prevents these
runtime issues at compile-time by embedding HTML directly into Swift’s powerful type system. It uses the
swift-html DSL for constructing HTML documents using plain Swift data structures.
"""
]),
),

h2(["Usage"]),
p(["""
.h2("Usage"),
.p("""
To use the plugin all you have to do is return a `Node` value from your router callback:
"""]),
pre(["""
"""
),
.pre(#"""
import HtmlKituraSupport
import Kitura
let router = Router()
router.get("/") { request, response, next in
response.send(
h1(["Hello, type-safe HTML on Kitura!"])
Node.h1("Hello, type-safe HTML on Kitura!")
)
next()
}
Kitura.addHTTPServer(onPort: 8080, with: router)
Kitura.run()
"""
]),
"""#
),

h2(["Take it for a spin"]),
p(["""
.h2("Take it for a spin"),
.p("""
We've included a sample Kitura application in this repo to show off its usage. To run the app
immediately, simply do:
"""]),
ul([
li([code(["swift run HtmlKituraSupportExample"])]),
li(["Open your browser to ", code(["http://localhost:8080"])])
]),
p(["""
"""
),
.ul(
.li(.code("swift run HtmlKituraSupportExample")),
.li("Open your browser to \(.code("http://localhost:8080"))")
),
.p("""
The HTML for that page is constructed and rendered with swift-html!
"""]),
p(["""
"""
),
.p("""
If you want to run the app in Xcode so that you can play around with the HTML, try this:
"""]),
ul([
li([code(["git clone https://github.com/pointfreeco/swift-html-kitura"])]),
li([code(["cd swift-html-kitura"])]),
li([code(["make xcodeproj"])]),
li(["Select the ", code(["HtmlKituraSupportExample"]), " target"]),
li(["Build and run ", code(["cmd+R"])]),
li(["Open your browser to ", code(["http://localhost:8080`"])])
])
])
])
"""
),
.ul(
.li(.code("git clone https://github.com/pointfreeco/swift-html-kitura")),
.li(.code("cd swift-html-kitura")),
.li(.code("make xcodeproj")),
.li("Select the \(.code("HtmlKituraSupportExample")) target"),
.li("Build and run \(.code("cmd+R"))"),
.li("Open your browser to \(.code("http://localhost:8080"))"
)
)
)
)
)

next()
next()
}


Kitura.addHTTPServer(onPort: 8080, with: router)
Kitura.run()

0 comments on commit 63c20b8

Please sign in to comment.