From 0e45ebb40d6c02d1e3aa476f661e432ad48db1fe Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Sat, 5 Feb 2022 18:55:21 -0500 Subject: [PATCH] Added the new license chooser! --- site/assets/cool-border.svg | 10 +++++++ site/styles.scss | 57 +++++++++++++++++++++++++++++++++++++ src/License.elm | 8 ++++++ src/License/Hippocratic.elm | 9 ++++++ src/License/NPL.elm | 11 +++++++ src/Main.elm | 47 ++++++++++++++++++++++++++++-- 6 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 site/assets/cool-border.svg diff --git a/site/assets/cool-border.svg b/site/assets/cool-border.svg new file mode 100644 index 0000000..76e5b0d --- /dev/null +++ b/site/assets/cool-border.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/site/styles.scss b/site/styles.scss index 6f44f92..4a6ff4c 100644 --- a/site/styles.scss +++ b/site/styles.scss @@ -83,6 +83,12 @@ header { border-top: 0; & ~ :not(.bevel) { background-color: var(--bevel); + :first-child { + margin-top: 0; + } + :last-child { + margin-bottom: 0; + } } } &.bl, &.br { @@ -96,6 +102,57 @@ header { } } +#license-chooser { + margin: 0 -50px; + #selected-license { + border: 60px solid; + border-image: url("/assets/cool-border.svg") 60; + padding: 30px; + border-radius: 20px; + white-space: pre-wrap; + h2 { + margin-top: 0; + } + p { + margin-bottom: 0; + font-size: 1.3rem; + line-height: 130%; + } + } + #available-licenses { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 20px; + margin-top: 20px; + margin-bottom: 100px; + + .selectable-license { + background: none; + border: 3px solid var(--color-hi); + height: 50px; + color: white; + font-family: Lack, sansserif; + font-size: 1.2rem; + transform: skew(-15deg); + cursor: pointer; + + span { + transform: skew(15deg); + display: block; + } + + &:hover { + background-color: #1f0430; + } + + &.active { + background-color: var(--color-hi); + color: var(--color-bg); + } + } + } +} + #modules { display: grid; grid-template-columns: 50% 50%; diff --git a/src/License.elm b/src/License.elm index eb5235b..2a0a2f2 100644 --- a/src/License.elm +++ b/src/License.elm @@ -7,6 +7,7 @@ module License exposing , downloadMime , empty , License + , LicenseDescriptors , LicenseInfo , Template , ModuleInfo @@ -82,6 +83,13 @@ type alias LicenseInfo modtype = { availableModules : List modtype , templates : DownloadType -> Template modtype , moduleInfo : modtype -> ModuleInfo + , descriptors : LicenseDescriptors + } + +type alias LicenseDescriptors = + { name : String + , desc : String + , slug : String } empty : LicenseInfo modtype -> License modtype diff --git a/src/License/Hippocratic.elm b/src/License/Hippocratic.elm index 89b4dcb..49444c5 100644 --- a/src/License/Hippocratic.elm +++ b/src/License/Hippocratic.elm @@ -17,6 +17,15 @@ info = { availableModules = availableModules , templates = getTemplate , moduleInfo = moduleInfo + , descriptors = + { name = "Hippocratic License 3.0" + , slug = "HL" + , desc = String.trim """ +The flagship ethical source license, the hippocratic license is one of the most customizable and practical ELOS licenses out there. The 3rd version features many optional modules to tailor the license to issues that matter to you, including optional copyleft functionality. + +Also featured is an out-of-court arbitration clause, and restrictions that prevent any organizations involved in unethical practices from using the software, as opposed to just preventing the direct use of the software for unethical practices. +""" + } } type Module diff --git a/src/License/NPL.elm b/src/License/NPL.elm index 59c8b28..813b68d 100644 --- a/src/License/NPL.elm +++ b/src/License/NPL.elm @@ -15,6 +15,17 @@ info = { availableModules = availableModules , templates = getTemplate , moduleInfo = moduleInfo + , descriptors = + { name = "Nonviolent Public License v7" + , slug = "NVPL/CNPL" + , desc = String.trim """ +The NVPL is perhaps best known for its variant the CNPL (Cooperative Nonviolent Public License), an ELOS license unique in its restriction of comercial use of software to worker owned co-operatives (check off "Worker Ownership" to enable this variant). + +Even on its own, however, the NVPL is a powerful license, including protections against using the work to hurt others or using the work for surveilence, war/war-profiteering, incarceration, fossil fuel extraction/processing, child labor, and the spreading of hate speach. + +The NVPL is also one of a few ELOS licenses that explicitly includes an (AGPL-like) clause that requires network services to distribute or link to the project's source code. +""" + } } type Module diff --git a/src/Main.elm b/src/Main.elm index 7f99c67..c0a73c8 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -2,7 +2,7 @@ module Main exposing (main) import Browser import Sort.Set as Set exposing (Set) -import Html exposing (Html, div, input, label, p, section, text, h3) +import Html exposing (Html, button, div, h2, input, label, p, section, text, span, h3) import Html.Events exposing (onCheck, onClick) import Html.Attributes exposing (class, type_, id) import Html.Attributes exposing (attribute) @@ -28,6 +28,8 @@ subscriptions _ = Sub.none type SelectedLicense = Hippocratic | NPL +availableLicenses : List SelectedLicense +availableLicenses = [ Hippocratic, NPL ] type alias Model = { selected : SelectedLicense @@ -35,6 +37,12 @@ type alias Model = , npl : License NPL.Module } +selectedInfo : SelectedLicense -> License.LicenseDescriptors +selectedInfo selected = + case selected of + Hippocratic -> Hippocratic.info.descriptors + NPL -> NPL.info.descriptors + init : () -> (Model, Cmd Msg) init () = ( @@ -100,6 +108,40 @@ view_module_button wrapModule moduleInfo enabled mod = ] ] +viewLicenseChooser : SelectedLicense -> Html Msg +viewLicenseChooser selected = + div + [ id "license-chooser" ] + [ selected + |> selectedInfo + |> viewLicenseInfo + |> Html.map never + , div [ id "available-licenses" ] + ( availableLicenses + |> List.map (selectableLicense selected) + ) + ] + +viewLicenseInfo : License.LicenseDescriptors -> Html Never +viewLicenseInfo info = + div [ id "selected-license" ] + [ h2 [] [text info.name] + , p [] [text info.desc] + ] + +selectableLicense : SelectedLicense -> SelectedLicense -> Html Msg +selectableLicense currentlySelected license = + button + ( [ onClick (SwitchLicense license) + , class "selectable-license" + ] + ++ if currentlySelected == license then [class "active"] else [] + ) + [ span [] + [ text (.slug (selectedInfo license)) + ] + ] + view_modules : ModuleWrapper moduleType -> License moduleType -> Html Msg view_modules wrap license = section [id "modules"] ( @@ -144,7 +186,8 @@ downloads = view : Model -> Html Msg view model = div [id "elm-area"] - [ case model.selected of + [ viewLicenseChooser model.selected + , case model.selected of Hippocratic -> view_modules HippocraticMod model.hippocratic NPL -> view_modules NPLMod model.npl , downloads