diff --git a/src/Vervis/Handler/Key.hs b/src/Vervis/Handler/Key.hs index e9eee88..7e6057f 100644 --- a/src/Vervis/Handler/Key.hs +++ b/src/Vervis/Handler/Key.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2018 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -31,6 +31,7 @@ import Data.Text (Text, intercalate) import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Database.Persist +import Network.HTTP.Types (StdMethod (DELETE)) import Text.Blaze.Html (Html, toHtml) import Yesod.Auth (requireAuthId) import Yesod.Core (defaultLayout) @@ -45,6 +46,7 @@ import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident import Vervis.Settings +import Vervis.Widget (buttonW) getKeysR :: Handler Html getKeysR = do diff --git a/src/Vervis/Handler/Repo/Darcs.hs b/src/Vervis/Handler/Repo/Darcs.hs index d28330b..e3b2852 100644 --- a/src/Vervis/Handler/Repo/Darcs.hs +++ b/src/Vervis/Handler/Repo/Darcs.hs @@ -32,6 +32,7 @@ import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Data.Traversable (for) import Database.Esqueleto +import Network.HTTP.Types (StdMethod (DELETE)) import System.FilePath ((), joinPath) import System.Directory (doesFileExist) import Text.Blaze.Html (Html) @@ -65,6 +66,7 @@ import Vervis.Settings import Vervis.SourceTree import Vervis.Style import Vervis.Time +import Vervis.Widget (buttonW) import Vervis.Widget.Repo import Vervis.Widget.Sharer diff --git a/src/Vervis/Handler/Repo/Git.hs b/src/Vervis/Handler/Repo/Git.hs index da8f777..fa9cfba 100644 --- a/src/Vervis/Handler/Repo/Git.hs +++ b/src/Vervis/Handler/Repo/Git.hs @@ -42,6 +42,7 @@ import Data.Text.Encoding.Error (lenientDecode) import Data.Traversable (for) import Database.Esqueleto import Data.Hourglass (timeConvert) +import Network.HTTP.Types (StdMethod (DELETE)) import System.Directory (createDirectoryIfMissing) import System.Hourglass (dateCurrent) import Text.Blaze.Html (Html) @@ -75,6 +76,7 @@ import Vervis.Settings import Vervis.SourceTree import Vervis.Style import Vervis.Time (showDate) +import Vervis.Widget (buttonW) import Vervis.Widget.Repo import Vervis.Widget.Sharer (personLinkW) diff --git a/src/Vervis/Handler/Role.hs b/src/Vervis/Handler/Role.hs index 5bf7b37..2dfef58 100644 --- a/src/Vervis/Handler/Role.hs +++ b/src/Vervis/Handler/Role.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2018 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -38,6 +38,7 @@ where import Prelude import Database.Persist +import Network.HTTP.Types (StdMethod (DELETE)) import Text.Blaze.Html (Html) import Yesod.Auth (requireAuthId) import Yesod.Core (defaultLayout, setMessage) @@ -52,6 +53,7 @@ import Vervis.Model import Vervis.Model.Ident (ShrIdent, RlIdent, rl2text) import Vervis.Role import Vervis.Settings (widgetFile) +import Vervis.Widget (buttonW) import Vervis.Widget.Role getRepoRolesR :: ShrIdent -> Handler Html diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 732d27f..125e342 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -68,6 +68,7 @@ import Data.Time.Format (formatTime, defaultTimeLocale) import Data.Traversable (for) import Database.Esqueleto hiding ((=.), (+=.), update, delete) import Database.Persist hiding ((==.)) +import Network.HTTP.Types (StdMethod (DELETE, POST)) import Text.Blaze.Html (Html, toHtml) import Yesod.Auth (requireAuthId, maybeAuthId) import Yesod.Core (defaultLayout) @@ -96,6 +97,7 @@ import Vervis.Style import Vervis.Ticket import Vervis.TicketFilter (filterTickets) import Vervis.Time (showDate) +import Vervis.Widget (buttonW) import Vervis.Widget.Discussion (discussionW) import Vervis.Widget.Sharer (personLinkW) import Vervis.Widget.Ticket diff --git a/src/Vervis/Handler/Workflow.hs b/src/Vervis/Handler/Workflow.hs index ea9bec9..99b1ac3 100644 --- a/src/Vervis/Handler/Workflow.hs +++ b/src/Vervis/Handler/Workflow.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2018 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -50,6 +50,7 @@ import Prelude import Data.Maybe (fromMaybe) import Data.Text (Text) import Database.Persist +import Network.HTTP.Types (StdMethod (DELETE, PUT)) import Text.Blaze.Html (Html) import Yesod.Auth (requireAuthId) import Yesod.Core (defaultLayout) @@ -64,6 +65,7 @@ import Vervis.Model import Vervis.Model.Ident import Vervis.Model.Workflow import Vervis.Settings +import Vervis.Widget (buttonW) import Vervis.Widget.Sharer ------------------------------------------------------------------------------- diff --git a/src/Vervis/Widget.hs b/src/Vervis/Widget.hs index 2e03e0f..bb80ee8 100644 --- a/src/Vervis/Widget.hs +++ b/src/Vervis/Widget.hs @@ -18,6 +18,7 @@ module Vervis.Widget ( breadcrumbsW , revisionW , avatarW + , buttonW ) where @@ -28,7 +29,8 @@ import Data.Time.Calendar (toGregorian) import Data.Time.Clock (UTCTime (..)) import Development.Darcs.Rev import Formatting (sformat, (%), int, left) -import Yesod.Core (YesodBreadcrumbs, breadcrumbs) +import Network.HTTP.Types (StdMethod) +import Yesod.Core import Yesod.Core.Widget import qualified Data.Text as T (take) @@ -62,3 +64,15 @@ avatarW secure email = do $nothing

INVALID EMAIL |] + +buttonW :: StdMethod -> Text -> Route site -> WidgetT site IO () +buttonW method content route = do + let tokenKey = defaultCsrfParamName + mtoken <- reqToken <$> getRequest + [whamlet| +

+ + $maybe n <- mtoken + + + |] diff --git a/templates/key/one.hamlet b/templates/key/one.hamlet index 47f98b8..52508dc 100644 --- a/templates/key/one.hamlet +++ b/templates/key/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .

- - - + ^{buttonW DELETE "Delete this key" (KeyR tag)} diff --git a/templates/project/role/one.hamlet b/templates/project/role/one.hamlet index a2a822e..1ce8014 100644 --- a/templates/project/role/one.hamlet +++ b/templates/project/role/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .
- - - + ^{buttonW DELETE "Delete this role" (ProjectRoleR shr rl)}

Operations diff --git a/templates/repo/role/one.hamlet b/templates/repo/role/one.hamlet index 42c7a23..3df4912 100644 --- a/templates/repo/role/one.hamlet +++ b/templates/repo/role/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .

- - - + ^{buttonW DELETE "Delete this role" (RepoRoleR shr rl)}

Operations diff --git a/templates/repo/source-darcs.hamlet b/templates/repo/source-darcs.hamlet index 374f8c2..9a2960f 100644 --- a/templates/repo/source-darcs.hamlet +++ b/templates/repo/source-darcs.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -16,9 +16,7 @@ $maybe desc <- repoDesc repository

#{desc}

- - - + ^{buttonW DELETE "Delete this repo" (RepoR user repo)}

Collaborators diff --git a/templates/repo/source-git.hamlet b/templates/repo/source-git.hamlet index 34255d7..aaa3e46 100644 --- a/templates/repo/source-git.hamlet +++ b/templates/repo/source-git.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -16,9 +16,7 @@ $maybe desc <- repoDesc repository

#{desc}

- - - + ^{buttonW DELETE "Delete this repo" (RepoR user repo)}

Collaborators diff --git a/templates/ticket/dep/list.hamlet b/templates/ticket/dep/list.hamlet index 1633147..3bfadb1 100644 --- a/templates/ticket/dep/list.hamlet +++ b/templates/ticket/dep/list.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -32,9 +32,7 @@ $# . #{show status} $if forward

- - - + ^{buttonW DELETE "Remove" (TicketDepR shr prj num number)} $if forward

diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index 8afb795..eff824b 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -15,9 +15,7 @@ $# .

Edit this ticket

- - - + ^{buttonW DELETE "Delete this ticket" (TicketR shar proj num)}

Depended by: @@ -51,13 +49,11 @@ $if ticketStatus ticket /= TSClosed $if me Assigned to you. - - + ^{buttonW POST "Unclaim this ticket" (TicketUnclaimR shar proj num)} $else Assigned to ^{personLinkW assignee}. - - + ^{buttonW POST "Unassign this ticket" (TicketUnassignR shar proj num)} $nothing Not assigned. @@ -65,8 +61,7 @@ $if ticketStatus ticket /= TSClosed or - - + ^{buttonW POST "Claim this ticket" (TicketClaimR shar proj num)} or @@ -88,21 +83,17 @@ $if ticketStatus ticket /= TSClosed $of TSNew Open, new. - - - - + ^{buttonW POST "Accept this ticket" (TicketAcceptR shar proj num)} + ^{buttonW POST "Close this ticket" (TicketCloseR shar proj num)} $of TSTodo Open, to do. - - + ^{buttonW POST "Close this ticket" (TicketCloseR shar proj num)} $of TSClosed Closed on #{showDate $ ticketClosed ticket} by ^{personLinkW closer}. - - + ^{buttonW POST "Reopen this ticket" (TicketOpenR shar proj num)}

#{ticketTitle ticket} diff --git a/templates/workflow/enum/ctor/list.hamlet b/templates/workflow/enum/ctor/list.hamlet index 68d8005..a4e0365 100644 --- a/templates/workflow/enum/ctor/list.hamlet +++ b/templates/workflow/enum/ctor/list.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -25,9 +25,5 @@ $# .
#{fromMaybe "(none)" $ workflowFieldEnumCtorDesc c}
- - - - - - + ^{buttonW PUT "Edit this ctor" (WorkflowEnumCtorR shr wfl enm name)} + ^{buttonW DELETE "Delete this ctor" (WorkflowEnumCtorR shr wfl enm name)} diff --git a/templates/workflow/enum/one.hamlet b/templates/workflow/enum/one.hamlet index b069346..4f471a5 100644 --- a/templates/workflow/enum/one.hamlet +++ b/templates/workflow/enum/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .

- - - + ^{buttonW DELETE "Delete this enum" (WorkflowEnumR shr wfl enm)}

  • diff --git a/templates/workflow/field/one.hamlet b/templates/workflow/field/one.hamlet index 75d9631..9ab9471 100644 --- a/templates/workflow/field/one.hamlet +++ b/templates/workflow/field/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .

    - - - + ^{buttonW DELETE "Delete this field" (WorkflowFieldR shr wfl fld)}

    • diff --git a/templates/workflow/one.hamlet b/templates/workflow/one.hamlet index c01acdb..1dd16be 100644 --- a/templates/workflow/one.hamlet +++ b/templates/workflow/one.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016 by fr33domlover . +$# Written in 2016, 2018 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -13,9 +13,7 @@ $# with this software. If not, see $# .

      - - - + ^{buttonW DELETE "Delete this workflow" (WorkflowR shr wfl)}