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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ app/node_modules
app/elm/elm-stuff
app/elm/tests/elm-stuff
app/js/main.js
app/css/main.css
app/css/oration.css
app/css/
app/package-lock.json
Cargo.lock
*.db
*.retry
.env
.vagrant
staging/deploy
releases
46 changes: 1 addition & 45 deletions app/brunch-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,26 @@ exports.config = {
files: {
javascripts: {
joinTo: "js/oration.js"
},
stylesheets: {
joinTo: "css/oration.css"
}
},
conventions: {
// This option sets where we should place non-css and non-js assets in.
// By default, we set this to "/assets/static". Files in this directory
// will be copied to `paths.public`, which is set below to "../public".
assets: /^(static)/,
ignored: /elm-stuff/
},
// paths configuration
paths: {
// Dependencies and current project directories to watch
watched: ["static", "js", "css", "elm"],
// Where to compile files to
public: "../public"
},
plugins: {
babel: {
// Do not use ES6 compiler for debugging
// Do not use ES6 transpiler for debugging
ignore: [/main.js$/]
},
elmBrunch: {
elmFolder: "elm",
mainModules: ["Main.elm"],
makeParameters: ["--warn","--debug"],
outputFolder: "../js"
},
elmCss: {
projectDir: "elm",
sourcePath: "Stylesheets.elm",
pattern: "Style.elm",
outputDir: "../css"
},
cssnano: {
preset: [
'default',
{discardComments: {removeAll: true}}
]
}
},
modules: {
autoRequire: {
"js/oration.js": ["js/oration"]
}
},
overrides: {
production: {
optimize: true,
sourceMaps: false,
plugins: {
autoReload: {
enabled: false
},
babel: {
//Transpile the main file in production
ignore: []
},
elmBrunch: {
makeParameters: ["--warn"]
}
}
}
}
};
13 changes: 7 additions & 6 deletions app/elm/Main.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Main exposing (main)

import Html.Styled exposing (toUnstyled)
import Http
import Models exposing (Model, Status(Commenting))
import Msg exposing (Msg)
Expand All @@ -14,7 +15,7 @@ import View exposing (view)

main : Program Never Model Msg
main =
Navigation.program Msg.Post { init = init, view = view, update = update, subscriptions = subscriptions }
Navigation.program Msg.Pathname { init = init, view = view >> toUnstyled, update = update, subscriptions = subscriptions }


init : Navigation.Location -> ( Model, Cmd Msg )
Expand All @@ -31,27 +32,27 @@ init location =
}
, comments = []
, count = 0
, post = location
, pathname = location.pathname
, title = ""
, debug = ""
, now = dateTime zero
, editTimeout = 120
, blogAuthor = ""
, status = Commenting
}
, initialise location
, initialise location.pathname
)


initialise : Navigation.Location -> Cmd Msg
initialise location =
initialise : String -> Cmd Msg
initialise pathname =
let
loadHashes =
Request.Init.hashes
|> Http.toTask

loadComments =
Request.Comment.comments location
Request.Comment.comments pathname
|> Http.toTask
in
Cmd.batch
Expand Down
2 changes: 1 addition & 1 deletion app/elm/Markdown.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Markdown

-}

import Html exposing (Attribute, Html)
import Html.Styled exposing (Attribute, Html)
import Native.Markdown


Expand Down
3 changes: 1 addition & 2 deletions app/elm/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Models exposing (Model, Status(..))

import Data.Comment exposing (Comment, Inserted)
import Data.User exposing (User)
import Navigation exposing (Location)
import Time.DateTime exposing (DateTime)


Expand All @@ -12,7 +11,7 @@ type alias Model =
, user : User
, comments : List Comment
, count : Int
, post : Location
, pathname : String
, title : String
, debug : String
, now : DateTime
Expand Down
2 changes: 1 addition & 1 deletion app/elm/Msg.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Msg
| UpdatePreview
| SetPreview (Maybe String)
| Count (Result Http.Error String)
| Post Location
| Pathname Location
| StoreUser
| Title String
| PostComment
Expand Down
114 changes: 0 additions & 114 deletions app/elm/Native/LocalStorage.js

This file was deleted.

15 changes: 7 additions & 8 deletions app/elm/Request/Comment.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import Http
import HttpBuilder
import Json.Decode as Decode
import Models exposing (Model)
import Navigation exposing (Location)


{-| Request the number of comments for a given post
-}
count : Location -> Http.Request String
count location =
count : String -> Http.Request String
count pathname =
"/oration/count"
|> HttpBuilder.get
|> HttpBuilder.withQueryParams [ ( "url", location.pathname ) ]
|> HttpBuilder.withQueryParams [ ( "url", pathname ) ]
|> HttpBuilder.withExpect Http.expectString
|> HttpBuilder.toRequest

Expand All @@ -29,7 +28,7 @@ post model =
body =
[ ( "comment", model.comment )
, ( "title", model.title )
, ( "path", model.post.pathname )
, ( "path", model.pathname )
]

--User details are only sent if they exist
Expand Down Expand Up @@ -122,8 +121,8 @@ delete id identity =

{-| Request the comments for the current url
-}
comments : Location -> Http.Request (List Comment)
comments location =
comments : String -> Http.Request (List Comment)
comments pathname =
let
expect =
Decode.list Comment.decoder
Expand All @@ -132,7 +131,7 @@ comments location =
in
"/oration/comments"
|> HttpBuilder.get
|> HttpBuilder.withQueryParams [ ( "url", location.pathname ) ]
|> HttpBuilder.withQueryParams [ ( "url", pathname ) ]
|> HttpBuilder.withExpect expect
|> HttpBuilder.toRequest

Expand Down
Loading