Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:
Upgrade to 0.19, rearchitect everything!

# The commit message #2 will be skipped:

#	Add elm.json

# The commit message #3 will be skipped:

#	Vendor date-format and ISO8601

# The commit message #4 will be skipped:

#	Refactor out Json.Encode.Extra

# The commit message #5 will be skipped:

#	Use Browser.setScrollTop over Dom.Scroll.toTop

# The commit message #6 will be skipped:

#	UrlParser --> Url.Parser

# The commit message #7 will be skipped:

#	Use Posix over Date

# The commit message #8 will be skipped:

#	Use new style attribute

# The commit message #9 will be skipped:

#	% --> modBy

# The commit message #10 will be skipped:

#	wip

# The commit message #1 will be skipped:

#	Switch to DateFormat

# The commit message #2 will be skipped:

#	wip

# The commit message #3 will be skipped:

#	Upgrade some stuff

# The commit message #4 will be skipped:

#	Use Posix more

# The commit message #5 will be skipped:

#	Fix some ISO8601 and Util stuff.

# The commit message #6 will be skipped:

#	Fix some URL parsing stuff.

# The commit message #7 will be skipped:

#	Fix a toString

# The commit message #8 will be skipped:

#	s/browser/application

# The commit message #9 will be skipped:

#	Use new HttpBuilder QueryParameter

# The commit message #10 will be skipped:

#	Use new Encode.list

# The commit message #1 will be skipped:

#	Fix some more toString usages

# The commit message #2 will be skipped:

#	Don't shadow

# The commit message #3 will be skipped:

#	modifyUrl -> replaceUrl

# The commit message #4 will be skipped:

#	Update main

# The commit message #5 will be skipped:

#	Set titles

# The commit message #6 will be skipped:

#	Use a parser for 8601

# The commit message #7 will be skipped:

#	Remove a Debug.crash

# The commit message #8 will be skipped:

#	More timezone stuff

# The commit message #9 will be skipped:

#	REVERT THIS

# The commit message #10 will be skipped:

#	Give setScrollTop another argument.

# The commit message #1 will be skipped:

#	Add Makefile

# The commit message #2 will be skipped:

#	s/View/Page/g

# The commit message #3 will be skipped:

#	s/Page/CurrentPage

# The commit message #4 will be skipped:

#	Use :: over [foo] ++

# The commit message #5 will be skipped:

#	Move Username into its own module

# The commit message #6 will be skipped:

#	Move Article.Tag into its own module

# The commit message #7 will be skipped:

#	Move Feed.Source into its own module

# The commit message #8 will be skipped:

#	Move Article.Slug into its own module

# The commit message #9 will be skipped:

#	Fix compilation errors.

# The commit message #10 will be skipped:

#	Rename Data.UserPhoto to Data.User.Photo

# The commit message #1 will be skipped:

#	:art: elm-format

# The commit message #2 will be skipped:

#	s/defaultValue/value/g

# The commit message #3 will be skipped:

#	Add favicons

# The commit message #4 will be skipped:

#	Passwords must be at least 6 chars.

# The commit message #5 will be skipped:

#	Empty string photos should also use default photo.

# The commit message #6 will be skipped:

#	:art: Give a thing a name

# The commit message #7 will be skipped:

#	Upgrade to lukewestby/http-builder 1.0.1

# The commit message #8 will be skipped:

#	Don't use record updates where they no longer work.

# The commit message #9 will be skipped:

#	:art: elm-format v0.8

# The commit message #10 will be skipped:

#	Fix Parser errorsg

# The commit message #1 will be skipped:

#	Upgrade Iso8601

# The commit message #2 will be skipped:

#	rm elm-package.json

# The commit message #3 will be skipped:

#	Refactor decodeUserFromJson

# The commit message #4 will be skipped:

#	Refactor sessionChange

# The commit message #5 will be skipped:

#	Explicitly name more arguments

# The commit message #6 will be skipped:

#	Use pattern match over Maybe.map/withDefault

# The commit message #7 will be skipped:

#	Upgrade to latest NoRedInk/json-pipeline-decoder

# The commit message #8 will be skipped:

#	Restore rtfeldman/elm-validate

# The commit message #9 will be skipped:

#	Replace SelectList with custom data structure

# The commit message #10 will be skipped:

#	Finish getting things compiling.

# The commit message #1 will be skipped:

#	Fix date formatting, upgrade elm-validate

# The commit message #2 will be skipped:

#	Drop obsolete Util.pair and Util.viewIf

# The commit message #3 will be skipped:

#	Unify Data.* and Request.*
#
#	I had a few guiding principles here:
#
#	1. Organize modules around data structures. How should it be possible to
#	create these things? If it should only be possible to create these
#	things through a HTTP request, then that's the only way I'll expose!
#	Encoding expectations in APIs is awesome.
#	2. Tailor client data structures to the client, not to the server. For
#	example, I'm not using updatedAt anywhere. Why decode it, store it, and
#	expose it just because the server sends it?
#	3. Unify User, Author, and Profile into User with one type parameter.
#	Email and AuthToken are only used for the current user, whereas
#	following is only used for other users. They share all the rest of the
#	info!
#	4. Drop Ports.elm in favor of exposing those APIs where they make sense.

# The commit message #4 will be skipped:

#	Split User into Me and Profile.
#
#	They're fundamentally different. Having 3 fields in common isn't reason
#	enough to have them share a type!

# The commit message #5 will be skipped:

#	Reorganize Session

# The commit message #6 will be skipped:

#	Get things compiling.

# The commit message #7 will be skipped:

#	Convert fragment to path

# The commit message #8 will be skipped:

#	Reorganize some comments

# The commit message #9 will be skipped:

#	Clean up some comments

# The commit message #10 will be skipped:

#	Pass flags properly

# The commit message #1 will be skipped:

#	Fix some hrefs

# The commit message #2 will be skipped:

#	Fix feed source ordering

# The commit message #3 will be skipped:

#	De-vendor iso8601

# The commit message #4 will be skipped:

#	Demote parser and regex to indirect deps

# The commit message #5 will be skipped:

#	:skull: Dead code

# The commit message #6 will be skipped:

#	Update some more comments

# The commit message #7 will be skipped:

#	Past tense msg

# The commit message #8 will be skipped:

#	Use Api.url over apiUrl

# The commit message #9 will be skipped:

#	s/profile/author

# The commit message #10 will be skipped:

#	:skull: obsolete comment

# The commit message #1 will be skipped:

#	Replace ArticleRecord with Metadata

# The commit message #2 will be skipped:

#	Document Metadata

# The commit message #3 will be skipped:

#	Rename UserPhoto to Avatar

# The commit message #4 will be skipped:

#	Renamte get to fetch

# The commit message #5 will be skipped:

#	Move author out of metadata

# The commit message #6 will be skipped:

#	:art: elm-format

# The commit message #7 will be skipped:

#	Reorganize some stuff

# The commit message #8 will be skipped:

#	Upgrade to elm-validate 4.0.0

# The commit message #9 will be skipped:

#	Inline Article.delete into Page.Article

# The commit message #10 will be skipped:

#	Add Api.listErrors

# The commit message #1 will be skipped:

#	Store session info from Main.

# The commit message #2 will be skipped:

#	s/convert/transform/g

# The commit message #3 will be skipped:

#	Revamp Author and Me

# The commit message #4 will be skipped:

#	Bump elm-iso8601 for bugfix

# The commit message #5 will be skipped:

#	Replace Me with AuthToken knowing Username

# The commit message #6 will be skipped:

#	Swap order on Session.Internals

# The commit message #7 will be skipped:

#	wip

# The commit message #8 will be skipped:

#	s/NoOp/Ignored/g

# The commit message #9 will be skipped:

#	s/Views.Article/Article.Preview/g

# The commit message #10 will be skipped:

#	Move Views.Author into Author.

# The commit message #1 will be skipped:

#	Move Skeleton and Views.Errors into Page

# The commit message #2 will be skipped:

#	Rename Views.Follow to Author.Follow

# The commit message #3 will be skipped:

#	Drop obsolete loading spinner

# The commit message #4 will be skipped:

#	Rename Views.Assets to Assets

# The commit message #5 will be skipped:

#	Rename Views.Article.Favorite to Article.Favorite

# The commit message #6 will be skipped:

#	Rename ActivePage to Page

# The commit message #7 will be skipped:

#	Rename Views.Form to Field

# The commit message #8 will be skipped:

#	Revert "Rename Views.Form to Field"
#
#	This reverts commit 15032ce.

# The commit message #9 will be skipped:

#	Rename Views.Form to Form

# The commit message #10 will be skipped:

#	Split Util into more specific modules.

# The commit message #1 will be skipped:

#	Move viewTimestamp into Timestamp.view

# The commit message #2 will be skipped:

#	Remove Author.Follow

# The commit message #3 will be skipped:

#	Rename LoggedInUser to Viewer, other stuff.

# The commit message #4 will be skipped:

#	Revamp Article Editor data model.

# The commit message #5 will be skipped:

#	Revamp all the everythings.

# The commit message #6 will be skipped:

#	Rename Creds to Cred

# The commit message #7 will be skipped:

#	Remove AuthRequired

# The commit message #8 will be skipped:

#	Rule out some more login states.

# The commit message #9 will be skipped:

#	Add more error handling to Api

# The commit message #10 will be skipped:

#	Fix typo

# The commit message #1 will be skipped:

#	s/Log in/Sign in

# The commit message #2 will be skipped:

#	Add Loading.error

# The commit message #3 will be skipped:

#	Use pattern matching more

# The commit message #4 will be skipped:

#	:skull: dead code

# The commit message #5 will be skipped:

#	Go back to the old style of tupled update

# The commit message #6 will be skipped:

#	Consolidate update helpers

# The commit message #7 will be skipped:

#	Be more consistent about Fail and Log.error.

# The commit message #8 will be skipped:

#	Inline banner

# The commit message #9 will be skipped:

#	:skull: withFavoriteButton

# The commit message #10 will be skipped:

#	Simplify viewComment

# The commit message #1 will be skipped:

#	Make followButton cases nicer

# The commit message #2 will be skipped:

#	Centralize optionalErrors

# The commit message #3 will be skipped:

#	Better names

# The commit message #4 will be skipped:

#	Minor tweaks

# The commit message #5 will be skipped:

#	Ellipses

# The commit message #6 will be skipped:

#	Revert "Ellipses"
#
#	This reverts commit 267256f92c76313203882e5289ecee0a4bf95ab1.

# The commit message #7 will be skipped:

#	:skull: unused import

# The commit message #8 will be skipped:

#	Remove Email opaque type

# The commit message #9 will be skipped:

#	Revert "Remove Email opaque type"
#
#	This reverts commit 92b21c2d83c63890c856823efe0545c8c780e89c.

# The commit message #10 will be skipped:

#	:skull: Form

# The commit message #1 will be skipped:

#	wip

# The commit message #2 will be skipped:

#	Simplify some stuff

# The commit message #3 will be skipped:

#	Drop em dash

# The commit message #4 will be skipped:

#	Fix some Author decoder stuff

# The commit message #5 will be skipped:

#	Inline Article.Preview

# The commit message #6 will be skipped:

#	Change type of follow/unfollow buttons a bit.

# The commit message #7 will be skipped:

#	Fix errors decoder

# The commit message #8 will be skipped:

#	Fix login/register redirects

# The commit message #9 will be skipped:

#	Weird bug

# The commit message #10 will be skipped:

#	Remove Debug.logs

# The commit message #1 will be skipped:

#	Fix weird bug

# The commit message #2 will be skipped:

#	Remove Session Internals
  • Loading branch information
Richard Feldman committed Aug 11, 2018
1 parent 298bfdf commit b00857e
Show file tree
Hide file tree
Showing 80 changed files with 5,084 additions and 3,314 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

MAIN_FILE = src/Main.elm
OUTPUT_FILE = elm.js
RUN_UGLIFY = npx uglify-js $(OUTPUT_FILE) --output=$(OUTPUT_FILE)

.PHONY: production dev test

production:
npx elm make --optimize $(MAIN_FILE) --output=$(OUTPUT_FILE) && echo "Uglifying output..." && $(RUN_UGLIFY) --compress --mangle

dev:
npx elm-live $(MAIN_FILE) --output=$(OUTPUT_FILE) --pushstate --debug

test:
npx elm-test
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ Check out [the full writeup](https://dev.to/rtfeldman/tour-of-an-open-source-elm

# Getting started

If you don't already have `elm` and `elm-live`:
I set this up with `make` to show that you can make a SPA in Elm with any
build tool you like! It takes very little configuration.

> npm install -g elm elm-live
To build production assets (including minification):

Then, to build everything:
> make
> elm-live --output=elm.js src/Main.elm --pushstate --open --debug
To build local development (including the time-traveling debugger)

> make dev
(Leave off the `--debug` if you don't want the time-traveling debugger.)
Binary file added assets/icons/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/icons/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added assets/icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon.ico
Binary file not shown.
Binary file added assets/icons/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions assets/icons/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions assets/images/loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions assets/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
26 changes: 0 additions & 26 deletions elm-package.json

This file was deleted.

35 changes: 35 additions & 0 deletions elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"NoRedInk/json-decode-pipeline": "1.0.0",
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/http": "1.0.0",
"elm/json": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-explorations/markdown": "1.0.0",
"lukewestby/elm-http-builder": "6.0.0",
"rtfeldman/elm-iso8601": "1.0.1"
},
"indirect": {
"elm/parser": "1.0.0",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.0.0"
},
"indirect": {
"elm/random": "1.0.0"
}
}
}
20 changes: 14 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
<head>
<meta charset="utf-8">
<title>Conduit</title>

<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
<link rel="manifest" href="/assets/site.webmanifest">
<link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

<!-- Import Ionicon icons & Google Fonts our Bootstrap theme relies on -->
<link href="//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Titillium+Web:700|Source+Serif+Pro:400,700|Merriweather+Sans:400,700|Source+Sans+Pro:400,300,600,700,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">
<!-- Import the custom Bootstrap 4 theme from our hosted CDN -->
<link rel="stylesheet" href="//demo.productionready.io/main.css">
<style>/* Loading spinner courtesy of https://github.com/tobiasahlin/SpinKit */
.sk-three-bounce { margin-right: 10px; } .sk-three-bounce .sk-child { width: 14px; height: 14px; background-color: #333; border-radius: 100%; display: inline-block; -webkit-animation: sk-three-bounce 1.4s ease-in-out 0s infinite both; animation: sk-three-bounce 1.4s ease-in-out 0s infinite both; } .sk-three-bounce .sk-bounce1 { -webkit-animation-delay: 0.28s; animation-delay: 0.28s; } .sk-three-bounce .sk-bounce2 { -webkit-animation-delay: 0.44s; animation-delay: 0.44s; } .sk-three-bounce .sk-bounce3 { -webkit-animation-delay: 0.6s; animation-delay: 0.6s; } @-webkit-keyframes sk-three-bounce { 0%, 80%, 100% { -webkit-transform: scale(0); transform: scale(0); } 40% { -webkit-transform: scale(1); transform: scale(1); } } @keyframes sk-three-bounce { 0%, 80%, 100% { -webkit-transform: scale(0); transform: scale(0); } 40% { -webkit-transform: scale(1); transform: scale(1); } }
</style>


<script src="elm.js"></script>
</head>
<body id="page-body">
<body>
<script>
var app = Elm.Main.fullscreen(localStorage.session || null);
var app = Elm.Main.init({flags: localStorage.session || null});

app.ports.storeSession.subscribe(function(session) {
localStorage.session = session;

// Report that the new session was stored succesfully.
setTimeout(function() { app.ports.onSessionChange.send(session); }, 0);
});

window.addEventListener("storage", function(event) {
Expand Down
55 changes: 55 additions & 0 deletions src/Api.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module Api exposing (addServerError, decodeErrors, url)

import Http
import Json.Decode as Decode exposing (Decoder, decodeString, field, string)
import Json.Decode.Pipeline as Pipeline exposing (optional)
import Url.Builder



-- URL


{-| Get a URL to the Conduit API.
-}
url : List String -> String
url paths =
-- NOTE: Url.Builder takes care of percent-encoding special URL characters.
-- See https://package.elm-lang.org/packages/elm/url/latest/Url#percentEncode
Url.Builder.crossOrigin "https://conduit.productionready.io"
("api" :: paths)
[]



-- ERRORS


addServerError : List String -> List String
addServerError list =
"Server error" :: list


{-| Many API endpoints include an "errors" field in their BadStatus responses.
-}
decodeErrors : Http.Error -> List String
decodeErrors error =
case error of
Http.BadStatus response ->
response.body
|> decodeString (field "errors" errorsDecoder)
|> Result.withDefault [ "Server error" ]

err ->
[ "Server error" ]


errorsDecoder : Decoder (List String)
errorsDecoder =
Decode.keyValuePairs (Decode.list Decode.string)
|> Decode.map (List.concatMap fromPair)


fromPair : ( String, List String ) -> List String
fromPair ( field, errors ) =
List.map (\error -> field ++ " " ++ error) errors
Loading

0 comments on commit b00857e

Please sign in to comment.