Skip to content

Commit

Permalink
A lot of licensing stuff fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
apathism committed Sep 10, 2018
1 parent 2a47153 commit 6b42bd4
Show file tree
Hide file tree
Showing 26 changed files with 600 additions and 31 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ejstand
# EjStand

ejstand is a simple and configurable web standings daemon for ejudge contest
EjStand is a simple and configurable web standings daemon for ejudge contest
management system. Its intended to use in situations when standing contains
results from different contests or when standing needs some additional display
options not supported by ejudge.
Expand All @@ -9,15 +9,15 @@ options not supported by ejudge.

### Installing

ejstand is written in Haskell programming language and can be easily
EjStand is written in Haskell programming language and can be easily
built with [Stack tool](https://www.haskellstack.org/).

```bash
cd ejstand
stack build
```

If you wish to install ejstand locally (to `~/.local/bin`), you can use
If you wish to install EjStand locally (to `~/.local/bin`), you can use
```bash
stack install
```
Expand All @@ -28,30 +28,30 @@ source in `dist` directory.

### Configuration

ejstand has two different types of configuration files: _global_ and _local_.
EjStand has two different types of configuration files: _global_ and _local_.

Global configuration file is unique and contains options which are applied for
all standings served by ejstand. For example, two of the most important options
all standings served by ejStand. For example, two of the most important options
in that file is hostname/IP and port to bind an application webserver.

Local configuration files define settings for different standing tables and
therefore aren't unique.

Examples with detailed descriptions for each option are presented in the
`conf` directory. You can use this examples as templates for your own ejstand
`conf` directory. You can use this examples as templates for your own EjStand
instance.

Personally i'd start my own ejstand configuration with
Personally i'd start my own EjStand configuration with
```bash
sudo install -Dm644 conf/global.cfg.example /etc/ejstand.cfg
"${EDITOR}" /etc/ejstand.cfg
```

### Setting Up WebServer

Most of the time it makes sense to set up ejstand next to ejudge, and that means
Most of the time it makes sense to set up EjStand next to ejudge, and that means
that you're probably want some kind of directory (for example, /ejstand) on
your Apache/nginx/whatever-you-use to be proxied to ejstand.
your Apache/nginx/whatever-you-use to be proxied to EjStand.

This [article](https://www.nginx.com/resources/wiki/start/topics/examples/likeapache/)
can help you to setup your global server in a proper way.
Expand All @@ -78,6 +78,9 @@ This project is licensed under the
[GNU AGPL license](https://www.gnu.org/licenses/agpl-3.0.en.html) version 3.
See LICENSE file for more details.

EjStand uses a lot of third-party libraries licensed under BSD2/BSD3/MIT licenses.
You can review third-party licenses in `third-party/licenses` directory.

If you want to use this program under other license, you can contact
[me](https://apathism.net/contacts) personally, and we'll discuss conditions
of licensing.
Expand Down
33 changes: 20 additions & 13 deletions ejstand.cabal
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: ejstand
version: 0.3.0
homepage: https://apathism.net/git/apathism/ejstand
bug-reports: https://apathism.net/git/apathism/ejstand/issues
license: AGPL-3
license-file: LICENSE
author: Ivan Koryabkin
maintainer: Ivan Koryabkin <[email protected]>
synopsis: Ejudge Configurable Web Standings Daemon for Multiple Contests
category: Web
build-type: Simple
cabal-version: >=1.10
name: ejstand
version: 0.3.0
synopsis: Ejudge Configurable Web Standings Daemon for Multiple Contests
homepage: https://apathism.net/git/apathism/ejstand
bug-reports: https://apathism.net/git/apathism/ejstand/issues
license: AGPL-3
license-file: LICENSE
author: Ivan Koryabkin <[email protected]>
maintainer: Ivan Koryabkin <[email protected]>
copyright: (c) 2018 Ivan Koryabkin
category: Web
build-type: Simple
cabal-version: >=1.10

source-repository head
type: git
location: https://apathism.net/git/apathism/ejstand.git

executable ejstand
main-is: Main.hs
Expand All @@ -19,7 +24,7 @@ executable ejstand
-- Time measuring
clock, time,
-- Filesystem & Network tools
directory, http-types, wai, warp,
directory, file-embed, http-types, wai, warp,
-- Parsers & Template Engines
blaze-html, shakespeare, xml-conduit,
-- Other
Expand All @@ -32,7 +37,9 @@ executable ejstand
EjStand.DataParser
EjStand.HtmlRenderer
EjStand.InternalsCore
EjStand.LegalCredits
EjStand.StandingBuilder
EjStand.StandingModels
EjStand.WebApplication
Paths_ejstand
default-language: Haskell2010
6 changes: 4 additions & 2 deletions src/EjStand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module EjStand
)
where

import Data.String (IsString)
import Data.String (IsString, fromString)
import Data.Version (showVersion)
import Paths_ejstand (version)

getVersion :: IsString a => a
getVersion = "0.3.0"
getVersion = fromString . showVersion $ version
62 changes: 62 additions & 0 deletions src/EjStand/LegalCredits.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
module EjStand.LegalCredits
( renderLegalCredits
)
where

import Data.ByteString (ByteString)
import Data.FileEmbed (embedDir)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes)
import Data.String (IsString)
import Data.Text (Text, pack)
import Data.Text.Encoding (decodeUtf8)
import qualified Data.Text.Lazy as LT
import EjStand.StandingModels (GlobalConfiguration (..))
import Text.Blaze.Html.Renderer.Text (renderHtml)
import Text.Hamlet (shamletFile)

data CabalPackage = CabalPackage { packageName :: !Text
, packageLicenseText :: !Text
} deriving (Show)

getDependenciesStringList :: IsString s => [s]
getDependenciesStringList =
[ "base"
, "bytestring"
, "containers"
, "safe"
, "text"
, "clock"
, "time"
, "directory"
, "file-embed"
, "http-types"
, "wai"
, "warp"
, "blaze-html"
, "shakespeare"
, "xml-conduit"
, "binary"
, "mtl"
]

getDependenciesLicenses :: Map Text ByteString
getDependenciesLicenses = Map.fromList $ (\(a, b) -> (pack a, b)) <$> $(embedDir "third-party/licenses")

getCabalPackages :: [CabalPackage]
getCabalPackages =
catMaybes
$ toMaybePackage
<$> (\dep -> (dep :: Text, Map.lookup (dep <> ".txt") getDependenciesLicenses))
<$> getDependenciesStringList
where
toMaybePackage :: (Text, Maybe ByteString) -> Maybe CabalPackage
toMaybePackage (name, Nothing ) = Nothing
toMaybePackage (name, (Just license)) = Just $ CabalPackage name $ decodeUtf8 license

renderLegalCredits :: GlobalConfiguration -> LT.Text
renderLegalCredits GlobalConfiguration {..} = renderHtml ($(shamletFile "templates/credits.hamlet"))
3 changes: 3 additions & 0 deletions src/EjStand/WebApplication.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import qualified Data.Text.Lazy.Encoding as EncLazy (encodeUtf8)
import EjStand.ConfigParser (retrieveGlobalConfiguration, retrieveStandingConfigs)
import EjStand.HtmlRenderer (renderCSS, renderStanding)
import EjStand.InternalsCore (textReplaceLast)
import EjStand.LegalCredits (renderLegalCredits)
import EjStand.StandingBuilder (buildStanding, prepareStandingSource)
import EjStand.StandingModels
import Network.HTTP.Types (ResponseHeaders, Status, status200, status404, status500)
Expand Down Expand Up @@ -89,6 +90,8 @@ runEjStandRequest global request respond = catchSomeException' (onExceptionRespo
let path = rawPathInfo request
possibleRoutes = filter (isPathCorresponding path) local
case (path, possibleRoutes) of
("/credits.html", _) ->
respond $ responseLBS status200 [("Content-Type", "text/html")] $ EncLazy.encodeUtf8 $ renderLegalCredits global
("/ejstand.css", _) ->
respond $ responseLBS status200 [("Content-Type", "text/css")] $ EncLazy.encodeUtf8 renderCSS
(_, [] ) -> respond $ responseBS status404 [("Content-Type", "text/plain")] $ buildNotFoundTextMessage request
Expand Down
18 changes: 18 additions & 0 deletions templates/credits.hamlet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$doctype 5
<html lang="ru">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Лицензии вспомогательных библиотек
<link rel="stylesheet" href="#{webRoot}ejstand.css">
<body>
<h1>
Лицензии вспомогательных библиотек
В данном разделе представлена информация о лицензиях вспомогательных библиотек,
использованных при создании EjStand. Более подробную информацию можно найти по
ссылкам в Hackage.
$forall package <- getCabalPackages
<h2>
<a href="https://hackage.haskell.org/package/#{packageName package}" target="_blank">
#{packageName package}
<pre>
#{packageLicenseText package}
8 changes: 5 additions & 3 deletions templates/main.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ $doctype 5
Эта страница была сгенерирована
<a href="https://apathism.net/git/apathism/ejstand">
EjStand
#{getTextVersion}.
#{getTextVersion} за %%GENERATION_TIME%% мс.
<p class="license">
Это свободная программа, вы можете распространять и/или изменять ее на условиях лицензии
<a href="https://www.gnu.org/licenses/agpl-3.0.ru.html">
GNU Affero General Public License
(AGPL) версии 3.
<p class="generation_time">
На генерацию страницы ушло %%GENERATION_TIME%% мс.
<p class="third-party">
В состав данного ПО также входят свободные библиотки под
<a href="#{webRoot}credits.html">
другими лицензиями.
14 changes: 12 additions & 2 deletions templates/main.lucius
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ h1 {
font-size: 12pt;
}

h2 {
font-family: Verdana, Arial, sans-serif;
font-size: 10pt;
}

pre {
border: 1px solid black;
background-color: #eeeeee;
}

body {
font-family: Arial, sans-serif;
font-size: 10pt;
Expand Down Expand Up @@ -117,10 +127,10 @@ sub, sup {
margin: 0;
}

.footer a {
a {
color: #333333;
}

.footer a:hover {
a:hover {
color: #aaaaaa;
}
31 changes: 31 additions & 0 deletions third-party/licenses/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
The Glasgow Haskell Compiler License

Copyright 2002, The University Court of the University of Glasgow.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
30 changes: 30 additions & 0 deletions third-party/licenses/blaze-html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright Jasper Van der Jeugt 2010

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Jasper Van der Jeugt nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 changes: 30 additions & 0 deletions third-party/licenses/bytestring.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) Don Stewart 2005-2009
(c) Duncan Coutts 2006-2015
(c) David Roundy 2003-2005
(c) Simon Meier 2010-2011

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Loading

0 comments on commit 6b42bd4

Please sign in to comment.