Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/elm/Data/Comment.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Data.Comment exposing (Comment, Edited, Inserted, Responses(Responses), count, decoder, delete, disableVote, dislike, editDecoder, encode, getText, insertDecoder, insertNew, like, readOnly, toggleVisible, update)
module Data.Comment exposing (Comment, Edited, Inserted, Responses(..), count, decoder, delete, disableVote, dislike, editDecoder, encode, getText, insertDecoder, insertNew, like, readOnly, toggleVisible, update)

import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Extra as DecodeExtra
Expand Down Expand Up @@ -77,6 +77,7 @@ insertNew insert current =
in
if isNothing insert.parent then
comments ++ List.singleton newComment

else
List.map (\comment -> injectNew insert newComment comment) comments

Expand All @@ -89,6 +90,7 @@ injectNew insert newComment comment =
case comment.children of
Responses responses ->
Responses <| responses ++ List.singleton newComment

else
case comment.children of
Responses responses ->
Expand All @@ -111,6 +113,7 @@ injectUpdates edit comment =
, hash = edit.hash
, editable = True
}

else
mapChildren edit comment injectUpdates

Expand All @@ -124,6 +127,7 @@ switchVisible : Int -> Comment -> Comment
switchVisible id comment =
if comment.id == id then
{ comment | visible = not comment.visible }

else
mapChildren id comment switchVisible

Expand All @@ -146,6 +150,7 @@ filterComment id comment =
in
if noChildren then
Nothing

else
--We must display a masked delete
let
Expand All @@ -163,6 +168,7 @@ filterComment id comment =
, votes = 0
, votable = False
}

else
let
children =
Expand All @@ -182,6 +188,7 @@ removeEditable : Int -> Comment -> Comment
removeEditable id comment =
if comment.id == id then
{ comment | editable = False }

else
mapChildren id comment removeEditable

Expand Down Expand Up @@ -212,6 +219,7 @@ voteComment ( id, like ) comment =
| votes = count
, votable = False
}

else
mapChildren ( id, like ) comment voteComment

Expand All @@ -225,6 +233,7 @@ removeVotable : Int -> Comment -> Comment
removeVotable id comment =
if comment.id == id then
{ comment | votable = False }

else
mapChildren id comment removeVotable

Expand Down Expand Up @@ -266,6 +275,7 @@ findText : Int -> Comment -> String
findText id comment =
if comment.id == id then
comment.text

else
""

Expand Down
1 change: 1 addition & 0 deletions app/elm/Data/User.elm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ getIdentity user =
in
if List.all isNothing data then
user.iphash ? ""

else
-- Join with b since it gives the authors' credentials a cool identicon
Crypto.Hash.sha224 (String.join "b" unwrapped)
Expand Down
2 changes: 1 addition & 1 deletion app/elm/Main.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Main exposing (main)

import Http
import Models exposing (Model, Status(Commenting))
import Models exposing (Model, Status(..))
import Msg exposing (Msg)
import Navigation
import Request.Comment
Expand Down
15 changes: 7 additions & 8 deletions app/elm/Markdown.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
module Markdown
exposing
( Options
, defaultOptions
, toHtml
, toHtmlWith
)
module Markdown exposing
( toHtml
, Options, defaultOptions, toHtmlWith
)

{-| A library for markdown parsing. This is just an Elm API built on top of the
[markdown-it](https://github.com/markdown-it/markdown-it) project which focuses on speed.
Expand Down Expand Up @@ -77,11 +74,13 @@ toHtml attrs string =
-- Russian
{ doubleLeft = "«", doubleRight = "»", singleLeft = "„", singleRight = "“" }


-- German
{ doubleLeft = "„", doubleRight = "“", singleLeft = "‚", singleRight = "‘" }


-- French
{ doubleLeft = "«\xA0", doubleRight = "\xA0»", singleLeft = "‹\xA0", singleRight = "\xA0›" }
{ doubleLeft = "«\u{00A0}", doubleRight = "\u{00A0}»", singleLeft = "‹\u{00A0}", singleRight = "\u{00A0}›" }

[gfm]: https://help.github.com/articles/github-flavored-markdown/
[fenced]: https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks
Expand Down
2 changes: 1 addition & 1 deletion app/elm/Msg.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Msg exposing (..)
module Msg exposing (Msg(..))

import Data.Comment exposing (Comment, Edited, Inserted)
import Data.Init exposing (Init)
Expand Down
2 changes: 1 addition & 1 deletion app/elm/Style.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Style exposing (..)
module Style exposing (OrationClasses(..), OrationIds(..), activeColor, clickableStyle, css, hoverColor, inputStyle, orationNamespace, primaryColor)

import Css exposing (..)
import Css.Elements exposing (button, img, input, label, li, p, textarea, typeSelector)
Expand Down
3 changes: 2 additions & 1 deletion app/elm/Stylesheets.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
port module Stylesheets exposing (..)
port module Stylesheets exposing (fileStructure, files, main)

import Css.File exposing (CssCompilerProgram, CssFileStructure)
import Css.Normalize
import Style



{- Stylesheets -}


Expand Down
13 changes: 12 additions & 1 deletion app/elm/Time/DateTime/Distance.elm
Original file line number Diff line number Diff line change
Expand Up @@ -105,41 +105,52 @@ calculateDistance delta =
in
if minutes == 0 then
LessThanXMinutes 1

else if minutes < 2 then
XMinutes minutes

else if minutes < 45 then
-- 2 mins up to 0.75 hrs
XMinutes minutes

else if minutes < 90 then
-- 0.75 hrs up to 1.5 hrs
AboutXHours 1

else if minutes < minutes_in_day then
-- 1.5 hrs up to 24 hrs
upToOneDay minutes

else if minutes < minutes_in_almost_two_days then
-- 1 day up to 1.75 days
XDays 1

else if minutes < minutes_in_month then
-- 1.75 days up to 30 days
upToOneMonth minutes

else if minutes < minutes_in_two_months then
-- 1 month up to 2 months
upToTwoMonths minutes

else if months < 12 then
-- 2 months up to 12 months
upToOneYear minutes

else
-- 1 year up to max Date
let
monthsSinceStartOfYear =
months % 12
modBy 12 months
in
if monthsSinceStartOfYear < 3 then
-- N years up to 1 years 3 months
AboutXYears years

else if monthsSinceStartOfYear < 9 then
-- N years 3 months up to N years 9 months
OverXYears years

else
-- N years 9 months up to N year 12 months
AlmostXYears <| years + 1
Expand Down
Loading