mirror of
https://github.com/aelve/guide.git
synced 2024-12-23 12:52:31 +03:00
Add support for Google site verification
This commit is contained in:
parent
38560dd012
commit
bf10fa4036
@ -5,10 +5,12 @@ The `state/` directory contains the database. You can download the current datab
|
||||
$ git clone https://github.com/aelve/guide-database
|
||||
$ mv guide-database state
|
||||
|
||||
The `config.json` file contains the config (it will be created at the 1st start). There are 3 settings so far:
|
||||
The `config.json` file contains the config (it will be created at the 1st start). There are 4 settings so far:
|
||||
|
||||
* `admin-password` is the password for the admin panel (at `/admin`). Leave it empty if you don't want any password.
|
||||
|
||||
* `google-token` lets you set the Google site verification token. Leave it empty if you don't want Google verification.
|
||||
|
||||
* `base-url` is the URL of the server (which should contain `http://` or `https://`). It's used for feed generation.
|
||||
|
||||
* `prerender` enables prerendering pages when the server starts. By default it's disabled (because it's annoying during development).
|
||||
|
@ -35,29 +35,33 @@ import Utils
|
||||
|
||||
|
||||
data Config = Config {
|
||||
_baseUrl :: Url,
|
||||
_adminPassword :: Text,
|
||||
_prerender :: Bool }
|
||||
_baseUrl :: Url,
|
||||
_googleToken :: Text,
|
||||
_adminPassword :: Text,
|
||||
_prerender :: Bool }
|
||||
deriving (Eq, Show)
|
||||
|
||||
instance Default Config where
|
||||
def = Config {
|
||||
_baseUrl = "/",
|
||||
_adminPassword = "",
|
||||
_prerender = False }
|
||||
_baseUrl = "/",
|
||||
_googleToken = "",
|
||||
_adminPassword = "",
|
||||
_prerender = False }
|
||||
|
||||
instance FromJSON Config where
|
||||
parseJSON = withObject "config" $ \o -> do
|
||||
_baseUrl <- o .:? "base-url" .!= _baseUrl def
|
||||
_adminPassword <- o .:? "admin-password" .!= _adminPassword def
|
||||
_prerender <- o .:? "prerender" .!= _prerender def
|
||||
_baseUrl <- o .:? "base-url" .!= _baseUrl def
|
||||
_googleToken <- o .:? "google-token" .!= _googleToken def
|
||||
_adminPassword <- o .:? "admin-password" .!= _adminPassword def
|
||||
_prerender <- o .:? "prerender" .!= _prerender def
|
||||
return Config{..}
|
||||
|
||||
instance ToJSON Config where
|
||||
toJSON Config{..} = object [
|
||||
"base-url" .= _baseUrl,
|
||||
"admin-password" .= _adminPassword,
|
||||
"prerender" .= _prerender ]
|
||||
"base-url" .= _baseUrl,
|
||||
"google-token" .= _googleToken,
|
||||
"admin-password" .= _adminPassword,
|
||||
"prerender" .= _prerender ]
|
||||
|
||||
readConfig :: IO Config
|
||||
readConfig = do
|
||||
|
@ -505,6 +505,9 @@ wrapPage pageTitle page = doctypehtml_ $ do
|
||||
title_ (toHtml pageTitle)
|
||||
meta_ [name_ "viewport",
|
||||
content_ "width=device-width, initial-scale=1.0, user-scalable=yes"]
|
||||
token <- _googleToken <$> lift ask
|
||||
unless (T.null token) $
|
||||
meta_ [name_ "google-site-verification", content_ token]
|
||||
-- Report all Javascript errors with alerts
|
||||
script_ [text|
|
||||
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user