Skip to content

Commit

Permalink
Add pointer to many decks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lattyware committed May 23, 2020
1 parent cd591c4 commit 1bc4f07
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [Lattyware]
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Bug Report
about: Create a report to help us fix a problem.
title: ''
labels: bug
assignees: ''
---

## Describe the bug
A clear and concise description of what the bug is.
Please copy and paste or screenshot any error you received.


## How to reproduce the bug
Steps to reproduce the behaviour:
1. Start a new game
2. Enable a particular setting
3.


### Expected behaviour
A clear and concise description of what you expected to happen.

11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Feature Request
about: Ask us to add a new feature.
title: ''
labels: enhancement
assignees: ''
---

## Describe the feature
A clear and concise description of what the feature you would like is.

9 changes: 7 additions & 2 deletions client/src/elm/MassiveDecks/Card/Source/ManyDecks.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Html as Html exposing (Html)
import Html.Attributes as HtmlA
import Html.Events as HtmlE
import Json.Decode as Json
import MassiveDecks.Card.Source.ManyDecks.Model exposing (DeckCode, deckCode, toString)
import MassiveDecks.Card.Source.ManyDecks.Model as ManyDecks exposing (..)
import MassiveDecks.Card.Source.Methods as Source
import MassiveDecks.Card.Source.Model as Source exposing (Source)
import MassiveDecks.Components.Form.Message as Message exposing (Message)
Expand All @@ -19,6 +19,7 @@ import MassiveDecks.Strings as Strings exposing (MdString)
import MassiveDecks.Strings.Languages as Lang
import MassiveDecks.Util.Maybe as Maybe
import Material.TextField as TextField
import Url.Builder as Url


methods : DeckCode -> Source.ExternalMethods msg
Expand Down Expand Up @@ -125,8 +126,12 @@ editor dc shared existing update submit noOp =

details : DeckCode -> Shared -> Source.Details
details dc shared =
let
url baseUrl =
Url.crossOrigin baseUrl [ "decks", dc |> toString ] []
in
{ name = (() |> name |> Lang.string shared) ++ " " ++ (dc |> toString)
, url = Nothing
, url = shared.sources.manyDecks |> Maybe.map (.baseUrl >> url)
, author = Nothing
, translator = Nothing
, language = Nothing
Expand Down
2 changes: 1 addition & 1 deletion client/src/elm/MassiveDecks/Error.elm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ body shared route description details =
++ "\n\tPage: "
++ Route.externalUrl shared.origin route
++ "\n\tEnglish Error: "
++ Lang.givenLanguageString Lang.En description
++ Lang.givenLanguageString shared Lang.En description
++ "\n\tDetails: "
++ details
in
Expand Down
6 changes: 6 additions & 0 deletions client/src/elm/MassiveDecks/Pages/Start.elm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ view shared model =
let
r =
model.route

manyDecksAd { baseUrl } =
Html.blankA
[ HtmlA.href baseUrl, HtmlA.id "many-decks-ad", Strings.ManyDecksWhereToGet |> Lang.title shared ]
[ Html.div [] [ Icon.boxOpen |> Icon.viewIcon, Strings.ManyDecks |> Lang.html shared ] ]
in
[ Html.div [ HtmlA.class "page start" ]
[ overlay shared model.overlay
Expand Down Expand Up @@ -241,6 +246,7 @@ view shared model =
]
]
]
, shared.sources.manyDecks |> Maybe.map manyDecksAd |> Maybe.withDefault Html.nothing
]


Expand Down
4 changes: 2 additions & 2 deletions client/src/elm/MassiveDecks/Settings.elm
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,12 @@ languageOption shared currentLanguage language =
nameInCurrentLanguage =
language
|> Lang.languageName
|> Lang.givenLanguageString currentLanguage
|> Lang.givenLanguageString shared currentLanguage

autonym =
if language /= currentLanguage then
language
|> Lang.autonym
|> Lang.autonym shared
|> (\n -> Just [ Strings.AutonymFormat { autonym = n } |> Lang.html shared ])

else
Expand Down
16 changes: 8 additions & 8 deletions client/src/elm/MassiveDecks/Strings/Languages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ languageName language =

{-| The given language's name for itself.
-}
autonym : Language -> String
autonym language =
languageName language |> givenLanguageString language
autonym : Shared -> Language -> String
autonym shared language =
languageName language |> givenLanguageString shared language


{-| A sort that gives the closest matches first.
Expand Down Expand Up @@ -119,14 +119,14 @@ findBestMatch codes =
-}
string : Shared -> MdString -> String
string shared mdString =
mdString |> givenLanguageString (currentLanguage shared)
mdString |> givenLanguageString shared (currentLanguage shared)


{-| Build an actual string in the given language.
-}
givenLanguageString : Language -> MdString -> String
givenLanguageString lang mdString =
mdString |> Render.asString { lang = lang, translate = translate lang, parent = mdString }
givenLanguageString : Shared -> Language -> MdString -> String
givenLanguageString shared lang mdString =
mdString |> Render.asString { lang = lang, translate = translate lang, parent = mdString, shared = shared }


{-| An HTML text node from the given `MdString`. Note this is more than just convenience - we enhance some strings
Expand All @@ -138,7 +138,7 @@ html shared mdString =
lang =
currentLanguage shared
in
mdString |> Render.asHtml { lang = lang, translate = translate lang, parent = mdString }
mdString |> Render.asHtml { lang = lang, translate = translate lang, parent = mdString, shared = shared }


{-| Convenience for an HTML `title` attribute from the given `MdString`.
Expand Down
10 changes: 9 additions & 1 deletion client/src/elm/MassiveDecks/Strings/Render.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import FontAwesome.Icon as Icon exposing (Icon)
import FontAwesome.Solid as Icon
import Html as Html exposing (Html)
import Html.Attributes as HtmlA
import MassiveDecks.Card.Source.Model as Source
import MassiveDecks.Icon as Icon
import MassiveDecks.Model exposing (Shared)
import MassiveDecks.Strings as Strings exposing (..)
import MassiveDecks.Strings.Languages.En as En
import MassiveDecks.Strings.Languages.Model exposing (Language)
Expand All @@ -16,6 +18,7 @@ type alias Context =
{ lang : Language
, translate : MdString -> List Translation.Result
, parent : MdString
, shared : Shared
}


Expand Down Expand Up @@ -237,7 +240,12 @@ enhanceHtml context mdString unenhanced =
term context PlayedDescription Icon.check unenhanced

ManyDecksWhereToGet ->
[ Html.blankA [ HtmlA.href "https://decks.md.rereadgames.com/" ] unenhanced ]
case context.shared.sources.manyDecks of
Just { baseUrl } ->
[ Html.blankA [ HtmlA.href baseUrl ] unenhanced ]

Nothing ->
unenhanced

_ ->
unenhanced
Expand Down
2 changes: 2 additions & 0 deletions client/src/scss/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ $secondary-background: #cccccc;
$transparent: rgba(#ffffff, 0);

$card: #ffffff;

$many-decks: #00796b;
4 changes: 3 additions & 1 deletion client/src/scss/cards/_sources.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@use "../_colors";

.many-decks-deck-code {
font-family: monospace;
background-color: #00796b;
background-color: colors.$many-decks;
color: #ffffff;
padding: 0.5em;
letter-spacing: 0.2em;
Expand Down
33 changes: 33 additions & 0 deletions client/src/scss/pages/_start.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,36 @@
}
}
}

#many-decks-ad div {
position: fixed;
left: -0.8em;
top: -3em;

display: flex;
flex-direction: column-reverse;
align-items: center;
text-align: center;
justify-content: flex-start;

width: 7em;
height: 7em;
border-radius: 100%;

transition: left 0.25s, top 0.25s;

transform: rotate(-15deg);

font-size: 1.2em;
background-color: colors.$many-decks;
color: #ffffff;

> * {
margin-bottom: 0.5em;
}

&:hover {
left: -0.7em;
top: -2.5em;
}
}
2 changes: 1 addition & 1 deletion server/decks/cah-base-en.deck.json5
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
],
responses: [
"silence",
"the illusion of choice ina late-stage capitalist society",
"the illusion of choice in a late-stage capitalist society",
"many bats",
"famine",
"flesh-eating bacteria",
Expand Down
3 changes: 3 additions & 0 deletions server/src/ts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ const parseManyDecks = (
manyDecks: BaseManyDecks<UnparsedDuration>
): ManyDecks => ({
...manyDecks,
baseUrl: manyDecks.baseUrl.endsWith("/")
? manyDecks.baseUrl
: manyDecks.baseUrl + "/",
timeout: parseDuration(manyDecks.timeout),
});

Expand Down
7 changes: 5 additions & 2 deletions server/src/ts/games/cards/sources/many-decks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ export interface ClientInfo {

export class Resolver extends Source.Resolver<ManyDecks> {
public readonly source: ManyDecks;
private readonly config: Config.ManyDecks;
private readonly connectionPool: genericPool.Pool<AxiosInstance>;

public constructor(
source: ManyDecks,
config: Config.ManyDecks,
connectionPool: genericPool.Pool<AxiosInstance>
) {
super();
this.source = source;
this.config = config;
this.connectionPool = connectionPool;
}

Expand Down Expand Up @@ -80,6 +83,7 @@ export class Resolver extends Source.Resolver<ManyDecks> {
const summary = {
details: {
name: data.name,
url: `${this.config.baseUrl}decks/${this.source.deckCode}`,
author: data.author,
translator: data.translator,
language: data.language,
Expand Down Expand Up @@ -137,7 +141,6 @@ export class MetaResolver implements Source.MetaResolver<ManyDecks> {
timeout: config.timeout,
responseType: "json",
};
console.log(JSON.stringify(httpConfig));

this.connectionPool = genericPool.createPool(
{
Expand All @@ -161,7 +164,7 @@ export class MetaResolver implements Source.MetaResolver<ManyDecks> {
}

resolver(source: ManyDecks): Resolver {
return new Resolver(source, this.connectionPool);
return new Resolver(source, this.config, this.connectionPool);
}
}

Expand Down

0 comments on commit 1bc4f07

Please sign in to comment.