Display OpenSource/Proprietary stickers on cards

See https://framagit.org/RouxRC/ogptoolbox-floss-data for data analysis
leading to the filtering rule.

(close #45)
parent adbe46bd
module Cards.Item.View exposing (..)
import Cards.Item.Types exposing (..)
import Cards.ViewsParts exposing (..)
import Configuration
import Dict exposing (Dict)
import Html exposing (..)
......@@ -906,6 +907,8 @@ viewSidebar model card =
)
]
]
, div [ class "opensource-card" ]
[ viewCardOpenSourceStatus language values card ]
, let
firstTd =
td [ class "table-label" ]
......
module Cards.ViewsParts exposing (..)
import Dict exposing (Dict)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Attributes.Aria exposing (..)
......@@ -12,6 +13,53 @@ import Types exposing (..)
import Urls
viewCardOpenSourceStatus : I18n.Language -> Dict String TypedValue -> Card -> Html msg
viewCardOpenSourceStatus language values card =
let
repo =
(case I18n.getOneString language repoKeys card values of
Just value ->
String.length value > 8
Nothing ->
False
)
sourceCode =
(case I18n.getOneString language sourceCodeKeys card values of
Just value ->
String.length value > 8
Nothing ->
False
)
openSource =
(case I18n.getOneString language openSourceKeys card values of
Just value ->
String.toLower value == "yes" ||
String.toLower value == "oui"
Nothing ->
False
)
license =
(case I18n.getOneString language licenseKeys card values of
Just value ->
String.toLower value
Nothing ->
""
)
openLicense =
(
String.length license > 1 &&
not (String.contains license "proprieta") &&
not (String.contains license "non-free")
)
in
if repo || sourceCode || openSource || openLicense then
img [ src "/img/open.png", title (I18n.translate language I18n.OpenSource) ] []
else
img [ src "/img/closed.png", title (I18n.translate language I18n.Proprietary) ] []
viewCardThumbnail :
I18n.Language
-> (String -> msg)
......@@ -46,7 +94,14 @@ viewCardThumbnail language navigate onRemoveCard extraClass data card =
in
element
[ class ("thumbnail " ++ extraClass) ]
[ div [ class "visual" ]
[ (case cardType of
ToolCard ->
div [ class "opensource-home" ]
[ viewCardOpenSourceStatus language data.values card ]
_ ->
Html.text ""
)
, div [ class "visual" ]
[ case Urls.imageFullUrl language "500" card data.values of
Just url ->
img [ alt "logo", src url ] []
......
......@@ -210,6 +210,7 @@ type TranslationId
| OpenGovernmentPartnership
| OpenGovernmentPartnershipLogo
| OpenGovParagraph
| OpenSource
| Organization GrammaticalNumber
| OrganizationId
| OrganizationIdField
......@@ -229,6 +230,7 @@ type TranslationId
| PressDescription
| PressLead
| ProfileMyCollections
| Proprietary
| Publish
| PublishCollection
| PublishOrganization
......@@ -1605,6 +1607,12 @@ to strengthen governance.
s "Organizaciones"
}
OpenSource ->
{ english = s "Free Open Source Software"
, french = s "Logiciel Libre Open Source"
, spanish = todo
}
OrganizationId ->
{ english = s "Organization"
, french = s "Organisation"
......@@ -1707,6 +1715,12 @@ to strengthen governance.
, spanish = todo
}
Proprietary ->
{ english = s "Closed Proprietary Software"
, french = s "Logiciel propriétaire fermé"
, spanish = todo
}
Publish ->
{ english = s "Publish"
, french = s "Publier"
......
......@@ -377,6 +377,21 @@ licenseKeys =
[ "license" ]
openSourceKeys : List String
openSourceKeys =
[ "9647" ]
repoKeys : List String
repoKeys =
[ "12795" ]
sourceCodeKeys : List String
sourceCodeKeys =
[ "9389" ]
nameKeys : List String
nameKeys =
[ "name" ]
......
......@@ -10,6 +10,7 @@ import Http exposing (Error(..))
import Http.Error
import I18n
import String
import Cards.ViewsParts exposing (..)
import Tags.ViewsParts exposing (..)
import Types exposing (..)
import Urls
......@@ -110,6 +111,13 @@ viewCardListItem navigate language values card =
)
]
]
, (case cardType of
ToolCard ->
div [ class "opensource" ]
[ viewCardOpenSourceStatus language values card ]
_ ->
Html.text ""
)
, div [ class "caption" ]
[ h4 []
[ aForPath
......
......@@ -286,8 +286,8 @@ nav.navbar.navbar-default {
display: block;
width: 191px;
height: 25px;
background: url(../img/ogptoolbox-logo.png) no-repeat no-repeat ;
background-size: 191px ;
background: url(../img/ogptoolbox-logo.png) no-repeat no-repeat;
background-size: 191px;
margin: 29px 0 25px;
margin-left: 0px !important;
}
......@@ -897,16 +897,16 @@ h4.zone-label {
}
}
&.example, &.tool, &.orga {
&.example, &.tool, &.orga {
box-shadow: none;
border: none;
border-radius: 0px;
}
&.tool .visual, &.orga .visual {
&.tool .visual, &.orga .visual {
background: white;
position: relative;
img {
img {
height: auto;
width: auto;
min-width: auto;
......@@ -921,7 +921,38 @@ h4.zone-label {
}
}
&.tool {
&.tool .opensource, &.orga .opensource {
img {
position: relative;
width: 35px;
height: 35px;
right: 38px;
top: 3px;
}
}
&.tool .opensource-home, &.orga .opensource-home {
img {
position: absolute;
width: 35px;
height: 35px;
right: 5px;
top: 5px;
z-index: 10;
}
}
&.tool .opensource-card, &.orga .opensource-card {
img {
position: absolute;
width: 35px;
height: 35px;
left: 5px;
top: 5px;
}
}
&.tool {
background: white;
box-shadow: none;
border-size: 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment