├── .formatter.exs ├── .gitignore ├── README.md ├── assets ├── .babelrc ├── css │ └── app.scss ├── js │ └── app.js ├── package-lock.json ├── package.json ├── static │ ├── favicon.ico │ ├── images │ │ ├── card.jpg │ │ └── cards │ │ │ ├── eight.png │ │ │ ├── eleven.png │ │ │ ├── fifteen.png │ │ │ ├── five.png │ │ │ ├── four.png │ │ │ ├── fourteen.png │ │ │ ├── nine.png │ │ │ ├── one.png │ │ │ ├── seven.png │ │ │ ├── six.png │ │ │ ├── ten.png │ │ │ ├── thirteen.png │ │ │ ├── three.png │ │ │ ├── twelve.png │ │ │ └── two.png │ └── robots.txt └── webpack.config.js ├── config ├── config.exs ├── dev.exs ├── prod.exs ├── prod.secret.exs └── test.exs ├── gleam.toml ├── lib ├── game.ex ├── game │ ├── application.ex │ ├── card.ex │ ├── engine.ex │ ├── generator.ex │ ├── hash.ex │ ├── process.ex │ ├── random.ex │ ├── registry.ex │ ├── session.ex │ ├── session_supervisor.ex │ └── strucord.ex ├── game_web.ex └── game_web │ ├── channels │ └── user_socket.ex │ ├── controllers │ └── page_controller.ex │ ├── endpoint.ex │ ├── gettext.ex │ ├── live │ ├── page_live.ex │ └── page_live.html.leex │ ├── router.ex │ ├── telemetry.ex │ ├── templates │ ├── layout │ │ ├── app.html.eex │ │ ├── live.html.leex │ │ └── root.html.leex │ └── page │ │ └── index.html.eex │ └── views │ ├── error_helpers.ex │ ├── error_view.ex │ ├── layout_view.ex │ └── page_view.ex ├── mix.exs ├── mix.lock ├── priv └── gettext │ ├── en │ └── LC_MESSAGES │ │ └── errors.po │ └── errors.pot ├── rebar.config ├── src ├── game.app.src └── game.gleam └── test ├── game └── game_test.exs ├── game_web ├── live │ └── page_live_test.exs └── views │ ├── error_view_test.exs │ └── layout_view_test.exs ├── support ├── channel_case.ex └── conn_case.ex └── test_helper.exs /.formatter.exs: -------------------------------------------------------------------------------- 1 | [ 2 | import_deps: [:phoenix], 3 | inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where 3rd-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | game-*.tar 24 | 25 | # If NPM crashes, it generates a log, let's ignore it too. 26 | npm-debug.log 27 | 28 | # The directory NPM downloads your dependencies sources to. 29 | /assets/node_modules/ 30 | 31 | # Since we are building assets from assets/, 32 | # we ignore priv/static. You may want to comment 33 | # this depending on your deployment strategy. 34 | /priv/static/ 35 | 36 | # gleam 37 | /gen/ 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | To install on macOS 4 | 5 | ``` 6 | brew install gleam 7 | ``` 8 | 9 | ## Objectives 10 | 11 | The entire project centers around a single Gleam source file. The game [engine](https://github.com/toranb/elixir-gleam-match/blob/master/src/game.gleam) is driven from the elixir [wrapper](https://github.com/toranb/elixir-gleam-match/blob/master/lib/game/engine.ex) 12 | 13 | ```elixir 14 | defmodule Game.Engine do 15 | def flip(%__MODULE__{} = struct, flip_id) when is_binary(flip_id) do 16 | gleamify(struct, fn record -> 17 | :game.flip(record, flip_id) 18 | end) 19 | end 20 | 21 | def unflip(%__MODULE__{} = struct) do 22 | gleamify(struct, fn record -> 23 | :game.unflip(record) 24 | end) 25 | end 26 | 27 | def prepare_restart(%__MODULE__{} = struct) do 28 | gleamify(struct, fn record -> 29 | :game.prepare_restart(record) 30 | end) 31 | end 32 | end 33 | ``` 34 | 35 | ### flip 36 | 37 |  38 | 39 | This function is executed when the player clicks a playing card. Simply enumerate the cards and mark the one with the id as `flipped` using a boolean. If 2 cards have been flipped at this point attempt to match them by the id. When a match is found mark each card as `paired` and set the `flipped` for both back to false. Finally, if all the cards are paired declare the game over by marking the `winner` using a boolean value. 40 | 41 | One edge case here is that if 2 cards are flipped but they do *not* match, you need to set the `animating` boolean to true. This will later instruct the engine to fire `unflip`. 42 | 43 | ### unflip 44 | 45 |  46 | 47 | This function is executed after a 2nd card has flipped but failed to match. Simply enumerate the cards and mark the `flipped` attribute to false for any non paired card. You will also need to revert `animating` to false so the flip function works properly. 48 | 49 | ### prepare_restart 50 | 51 |  52 | 53 | This function is executed after the player decides to play again. Simply enumerate the cards and mark all `paired` and `flipped` attributes to false. 54 | 55 | ## Debugging Tips 56 | 57 | To print something in the Gleam source code import the io module and use `io.debug` 58 | 59 | ```elixir 60 | import gleam/io 61 | 62 | io.debug("Hello World!") 63 | ``` 64 | 65 | ## Learning Gleam 66 | 67 | Because the language is so young today the best place to dive in is the [getting started](https://gleam.run/) guide 68 | 69 | ## License 70 | 71 | Copyright © 2020 Toran Billups https://toranbillups.com 72 | 73 | Licensed under the MIT License 74 | -------------------------------------------------------------------------------- /assets/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /assets/css/app.scss: -------------------------------------------------------------------------------- 1 | /* This file is for your main application css. */ 2 | @import "../node_modules/nprogress/nprogress.css"; 3 | 4 | html { 5 | color: white; 6 | background: rgb(147,209,245); 7 | } 8 | .cards .card { 9 | position: relative; 10 | display: inline-block; 11 | width: 100px; 12 | height: 150px; 13 | margin: 1em 2em; 14 | } 15 | .cards .card .front, 16 | .cards .card .back { 17 | border-radius: 5px; 18 | position: absolute; 19 | left: 0; 20 | right: 0; 21 | top: 0; 22 | bottom: 0; 23 | width: 100%; 24 | height: 100%; 25 | background-color: white; 26 | backface-visibility: hidden; 27 | transition: transform 0.6s; 28 | transform-style: preserve-3d; 29 | } 30 | .cards .card .back { 31 | background-image: url("/images/card.jpg"); 32 | background-size: 90%; 33 | background-position: center; 34 | background-repeat: no-repeat; 35 | } 36 | .cards .card .front { 37 | transform: rotateY(-180deg); 38 | background-size: 90%; 39 | background-repeat: no-repeat; 40 | background-position: center; 41 | } 42 | .cards .card.flipped .back, 43 | .cards .card.found .back { 44 | transform: rotateY(180deg); 45 | } 46 | .cards .card.flipped .front, 47 | .cards .card.found .front { 48 | transform: rotateY(0deg); 49 | } 50 | .cards .card.found { 51 | opacity: 0.3; 52 | } 53 | .splash { 54 | position: absolute; 55 | left: 0; 56 | right: 0; 57 | top: 0; 58 | bottom: 0; 59 | background-color: rgba(0, 0, 0, 0.5); 60 | } 61 | .splash .content { 62 | position: absolute; 63 | left: 0; 64 | right: 0; 65 | top: 0; 66 | bottom: 0; 67 | width: 400px; 68 | height: 200px; 69 | margin: auto; 70 | text-align: center; 71 | background-color: rgba(51, 51, 51, 0.9); 72 | border-radius: 5px; 73 | padding: 1em; 74 | color: white; 75 | } 76 | .splash .content button { 77 | margin-top: 1.0em; 78 | background-color: #444; 79 | padding: 5px 20px; 80 | border-radius: 4px; 81 | border: 1px solid #555; 82 | color: white; 83 | font-size: 1.4em; 84 | } 85 | .center-all { 86 | display: flex; 87 | align-items: center; 88 | justify-content: center; 89 | } 90 | .text-white { 91 | color: white; 92 | } 93 | -------------------------------------------------------------------------------- /assets/js/app.js: -------------------------------------------------------------------------------- 1 | // We need to import the CSS so that webpack will load it. 2 | // The MiniCssExtractPlugin is used to separate it out into 3 | // its own CSS file. 4 | import "../css/app.scss" 5 | 6 | // webpack automatically bundles all modules in your 7 | // entry points. Those entry points can be configured 8 | // in "webpack.config.js". 9 | // 10 | // Import deps with the dep name or local files with a relative path, for example: 11 | // 12 | // import {Socket} from "phoenix" 13 | // import socket from "./socket" 14 | // 15 | import "phoenix_html" 16 | import {Socket} from "phoenix" 17 | import NProgress from "nprogress" 18 | import {LiveSocket} from "phoenix_live_view" 19 | 20 | let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") 21 | let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}}) 22 | 23 | // Show progress bar on live navigation and form submits 24 | window.addEventListener("phx:page-loading-start", info => NProgress.start()) 25 | window.addEventListener("phx:page-loading-stop", info => NProgress.done()) 26 | 27 | // connect if there are any LiveViews on the page 28 | liveSocket.connect() 29 | 30 | // expose liveSocket on window for web console debug logs and latency simulation: 31 | // >> liveSocket.enableDebug() 32 | // >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session 33 | // >> liveSocket.disableLatencySim() 34 | window.liveSocket = liveSocket 35 | 36 | -------------------------------------------------------------------------------- /assets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "repository": {}, 3 | "description": " ", 4 | "license": "MIT", 5 | "scripts": { 6 | "deploy": "webpack --mode production", 7 | "watch": "webpack --mode development --watch" 8 | }, 9 | "dependencies": { 10 | "phoenix": "file:../deps/phoenix", 11 | "phoenix_html": "file:../deps/phoenix_html", 12 | "phoenix_live_view": "file:../deps/phoenix_live_view", 13 | "nprogress": "^0.2.0" 14 | }, 15 | "devDependencies": { 16 | "@babel/core": "^7.0.0", 17 | "@babel/preset-env": "^7.0.0", 18 | "babel-loader": "^8.0.0", 19 | "copy-webpack-plugin": "^5.1.1", 20 | "css-loader": "^3.4.2", 21 | "sass-loader": "^8.0.2", 22 | "node-sass": "^4.13.1", 23 | "hard-source-webpack-plugin": "^0.13.1", 24 | "mini-css-extract-plugin": "^0.9.0", 25 | "optimize-css-assets-webpack-plugin": "^5.0.1", 26 | "terser-webpack-plugin": "^2.3.2", 27 | "webpack": "4.41.5", 28 | "webpack-cli": "^3.3.2" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assets/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/favicon.ico -------------------------------------------------------------------------------- /assets/static/images/card.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/card.jpg -------------------------------------------------------------------------------- /assets/static/images/cards/eight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/eight.png -------------------------------------------------------------------------------- /assets/static/images/cards/eleven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/eleven.png -------------------------------------------------------------------------------- /assets/static/images/cards/fifteen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/fifteen.png -------------------------------------------------------------------------------- /assets/static/images/cards/five.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/five.png -------------------------------------------------------------------------------- /assets/static/images/cards/four.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/four.png -------------------------------------------------------------------------------- /assets/static/images/cards/fourteen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/fourteen.png -------------------------------------------------------------------------------- /assets/static/images/cards/nine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/nine.png -------------------------------------------------------------------------------- /assets/static/images/cards/one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/one.png -------------------------------------------------------------------------------- /assets/static/images/cards/seven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/seven.png -------------------------------------------------------------------------------- /assets/static/images/cards/six.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/six.png -------------------------------------------------------------------------------- /assets/static/images/cards/ten.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/ten.png -------------------------------------------------------------------------------- /assets/static/images/cards/thirteen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/thirteen.png -------------------------------------------------------------------------------- /assets/static/images/cards/three.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/three.png -------------------------------------------------------------------------------- /assets/static/images/cards/twelve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/twelve.png -------------------------------------------------------------------------------- /assets/static/images/cards/two.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toranb/elixir-gleam-match/2102b071de2d45a7b528fc4fc7172e62dc72ce50/assets/static/images/cards/two.png -------------------------------------------------------------------------------- /assets/static/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /assets/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const glob = require('glob'); 3 | const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); 4 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 5 | const TerserPlugin = require('terser-webpack-plugin'); 6 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); 7 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 8 | 9 | module.exports = (env, options) => { 10 | const devMode = options.mode !== 'production'; 11 | 12 | return { 13 | optimization: { 14 | minimizer: [ 15 | new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }), 16 | new OptimizeCSSAssetsPlugin({}) 17 | ] 18 | }, 19 | entry: { 20 | 'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js']) 21 | }, 22 | output: { 23 | filename: '[name].js', 24 | path: path.resolve(__dirname, '../priv/static/js'), 25 | publicPath: '/js/' 26 | }, 27 | devtool: devMode ? 'eval-cheap-module-source-map' : undefined, 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.js$/, 32 | exclude: /node_modules/, 33 | use: { 34 | loader: 'babel-loader' 35 | } 36 | }, 37 | { 38 | test: /\.[s]?css$/, 39 | use: [ 40 | MiniCssExtractPlugin.loader, 41 | 'css-loader', 42 | 'sass-loader', 43 | ], 44 | } 45 | ] 46 | }, 47 | plugins: [ 48 | new MiniCssExtractPlugin({ filename: '../css/app.css' }), 49 | new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) 50 | ] 51 | .concat(devMode ? [new HardSourceWebpackPlugin()] : []) 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | # This file is responsible for configuring your application 2 | # and its dependencies with the aid of the Mix.Config module. 3 | # 4 | # This configuration file is loaded before any dependency and 5 | # is restricted to this project. 6 | 7 | # General application configuration 8 | use Mix.Config 9 | 10 | # Configures the endpoint 11 | config :game, GameWeb.Endpoint, 12 | url: [host: "localhost"], 13 | secret_key_base: "GwLnkgaSOj7v/g2aAYLHYfwkOA+Si55i4EzIMdlMJfvDHNm8hyLKpe4FRFvemFC3", 14 | render_errors: [view: GameWeb.ErrorView, accepts: ~w(html json), layout: false], 15 | pubsub_server: Game.PubSub, 16 | live_view: [signing_salt: "oAKTjPAE"] 17 | 18 | # Configures Elixir's Logger 19 | config :logger, :console, 20 | format: "$time $metadata[$level] $message\n", 21 | metadata: [:request_id] 22 | 23 | # Use Jason for JSON parsing in Phoenix 24 | config :phoenix, :json_library, Jason 25 | 26 | # Import environment specific config. This must remain at the bottom 27 | # of this file so it overrides the configuration defined above. 28 | import_config "#{Mix.env()}.exs" 29 | -------------------------------------------------------------------------------- /config/dev.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | 3 | # For development, we disable any cache and enable 4 | # debugging and code reloading. 5 | # 6 | # The watchers configuration can be used to run external 7 | # watchers to your application. For example, we use it 8 | # with webpack to recompile .js and .css sources. 9 | config :game, GameWeb.Endpoint, 10 | http: [port: 4000], 11 | debug_errors: true, 12 | code_reloader: true, 13 | check_origin: false, 14 | watchers: [ 15 | node: [ 16 | "node_modules/webpack/bin/webpack.js", 17 | "--mode", 18 | "development", 19 | "--watch-stdin", 20 | cd: Path.expand("../assets", __DIR__) 21 | ] 22 | ] 23 | 24 | # ## SSL Support 25 | # 26 | # In order to use HTTPS in development, a self-signed 27 | # certificate can be generated by running the following 28 | # Mix task: 29 | # 30 | # mix phx.gen.cert 31 | # 32 | # Note that this task requires Erlang/OTP 20 or later. 33 | # Run `mix help phx.gen.cert` for more information. 34 | # 35 | # The `http:` config above can be replaced with: 36 | # 37 | # https: [ 38 | # port: 4001, 39 | # cipher_suite: :strong, 40 | # keyfile: "priv/cert/selfsigned_key.pem", 41 | # certfile: "priv/cert/selfsigned.pem" 42 | # ], 43 | # 44 | # If desired, both `http:` and `https:` keys can be 45 | # configured to run both http and https servers on 46 | # different ports. 47 | 48 | # Watch static and templates for browser reloading. 49 | config :game, GameWeb.Endpoint, 50 | live_reload: [ 51 | patterns: [ 52 | ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", 53 | ~r"priv/gettext/.*(po)$", 54 | ~r"lib/game_web/(live|views)/.*(ex)$", 55 | ~r"lib/game_web/templates/.*(eex)$" 56 | ] 57 | ] 58 | 59 | # Do not include metadata nor timestamps in development logs 60 | config :logger, :console, format: "[$level] $message\n" 61 | 62 | # Set a higher stacktrace during development. Avoid configuring such 63 | # in production as building large stacktraces may be expensive. 64 | config :phoenix, :stacktrace_depth, 20 65 | 66 | # Initialize plugs at runtime for faster development compilation 67 | config :phoenix, :plug_init_mode, :runtime 68 | -------------------------------------------------------------------------------- /config/prod.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | 3 | # For production, don't forget to configure the url host 4 | # to something meaningful, Phoenix uses this information 5 | # when generating URLs. 6 | # 7 | # Note we also include the path to a cache manifest 8 | # containing the digested version of static files. This 9 | # manifest is generated by the `mix phx.digest` task, 10 | # which you should run after static files are built and 11 | # before starting your production server. 12 | config :game, GameWeb.Endpoint, 13 | url: [host: "example.com", port: 80], 14 | cache_static_manifest: "priv/static/cache_manifest.json" 15 | 16 | # Do not print debug messages in production 17 | config :logger, level: :info 18 | 19 | # ## SSL Support 20 | # 21 | # To get SSL working, you will need to add the `https` key 22 | # to the previous section and set your `:url` port to 443: 23 | # 24 | # config :game, GameWeb.Endpoint, 25 | # ... 26 | # url: [host: "example.com", port: 443], 27 | # https: [ 28 | # port: 443, 29 | # cipher_suite: :strong, 30 | # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), 31 | # certfile: System.get_env("SOME_APP_SSL_CERT_PATH"), 32 | # transport_options: [socket_opts: [:inet6]] 33 | # ] 34 | # 35 | # The `cipher_suite` is set to `:strong` to support only the 36 | # latest and more secure SSL ciphers. This means old browsers 37 | # and clients may not be supported. You can set it to 38 | # `:compatible` for wider support. 39 | # 40 | # `:keyfile` and `:certfile` expect an absolute path to the key 41 | # and cert in disk or a relative path inside priv, for example 42 | # "priv/ssl/server.key". For all supported SSL configuration 43 | # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 44 | # 45 | # We also recommend setting `force_ssl` in your endpoint, ensuring 46 | # no data is ever sent via http, always redirecting to https: 47 | # 48 | # config :game, GameWeb.Endpoint, 49 | # force_ssl: [hsts: true] 50 | # 51 | # Check `Plug.SSL` for all available options in `force_ssl`. 52 | 53 | # Finally import the config/prod.secret.exs which loads secrets 54 | # and configuration from environment variables. 55 | import_config "prod.secret.exs" 56 | -------------------------------------------------------------------------------- /config/prod.secret.exs: -------------------------------------------------------------------------------- 1 | # In this file, we load production configuration and secrets 2 | # from environment variables. You can also hardcode secrets, 3 | # although such is generally not recommended and you have to 4 | # remember to add this file to your .gitignore. 5 | use Mix.Config 6 | 7 | secret_key_base = 8 | System.get_env("SECRET_KEY_BASE") || 9 | raise """ 10 | environment variable SECRET_KEY_BASE is missing. 11 | You can generate one by calling: mix phx.gen.secret 12 | """ 13 | 14 | config :game, GameWeb.Endpoint, 15 | http: [ 16 | port: String.to_integer(System.get_env("PORT") || "4000"), 17 | transport_options: [socket_opts: [:inet6]] 18 | ], 19 | secret_key_base: secret_key_base 20 | 21 | # ## Using releases (Elixir v1.9+) 22 | # 23 | # If you are doing OTP releases, you need to instruct Phoenix 24 | # to start each relevant endpoint: 25 | # 26 | # config :game, GameWeb.Endpoint, server: true 27 | # 28 | # Then you can assemble a release by calling `mix release`. 29 | # See `mix help release` for more information. 30 | -------------------------------------------------------------------------------- /config/test.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | 3 | # We don't run a server during test. If one is required, 4 | # you can enable the server option below. 5 | config :game, GameWeb.Endpoint, 6 | http: [port: 4002], 7 | server: false 8 | 9 | # Print only warnings and errors during test 10 | config :logger, level: :warn 11 | -------------------------------------------------------------------------------- /gleam.toml: -------------------------------------------------------------------------------- 1 | name = "game" 2 | -------------------------------------------------------------------------------- /lib/game.ex: -------------------------------------------------------------------------------- 1 | defmodule Game do 2 | @moduledoc """ 3 | Game keeps the contexts that define your domain 4 | and business logic. 5 | 6 | Contexts are also responsible for managing your data, regardless 7 | if it comes from the database, an external API or others. 8 | """ 9 | end 10 | -------------------------------------------------------------------------------- /lib/game/application.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Application do 2 | # See https://hexdocs.pm/elixir/Application.html 3 | # for more information on OTP Applications 4 | @moduledoc false 5 | 6 | use Application 7 | 8 | def start(_type, _args) do 9 | children = [ 10 | # Start the Telemetry supervisor 11 | GameWeb.Telemetry, 12 | # Start the PubSub system 13 | {Phoenix.PubSub, name: Game.PubSub}, 14 | # Start the Endpoint (http/https) 15 | GameWeb.Endpoint, 16 | {Registry, keys: :unique, name: Game.Registry}, 17 | Game.SessionSupervisor 18 | ] 19 | 20 | # See https://hexdocs.pm/elixir/Supervisor.html 21 | # for other strategies and supported options 22 | opts = [strategy: :one_for_one, name: Game.Supervisor] 23 | Supervisor.start_link(children, opts) 24 | end 25 | 26 | # Tell Phoenix to update the endpoint configuration 27 | # whenever the application is updated. 28 | def config_change(changed, _new, removed) do 29 | GameWeb.Endpoint.config_change(changed, removed) 30 | :ok 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/game/card.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Card do 2 | use Game.Strucord, name: :card, from: "gen/src/game_Card.hrl" 3 | end 4 | -------------------------------------------------------------------------------- /lib/game/engine.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Engine do 2 | use Game.Strucord, name: :engine, from: "gen/src/game_Engine.hrl" 3 | 4 | def new(playing_cards, random) when is_boolean(random) do 5 | record = :game.init(playing_cards, random) 6 | from_record_custom(record) 7 | end 8 | 9 | def flip(%__MODULE__{} = struct, flip_id) when is_binary(flip_id) do 10 | gleamify(struct, fn record -> 11 | :game.flip(record, flip_id) 12 | end) 13 | end 14 | 15 | def unflip(%__MODULE__{} = struct) do 16 | gleamify(struct, fn record -> 17 | :game.unflip(record) 18 | end) 19 | end 20 | 21 | def prepare_restart(%__MODULE__{} = struct) do 22 | gleamify(struct, fn record -> 23 | :game.prepare_restart(record) 24 | end) 25 | end 26 | 27 | def restart(%__MODULE__{playing_cards: playing_cards, random: random}) do 28 | __MODULE__.new(playing_cards, random) 29 | end 30 | 31 | def gleamify(%__MODULE__{} = struct, f) when is_function(f, 1) do 32 | struct 33 | |> to_record_custom() 34 | |> f.() 35 | |> from_record_custom() 36 | end 37 | 38 | def to_record_custom(%__MODULE__{ 39 | cards: cards, 40 | winner: winner, 41 | animating: animating, 42 | score: score, 43 | playing_cards: playing_cards, 44 | random: random 45 | }) do 46 | cards = Enum.map(cards, fn c -> Game.Card.to_record(c) end) 47 | 48 | {:engine, cards, winner, animating, score, playing_cards, random} 49 | end 50 | 51 | def from_record_custom({:engine, cards, winner, animating, score, playing_cards, random}) do 52 | cards = Enum.map(cards, fn c -> Game.Card.from_record(c) end) 53 | 54 | %__MODULE__{ 55 | cards: cards, 56 | winner: winner, 57 | animating: animating, 58 | score: score, 59 | playing_cards: playing_cards, 60 | random: random 61 | } 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/game/generator.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Generator do 2 | def haiku do 3 | [ 4 | Enum.random(foods()), 5 | :rand.uniform(9999) 6 | ] 7 | |> Enum.join("-") 8 | end 9 | 10 | def foods do 11 | ~w( 12 | apple banana orange 13 | grape kiwi mango 14 | pear pineapple strawberry 15 | tomato watermelon cantaloupe 16 | ) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/game/hash.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Hash do 2 | def hmac(key, value, length \\ 25) do 3 | :crypto.hmac(:sha256, key, value) 4 | |> Base.encode16() 5 | |> String.slice(0, length) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/game/process.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Process do 2 | def sleep(t) do 3 | Process.sleep(t * 100) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/game/random.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Random do 2 | def take_random(items, number) do 3 | Enum.take_random(items, number) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/game/registry.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Registry do 2 | def via(name) do 3 | {:via, Registry, {__MODULE__, name}} 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/game/session.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Session do 2 | use GenServer 3 | 4 | @timeout :timer.minutes(20) 5 | 6 | import Game.Process, only: [sleep: 1] 7 | 8 | def start_link(name, playing_cards, random) do 9 | GenServer.start_link(__MODULE__, {:ok, playing_cards, random}, name: via(name)) 10 | end 11 | 12 | defp via(name), do: Game.Registry.via(name) 13 | 14 | @impl GenServer 15 | def init({:ok, playing_cards, random}) do 16 | state = Game.Engine.new(playing_cards, random) 17 | 18 | {:ok, state, @timeout} 19 | end 20 | 21 | def session_pid(name) do 22 | name 23 | |> via() 24 | |> GenServer.whereis() 25 | end 26 | 27 | def game_state(name) do 28 | GenServer.call(via(name), {:game_state}) 29 | end 30 | 31 | def flip(name, flip_id) do 32 | GenServer.call(via(name), {:flip, flip_id}) 33 | end 34 | 35 | def unflip(name) do 36 | sleep(10) 37 | GenServer.call(via(name), {:unflip}) 38 | end 39 | 40 | def prepare_restart(name) do 41 | GenServer.call(via(name), {:prepare_restart}) 42 | end 43 | 44 | def restart(name) do 45 | sleep(1) 46 | GenServer.call(via(name), {:restart}) 47 | end 48 | 49 | @impl GenServer 50 | def handle_call({:game_state}, _from, state) do 51 | {:reply, state, state, @timeout} 52 | end 53 | 54 | @impl GenServer 55 | def handle_call({:flip, flip_id}, _from, state) do 56 | new_state = Game.Engine.flip(state, flip_id) 57 | {:reply, new_state, new_state, @timeout} 58 | end 59 | 60 | @impl GenServer 61 | def handle_call({:unflip}, _from, state) do 62 | new_state = Game.Engine.unflip(state) 63 | {:reply, new_state, new_state, @timeout} 64 | end 65 | 66 | @impl GenServer 67 | def handle_call({:prepare_restart}, _from, state) do 68 | new_state = Game.Engine.prepare_restart(state) 69 | {:reply, new_state, new_state, @timeout} 70 | end 71 | 72 | @impl GenServer 73 | def handle_call({:restart}, _from, state) do 74 | new_state = Game.Engine.restart(state) 75 | {:reply, new_state, new_state, @timeout} 76 | end 77 | 78 | @impl GenServer 79 | def handle_info(:timeout, session) do 80 | {:stop, {:shutdown, :timeout}, session} 81 | end 82 | 83 | @impl GenServer 84 | def terminate(_reason, _session) do 85 | :ok 86 | end 87 | 88 | def session_name do 89 | Registry.keys(Game.Registry, self()) |> List.first() 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /lib/game/session_supervisor.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.SessionSupervisor do 2 | use DynamicSupervisor 3 | 4 | @default_playing_cards ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] 5 | 6 | def start_link(_args) do 7 | DynamicSupervisor.start_link(__MODULE__, :ok, name: __MODULE__) 8 | end 9 | 10 | def init(:ok) do 11 | DynamicSupervisor.init(strategy: :one_for_one) 12 | end 13 | 14 | def start_game(name, playing_cards \\ @default_playing_cards, random \\ true) do 15 | child_spec = %{ 16 | id: Game.Session, 17 | start: {Game.Session, :start_link, [name, playing_cards, random]}, 18 | restart: :transient 19 | } 20 | 21 | DynamicSupervisor.start_child(__MODULE__, child_spec) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/game/strucord.ex: -------------------------------------------------------------------------------- 1 | defmodule Game.Strucord do 2 | require Record 3 | 4 | defmacro __using__(opts) do 5 | name = Keyword.fetch!(opts, :name) 6 | from = Keyword.fetch!(opts, :from) 7 | 8 | fields = Record.extract(name, from: from) 9 | struct_fields = Keyword.keys(fields) 10 | vars = Macro.generate_arguments(length(struct_fields), __MODULE__) 11 | kvs = Enum.zip(struct_fields, vars) 12 | 13 | quote do 14 | defstruct unquote(struct_fields) 15 | 16 | def from_record({unquote(name), unquote_splicing(vars)}) do 17 | %__MODULE__{unquote_splicing(kvs)} 18 | end 19 | 20 | def to_record(%__MODULE__{unquote_splicing(kvs)}) do 21 | {unquote(name), unquote_splicing(vars)} 22 | end 23 | 24 | def with_record(%__MODULE__{} = struct, f) when is_function(f, 1) do 25 | struct 26 | |> to_record() 27 | |> f.() 28 | |> from_record() 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/game_web.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb do 2 | @moduledoc """ 3 | The entrypoint for defining your web interface, such 4 | as controllers, views, channels and so on. 5 | 6 | This can be used in your application as: 7 | 8 | use GameWeb, :controller 9 | use GameWeb, :view 10 | 11 | The definitions below will be executed for every view, 12 | controller, etc, so keep them short and clean, focused 13 | on imports, uses and aliases. 14 | 15 | Do NOT define functions inside the quoted expressions 16 | below. Instead, define any helper function in modules 17 | and import those modules here. 18 | """ 19 | 20 | def controller do 21 | quote do 22 | use Phoenix.Controller, namespace: GameWeb 23 | 24 | import Plug.Conn 25 | import GameWeb.Gettext 26 | alias GameWeb.Router.Helpers, as: Routes 27 | end 28 | end 29 | 30 | def view do 31 | quote do 32 | use Phoenix.View, 33 | root: "lib/game_web/templates", 34 | namespace: GameWeb 35 | 36 | # Import convenience functions from controllers 37 | import Phoenix.Controller, 38 | only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1] 39 | 40 | # Include shared imports and aliases for views 41 | unquote(view_helpers()) 42 | end 43 | end 44 | 45 | def live_view do 46 | quote do 47 | use Phoenix.LiveView, 48 | layout: {GameWeb.LayoutView, "live.html"} 49 | 50 | unquote(view_helpers()) 51 | end 52 | end 53 | 54 | def live_component do 55 | quote do 56 | use Phoenix.LiveComponent 57 | 58 | unquote(view_helpers()) 59 | end 60 | end 61 | 62 | def router do 63 | quote do 64 | use Phoenix.Router 65 | 66 | import Plug.Conn 67 | import Phoenix.Controller 68 | import Phoenix.LiveView.Router 69 | end 70 | end 71 | 72 | def channel do 73 | quote do 74 | use Phoenix.Channel 75 | import GameWeb.Gettext 76 | end 77 | end 78 | 79 | defp view_helpers do 80 | quote do 81 | # Use all HTML functionality (forms, tags, etc) 82 | use Phoenix.HTML 83 | 84 | # Import LiveView helpers (live_render, live_component, live_patch, etc) 85 | import Phoenix.LiveView.Helpers 86 | 87 | # Import basic rendering functionality (render, render_layout, etc) 88 | import Phoenix.View 89 | 90 | import GameWeb.ErrorHelpers 91 | import GameWeb.Gettext 92 | alias GameWeb.Router.Helpers, as: Routes 93 | end 94 | end 95 | 96 | @doc """ 97 | When used, dispatch to the appropriate controller/view/etc. 98 | """ 99 | defmacro __using__(which) when is_atom(which) do 100 | apply(__MODULE__, which, []) 101 | end 102 | end 103 | -------------------------------------------------------------------------------- /lib/game_web/channels/user_socket.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb.UserSocket do 2 | use Phoenix.Socket 3 | 4 | ## Channels 5 | # channel "room:*", GameWeb.RoomChannel 6 | 7 | # Socket params are passed from the client and can 8 | # be used to verify and authenticate a user. After 9 | # verification, you can put default assigns into 10 | # the socket that will be set for all channels, ie 11 | # 12 | # {:ok, assign(socket, :user_id, verified_user_id)} 13 | # 14 | # To deny connection, return `:error`. 15 | # 16 | # See `Phoenix.Token` documentation for examples in 17 | # performing token verification on connect. 18 | @impl true 19 | def connect(_params, socket, _connect_info) do 20 | {:ok, socket} 21 | end 22 | 23 | # Socket id's are topics that allow you to identify all sockets for a given user: 24 | # 25 | # def id(socket), do: "user_socket:#{socket.assigns.user_id}" 26 | # 27 | # Would allow you to broadcast a "disconnect" event and terminate 28 | # all active sockets and channels for a given user: 29 | # 30 | # GameWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) 31 | # 32 | # Returning `nil` makes this socket anonymous. 33 | @impl true 34 | def id(_socket), do: nil 35 | end 36 | -------------------------------------------------------------------------------- /lib/game_web/controllers/page_controller.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb.PageController do 2 | use GameWeb, :controller 3 | 4 | def index(conn, _params) do 5 | render(conn, "index.html") 6 | end 7 | 8 | def new(conn, _params) do 9 | game_name = Game.Generator.haiku() 10 | 11 | case Game.SessionSupervisor.start_game(game_name) do 12 | {:ok, _pid} -> 13 | redirect(conn, to: Routes.page_path(conn, :play, game_name)) 14 | 15 | {:error, {:already_started, _pid}} -> 16 | redirect(conn, to: Routes.page_path(conn, :play, game_name)) 17 | 18 | {:error, _error} -> 19 | render(conn, "index.html") 20 | end 21 | end 22 | 23 | def play(conn, %{"id" => game_name}) do 24 | case Game.Session.session_pid(game_name) do 25 | pid when is_pid(pid) -> 26 | render_live_view(conn, game_name) 27 | 28 | nil -> 29 | redirect_user(conn) 30 | end 31 | end 32 | 33 | def redirect_user(conn) do 34 | conn 35 | |> put_flash(:error, "game not found") 36 | |> redirect(to: Routes.page_path(conn, :index)) 37 | end 38 | 39 | def render_live_view(conn, game_name) do 40 | Phoenix.LiveView.Controller.live_render(conn, GameWeb.PageLive, 41 | session: %{ 42 | "game_name" => game_name, 43 | "error" => nil 44 | } 45 | ) 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/game_web/endpoint.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb.Endpoint do 2 | use Phoenix.Endpoint, otp_app: :game 3 | 4 | # The session will be stored in the cookie and signed, 5 | # this means its contents can be read but not tampered with. 6 | # Set :encryption_salt if you would also like to encrypt it. 7 | @session_options [ 8 | store: :cookie, 9 | key: "_game_key", 10 | signing_salt: "+O0jM8gZ" 11 | ] 12 | 13 | socket "/socket", GameWeb.UserSocket, 14 | websocket: true, 15 | longpoll: false 16 | 17 | socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] 18 | 19 | # Serve at "/" the static files from "priv/static" directory. 20 | # 21 | # You should set gzip to true if you are running phx.digest 22 | # when deploying your static files in production. 23 | plug Plug.Static, 24 | at: "/", 25 | from: :game, 26 | gzip: false, 27 | only: ~w(css fonts images js favicon.ico robots.txt) 28 | 29 | # Code reloading can be explicitly enabled under the 30 | # :code_reloader configuration of your endpoint. 31 | if code_reloading? do 32 | socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket 33 | plug Phoenix.LiveReloader 34 | plug Phoenix.CodeReloader 35 | end 36 | 37 | plug Phoenix.LiveDashboard.RequestLogger, 38 | param_key: "request_logger", 39 | cookie_key: "request_logger" 40 | 41 | plug Plug.RequestId 42 | plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] 43 | 44 | plug Plug.Parsers, 45 | parsers: [:urlencoded, :multipart, :json], 46 | pass: ["*/*"], 47 | json_decoder: Phoenix.json_library() 48 | 49 | plug Plug.MethodOverride 50 | plug Plug.Head 51 | plug Plug.Session, @session_options 52 | plug GameWeb.Router 53 | end 54 | -------------------------------------------------------------------------------- /lib/game_web/gettext.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb.Gettext do 2 | @moduledoc """ 3 | A module providing Internationalization with a gettext-based API. 4 | 5 | By using [Gettext](https://hexdocs.pm/gettext), 6 | your module gains a set of macros for translations, for example: 7 | 8 | import GameWeb.Gettext 9 | 10 | # Simple translation 11 | gettext("Here is the string to translate") 12 | 13 | # Plural translation 14 | ngettext("Here is the string to translate", 15 | "Here are the strings to translate", 16 | 3) 17 | 18 | # Domain-based translation 19 | dgettext("errors", "Here is the error message to translate") 20 | 21 | See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. 22 | """ 23 | use Gettext, otp_app: :game 24 | end 25 | -------------------------------------------------------------------------------- /lib/game_web/live/page_live.ex: -------------------------------------------------------------------------------- 1 | defmodule GameWeb.PageLive do 2 | use GameWeb, :live_view 3 | 4 | @impl true 5 | def mount(_params, %{"game_name" => game_name}, socket) do 6 | state = Game.Session.game_state(game_name) 7 | 8 | {:ok, set_state(socket, state, %{game_name: game_name})} 9 | end 10 | 11 | @impl true 12 | def handle_event("flip", %{"flip-id" => flip_id}, socket) do 13 | %{:game_name => game_name} = socket.assigns 14 | 15 | case Game.Session.session_pid(game_name) do 16 | pid when is_pid(pid) -> 17 | state = Game.Session.flip(game_name, flip_id) 18 | %Game.Engine{animating: animating} = state 19 | 20 | if animating == true do 21 | send(self(), {:unflip, game_name}) 22 | end 23 | 24 | {:noreply, set_state(socket, state, socket.assigns)} 25 | 26 | nil -> 27 | {:noreply, set_error(socket)} 28 | end 29 | end 30 | 31 | @impl true 32 | def handle_event("prepare_restart", _value, socket) do 33 | %{:game_name => game_name} = socket.assigns 34 | 35 | case Game.Session.session_pid(game_name) do 36 | pid when is_pid(pid) -> 37 | state = Game.Session.prepare_restart(game_name) 38 | send(self(), {:restart, game_name}) 39 | {:noreply, set_state(socket, state, socket.assigns)} 40 | 41 | nil -> 42 | {:noreply, set_error(socket)} 43 | end 44 | end 45 | 46 | @impl true 47 | def handle_info({:unflip, game_name}, socket) do 48 | case Game.Session.session_pid(game_name) do 49 | pid when is_pid(pid) -> 50 | state = Game.Session.unflip(game_name) 51 | 52 | {:noreply, set_state(socket, state, socket.assigns)} 53 | 54 | nil -> 55 | {:noreply, set_error(socket)} 56 | end 57 | end 58 | 59 | @impl true 60 | def handle_info({:restart, game_name}, socket) do 61 | case Game.Session.session_pid(game_name) do 62 | pid when is_pid(pid) -> 63 | state = Game.Session.restart(game_name) 64 | 65 | {:noreply, set_state(socket, state, socket.assigns)} 66 | 67 | nil -> 68 | {:noreply, set_error(socket)} 69 | end 70 | end 71 | 72 | def rows(%{cards: cards}) do 73 | Enum.map(cards, &Map.from_struct(&1)) 74 | end 75 | 76 | def set_state(socket, state, %{game_name: game_name}) do 77 | %Game.Engine{cards: cards, winner: winner, score: score} = state 78 | 79 | assign(socket, 80 | game_name: game_name, 81 | cards: cards, 82 | winner: winner, 83 | score: score 84 | ) 85 | end 86 | 87 | def set_error(socket) do 88 | assign(socket, 89 | error: "an error occurred" 90 | ) 91 | end 92 | 93 | def clazz(%{flipped: flipped, paired: paired}) do 94 | case paired == true do 95 | true -> 96 | "found" 97 | 98 | false -> 99 | case flipped == true do 100 | true -> "flipped" 101 | false -> "" 102 | end 103 | end 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /lib/game_web/live/page_live.html.leex: -------------------------------------------------------------------------------- 1 |