From cef64e48d778768e9bd61b32a8bb2ebef55a5849 Mon Sep 17 00:00:00 2001 From: hadihariri Date: Thu, 26 Mar 2020 15:15:50 +0100 Subject: [PATCH] Project set-up and static serving --- .gitignore | 12 ++--- LICENSE | 42 +++++++++--------- README.md | 4 +- gradle.properties | 4 ++ .../jetbrains/handson/website/Application.kt | 17 +++++++ src/main/resources/application.conf | 9 ++++ src/main/resources/files/index.html | 17 +++++++ src/main/resources/files/ktor.png | Bin 0 -> 6018 bytes src/main/resources/logback.xml | 12 +++++ 9 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 gradle.properties create mode 100644 src/main/kotlin/com/jetbrains/handson/website/Application.kt create mode 100644 src/main/resources/application.conf create mode 100644 src/main/resources/files/index.html create mode 100644 src/main/resources/files/ktor.png create mode 100644 src/main/resources/logback.xml diff --git a/.gitignore b/.gitignore index 0c408e8..fae6b74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ -.gradle/ -build/ +/.gradle +/.idea +/out +/build *.iml -out/ -.DS_Store -.idea/ -gradle/ \ No newline at end of file +*.ipr +*.iws diff --git a/LICENSE b/LICENSE index f49a4e1..12bc037 100644 --- a/LICENSE +++ b/LICENSE @@ -28,19 +28,19 @@ source, and configuration files. "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but + transformation or translation of resources Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a + Object form, made available under the License, as indicated by resources copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes + represent, as resources whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. @@ -57,21 +57,21 @@ and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." + designated in writing by the copyright owner as "Not resources Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and + on behalf of whom resources Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, + this License, each Contributor hereby grants to You resources perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, + this License, each Contributor hereby grants to You resources perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, @@ -79,9 +79,9 @@ by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct + institute patent litigation against any entity (including resources + cross-claim or counterclaim in resources lawsuit) alleging that the Work + or resources Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. @@ -91,8 +91,8 @@ modifications, and in Source or Object form, provided that You meet the following conditions: - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and + (resources) You must give any other recipients of the Work or + Derivative Works resources copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and @@ -103,15 +103,15 @@ excluding those notices that do not pertain to any part of the Derivative Works; and - (d) If the Work includes a "NOTICE" text file as part of its + (d) If the Work includes resources "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained + include resources readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed + of the following places: within resources NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and + within resources display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution @@ -123,7 +123,7 @@ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, + for any such Derivative Works as resources whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. @@ -155,7 +155,7 @@ unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a + incidental, or consequential damages of any character arising as resources result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all @@ -164,7 +164,7 @@ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, + and charge resources fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf @@ -181,7 +181,7 @@ boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a + comment syntax for the file format. We also recommend that resources file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. @@ -190,7 +190,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. - You may obtain a copy of the License at + You may obtain resources copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/README.md b/README.md index 8b7e6ef..36871f6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0) -# Creating a static website with Ktor +# Creating resources static website with Ktor -This repository is the code corresponding to the hands-on lab [Creating a website with Ktor](https://play.kotlinlang.org/hands-on/Creating%20a%20website%20with%20ktor/01_Introduction). +This repository is the code corresponding to the hands-on lab [Creating resources website with Ktor](https://play.kotlinlang.org/hands-on/Creating%20a%20website%20with%20ktor/01_Introduction). diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c378215 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +ktor_version=1.3.2 +kotlin.code.style=official +kotlin_version=1.3.70 +logback_version=1.2.1 diff --git a/src/main/kotlin/com/jetbrains/handson/website/Application.kt b/src/main/kotlin/com/jetbrains/handson/website/Application.kt new file mode 100644 index 0000000..d10594f --- /dev/null +++ b/src/main/kotlin/com/jetbrains/handson/website/Application.kt @@ -0,0 +1,17 @@ +package com.jetbrains.handson.website + +import io.ktor.application.Application +import io.ktor.http.content.resources +import io.ktor.http.content.static +import io.ktor.routing.routing + + +fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) + +fun Application.module() { + routing { + static("/static") { + resources("files") + } + } +} diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf new file mode 100644 index 0000000..4c46774 --- /dev/null +++ b/src/main/resources/application.conf @@ -0,0 +1,9 @@ +ktor { + deployment { + port = 8080 + port = ${?PORT} + } + application { + modules = [ com.jetbrains.handson.website.ApplicationKt.module ] + } +} \ No newline at end of file diff --git a/src/main/resources/files/index.html b/src/main/resources/files/index.html new file mode 100644 index 0000000..053c139 --- /dev/null +++ b/src/main/resources/files/index.html @@ -0,0 +1,17 @@ + + + + + Static Page + + +

Static Page

+

+ +

+

+ This is a static page! +

+Ktor Logo + + \ No newline at end of file diff --git a/src/main/resources/files/ktor.png b/src/main/resources/files/ktor.png new file mode 100644 index 0000000000000000000000000000000000000000..40c878cd2ede8a29676e93c3512f8c0d0db615d6 GIT binary patch literal 6018 zcmeHL^;=X?w;n*rArrK>Cj=)rPVR+q=xKtsplWA%98Jp+NBMJmfl>v%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