From a1baa33102ef10ab8ecbaa781cbb175a35ee1fd9 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 8 Jan 2023 15:58:20 +0300 Subject: [PATCH] Work on language support --- data/home/content/education/index.md | 8 ++-- data/home/content/education/kotlin.md | 36 +++++++------- gradle.properties | 2 +- src/main/kotlin/ru/mipt/spc/Application.kt | 1 - src/main/kotlin/ru/mipt/spc/spcHome.kt | 56 ++++++++++++++-------- src/main/kotlin/ru/mipt/spc/spcMasters.kt | 2 +- 6 files changed, 58 insertions(+), 47 deletions(-) diff --git a/data/home/content/education/index.md b/data/home/content/education/index.md index 6b5cc74..0615a6f 100644 --- a/data/home/content/education/index.md +++ b/data/home/content/education/index.md @@ -23,19 +23,19 @@ language: en ## Courses in 2022-2023: ### [Scientific literature seminar](#) -*curated by [Aleksandr Svetlichnyi](team#svetlichnyi)* +*curated by [Aleksandr Svetlichnyi](${resolvePageRef("team")}#svetlichnyi)* [Telegram](https://t.me/spc_seminar) ### [Statistical methods and data analysis](${resolvePageRef("education.stat-methods")}) -*by [Alexander Nozik](team#nozik) and [Vladimir Palmin](team#palmin)* +*by [Alexander Nozik](team#nozik) and [Vladimir Palmin](${resolvePageRef("team.index")}#palmin)* Actual program: [SPC-A-6](https://npm.mipt.ru/youtrack/articles/SPC-A-6) [Telegram](https://t.me/mipt_statmethods) ### [Introduction to scientific programming in Kotlin](${resolvePageRef("education.kotlin")}) -*by [Alexander Nozik](team#nozik)* +*by [Alexander Nozik](${resolvePageRef("team.index")}#nozik)* Actual program: [SPC-A-6](https://npm.mipt.ru/youtrack/articles/SPC-A-6) @@ -47,7 +47,7 @@ Actual program: [SPC-A-6](https://npm.mipt.ru/youtrack/articles/SPC-A-6) Actual program: [SPC-A-3](https://npm.mipt.ru/youtrack/articles/SPC-A-3) ### [Instruments of development](https://npm.mipt.ru/youtrack/articles/SPC-A-5) -*curated by [Alexander Nozik](team#nozik)* +*curated by [Alexander Nozik](${resolvePageRef("team.index")}#nozik)* Actual program: [SPC-A-5](https://npm.mipt.ru/youtrack/articles/SPC-A-5) diff --git a/data/home/content/education/kotlin.md b/data/home/content/education/kotlin.md index ab1e1f6..5c004e2 100644 --- a/data/home/content/education/kotlin.md +++ b/data/home/content/education/kotlin.md @@ -9,11 +9,11 @@ language: en Recording of lectures in 2019 is available [here](https://www.youtube.com/playlist?list=PL4_hYwCyhAvZzRpbK4iTy9S6_OWZNEiVk). ## Lecturer -[Alexander Nozik](${resolvePageRef("team")#nozik}) +[Alexander Nozik](${resolvePageRef("team.index")}#nozik) ## Course purpose -As physics (and science in general) develops, computer methods are becoming more and more important in the daily work of a scientist. In conducting an experiment, computer methods and tools are used at all stages of the work: planning the experiment, preparing the installation, collecting data, processing and publishing it. In such a situation, the quality of the programs used is beginning to play an important role. In addition, there is a need for specialists who understand both science and programming and who develop and improve software tools. +As science develops, computer methods are becoming more and more important in the daily work of a scientist. In conducting an experiment, computer methods and tools are used at all stages of the work: planning the experiment, preparing the installation, collecting data, processing and publishing it. In such a situation, the quality of the programs used is beginning to play an important role. In addition, there is a need for specialists who understand both science and programming and who develop and improve software tools. Most students (and scientists) are more or less familiar with the basic tools of a programmer, for example, writing simple programs in Python. This is not enough for serious scientific development, so the course aims at a more advanced understanding of hardware, program structure and modern development tools. @@ -26,18 +26,20 @@ As the main programming language we will use `Kotlin`, which appeared recently a * Extensive community. * Possibility of commercial use. -## Course format +## Format -In 2020, the course is held with the participation of JetBrains and the support of JetBrains Research. The most active students will have the opportunity to participate in summer internships at JetBrains. There is also an opportunity for senior students to do research at the MIPT Laboratory of Nuclear Physics Experiments Methods (participant of JetBrains Research) and at the JetBrains Moscow office. +The lessons are twice a week. +* One is a lecture at MIPT campus. Lectures are dedicated to Kotlin language features and specifics of its application to science and industry problems. +* The second one is practice. Practice is dedicated to work on students projects and additional material. + +To get a mark student must complete 3 practical tasks during the semester. All tasks are accepted in form of Kotlin application of notebook and pass a code-review stage. In this course we will learn to work in Kotlin language and apply it to scientific problems. We will focus on practical aspects and examples, so that no additional knowledge is needed to understand it. For practical examples we will use the development environment [IntelliJ IDEA Community Edition](https://www.jetbrains.com/idea/). -All questions related to the course will be discussed in telegram groups [@mipt-npm](https://t.me/mipt_npm) (scientific) and [Kotlin at MIPT](https://t.me/joinchat/EpV1201A_i0rTOCxHHnxXQ) (any questions about Kotlin). +All questions related to the course will be discussed in telegram [Kotlin at MIPT](https://t.me/kotlin_mipt). -All those wishing to participate should complete the [form](https://docs.google.com/forms/d/e/1FAIpQLSeNZT8B90pT6fM9oABHFbrtv6pKfoYKfO-ANAjLlgWynMnh_g/viewform). - -## Course content -1. **From hard to soft** +## Content +1. **From hard to soft** 1. Program as a set of instructions. Evolution of programs. 2. Memory structure. Segmentation fault. 3. Programming paradigms. Genealogy of languages. @@ -45,26 +47,22 @@ All those wishing to participate should complete the [form](https://docs.google. 5. Compilation and optimization. 6. Static and dynamic linking. Libraries. 7. Program structure. Entry points. -2. **The tools of the modern programmer** - 1. Automatic build systems. - 2. Version control systems. - 3. Integrated development environments. -3. **Kotlin language** +2. **Kotlin language** 1. Variables, classes and objects. 2. Control flow. Procedural and functional approach. - 3. Short circuits. + 3. Loops. 4. Data structures and operations on them. 5. Properties and Delegates. 6. Parametric types. 7. Extensions. 8. Boxing. - 9. Multiplatform projects -4. **Program Architecture** + 9. Multiplatform projects. +3. **Program Architecture** 1. Abstractions and interfaces. - 2. basics of collective development with the help of modern tools. + 2. Basics of collective development with the help of modern tools. 3. Ideology of object programming. Separation of behavior. 4. Ideology of functional programming. -5. **Scientific programming**. +4. **Scientific programming**. 1. Basics of numerical methods. The concept of numerical accuracy. Complexity of algorithms. 2. Numerical differentiation and integration. 3. Random Number Generators and Monte Carlo Modeling. diff --git a/gradle.properties b/gradle.properties index 9a9232d..18c1dd5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ kotlin.code.style=official -toolsVersion=0.13.1-kotlin-1.7.20 +toolsVersion=0.13.3-kotlin-1.7.20 snarkVersion=0.1.0-dev-1 \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/spc/Application.kt b/src/main/kotlin/ru/mipt/spc/Application.kt index bab8e04..5e3d334 100644 --- a/src/main/kotlin/ru/mipt/spc/Application.kt +++ b/src/main/kotlin/ru/mipt/spc/Application.kt @@ -51,7 +51,6 @@ fun Application.spcModule() { get("magprog"){ call.respondRedirect("education/masters") } - } } diff --git a/src/main/kotlin/ru/mipt/spc/spcHome.kt b/src/main/kotlin/ru/mipt/spc/spcHome.kt index 4b32da3..28652a7 100644 --- a/src/main/kotlin/ru/mipt/spc/spcHome.kt +++ b/src/main/kotlin/ru/mipt/spc/spcHome.kt @@ -3,9 +3,7 @@ package ru.mipt.spc import html5up.forty.fortyScripts import kotlinx.html.* import space.kscience.dataforge.data.Data -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.get -import space.kscience.dataforge.meta.string +import space.kscience.dataforge.meta.* import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.startsWith @@ -53,12 +51,26 @@ context(WebPage) internal fun HTML.spcPageContent( } @Suppress("UNCHECKED_CAST") -internal val FortyDataRenderer: DataRenderer = { name, data -> - if (data.type == typeOf()) { - data as Data - page(name) { - spcPageContent(data.meta) { - htmlData(data) +internal val FortyDataRenderer: DataRenderer = object : DataRenderer { + + context(SiteBuilder) + override fun invoke(name: Name, data: Data) { + if (data.type == typeOf()) { + data as Data + val languageMeta: Meta = DataRenderer.buildLanguageMeta(name) + + val dataMeta: Meta = if (languageMeta.isEmpty()) { + data.meta + } else { + data.meta.toMutableMeta().apply { + "language" put languageMeta + } + } + + page(name, data.meta) { + spcPageContent(dataMeta) { + htmlData(data) + } } } } @@ -248,34 +260,36 @@ context(WebPage) private fun HTML.spcHome() { } } } - fortyScripts() } - } internal fun SiteBuilder.spcHome(dataPath: Path, prefix: Name = Name.EMPTY) { val homePageData = snark.readDirectory(dataPath.resolve("content")) - route(prefix, homePageData, setAsRoot = true) { + site(prefix, homePageData) { file(dataPath.resolve("assets")) file(dataPath.resolve("images")) file(dataPath.resolve("../common"), "") - page { spcHome() } + withLanguages( + "en" to "", + "ru" to "ru" + ) { + page { spcHome() } - pages("consulting", dataRenderer = FortyDataRenderer) - //pages("ru.consulting".parseAsName(), dataRenderer = FortyDataRenderer) + pages("consulting", dataRenderer = FortyDataRenderer) - pages("education", dataRenderer = FortyDataRenderer) + pages("education", dataRenderer = FortyDataRenderer) - spcSpotlight("team") { _, meta -> - meta["type"].string == "team" - } + spcSpotlight("team") { _, meta -> + meta["type"].string == "team" + } - spcSpotlight("research") { name, meta -> - name.startsWith("projects".asName()) && meta["type"].string == "project" + spcSpotlight("research") { name, meta -> + name.startsWith("projects".asName()) && meta["type"].string == "project" + } } } diff --git a/src/main/kotlin/ru/mipt/spc/spcMasters.kt b/src/main/kotlin/ru/mipt/spc/spcMasters.kt index 41aeade..29e0a52 100644 --- a/src/main/kotlin/ru/mipt/spc/spcMasters.kt +++ b/src/main/kotlin/ru/mipt/spc/spcMasters.kt @@ -302,7 +302,7 @@ internal fun SiteBuilder.spcMasters(dataPath: Path, prefix: Name = "education.ma val magProgData: DataTree = snark.readDirectory(dataPath.resolve("content")) - route(prefix, magProgData, setAsRoot = true) { + site(prefix, magProgData) { file(dataPath.resolve("assets")) file(dataPath.resolve("images")) file(dataPath.resolve("../common"), "")