Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
shift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Trujillo
shift
Commits
64d2cd05
Commit
64d2cd05
authored
4 years ago
by
Eduardo Trujillo
Browse files
Options
Downloads
Patches
Plain Diff
feat(Server): Add exterimental web server
parent
89e5d59e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
shift.cabal
+2
-0
2 additions, 0 deletions
shift.cabal
src/Shift.hs
+2
-0
2 additions, 0 deletions
src/Shift.hs
src/Shift/CLI.hs
+53
-39
53 additions, 39 deletions
src/Shift/CLI.hs
src/Shift/Server.hs
+16
-0
16 additions, 0 deletions
src/Shift/Server.hs
with
73 additions
and
39 deletions
shift.cabal
+
2
−
0
View file @
64d2cd05
...
...
@@ -21,6 +21,7 @@ library
, Shift.Parsers
, Shift.Processing
, Shift.Rendering
, Shift.Server
, Shift.Types
, Shift.Utilities
, GitHub.UserSearch
...
...
@@ -48,6 +49,7 @@ library
, exceptions
, semigroups
, cmark-gfm
, scotty
default-language: Haskell2010
executable shift
...
...
This diff is collapsed.
Click to expand it.
src/Shift.hs
+
2
−
0
View file @
64d2cd05
...
...
@@ -11,6 +11,7 @@ import Shift.CLI as X
import
Shift.Git
as
X
import
Shift.Rendering
as
X
import
Shift.Types
as
X
import
Shift.Server
(
runServer
)
-- | The main CLI entrypoint.
shiftMain
::
IO
()
...
...
@@ -19,6 +20,7 @@ shiftMain = do
case
currentOptions
^.
soCommand
of
GenerateCommand
->
tempMain
currentOptions
ServeCommand
->
runServer
currentOptions
where
opts
=
info
(
helper
<*>
shiftOptions
)
...
...
This diff is collapsed.
Click to expand it.
src/Shift/CLI.hs
+
53
−
39
View file @
64d2cd05
{-# LANGUAGE LambdaCase
#-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell
#-}
{-# LANGUAGE TemplateHaskell #-}
module
Shift.CLI
where
import
Options.Applicative
import
Control.Lens
(
makeLenses
)
import
Options.Applicative
data
ShiftOptions
=
ShiftOptions
{
_soCommand
::
ShiftCommand
,
_soHostingType
::
HostingType
,
_soGitHubOwner
::
Maybe
String
,
_soGitHubRepository
::
Maybe
String
,
_soGitHubToken
::
Maybe
String
}
deriving
(
Show
,
Eq
)
{
_soCommand
::
ShiftCommand
,
_soHostingType
::
HostingType
,
_soGitHubOwner
::
Maybe
String
,
_soGitHubRepository
::
Maybe
String
,
_soGitHubToken
::
Maybe
String
}
deriving
(
Show
,
Eq
)
data
ShiftCommand
=
GenerateCommand
deriving
(
Show
,
Eq
,
Enum
)
data
ShiftCommand
=
GenerateCommand
|
ServeCommand
deriving
(
Show
,
Eq
,
Enum
)
data
HostingType
=
GitHubType
|
GitType
deriving
(
Show
,
Eq
,
Enum
)
shiftOptions
::
Parser
ShiftOptions
shiftOptions
=
ShiftOptions
<$>
shiftCommand
<*>
option
hostingType
(
long
"hosting-type"
<>
short
't'
<>
metavar
"TYPE"
<>
help
"Which kind of service the repository is hosted on"
)
<*>
optional
(
strOption
(
long
"github-owner"
<>
metavar
"USERNAME"
<>
help
"Username who owns the repository"
))
<*>
optional
(
strOption
(
long
"github-repository"
<>
metavar
"REPOSITORY"
<>
help
"Name of the repository"
))
<*>
optional
(
strOption
(
long
"github-token"
<>
metavar
"TOKEN"
<>
help
"GitHub access token"
))
shiftOptions
=
ShiftOptions
<$>
shiftCommand
<*>
option
hostingType
(
long
"hosting-type"
<>
short
't'
<>
metavar
"TYPE"
<>
help
"Which kind of service the repository is hosted on"
)
<*>
optional
(
strOption
(
long
"github-owner"
<>
metavar
"USERNAME"
<>
help
"Username who owns the repository"
)
)
<*>
optional
(
strOption
(
long
"github-repository"
<>
metavar
"REPOSITORY"
<>
help
"Name of the repository"
)
)
<*>
optional
(
strOption
(
long
"github-token"
<>
metavar
"TOKEN"
<>
help
"GitHub access token"
)
)
shiftCommand
::
Parser
ShiftCommand
shiftCommand
=
subparser
$
command
"generate"
(
info
(
pure
GenerateCommand
)
(
progDesc
"Generate changelog"
)
)
shiftCommand
=
subparser
$
command
"generate"
(
info
(
pure
GenerateCommand
)
(
progDesc
"Generate changelog"
)
)
<>
command
"serve"
(
info
(
pure
ServeCommand
)
(
progDesc
"Start UI server"
))
hostingType
::
ReadM
HostingType
hostingType
=
eitherReader
$
\
case
...
...
This diff is collapsed.
Click to expand it.
src/Shift/Server.hs
0 → 100644
+
16
−
0
View file @
64d2cd05
{-# LANGUAGE OverloadedStrings #-}
module
Shift.Server
(
runServer
)
where
import
Web.Scotty
(
scotty
,
get
,
param
,
html
)
import
Shift.CLI
(
ShiftOptions
)
import
Shift.Git
(
renderToNode
)
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
))
import
CMarkGFM
(
nodeToHtml
,
nodeToHtml
,
commonmarkToHtml
)
import
Data.Text.Lazy
(
fromChunks
)
runServer
::
ShiftOptions
->
IO
()
runServer
options
=
scotty
3000
$
get
"/"
$
do
node
<-
liftIO
$
renderToNode
options
html
$
fromChunks
[
nodeToHtml
[]
[]
node
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment