Current section

14 Versions

Jump to

Compare versions

19 files changed
+1080 additions
-1579 deletions
  @@ -2,6 +2,12 @@
2 2
3 3 ## Unreleased
4 4
5 + ## v0.8.0
6 +
7 + - remove the support of debug annotation for HEEx templates.
8 + - remove verified routes, and un-deprecate router helpers.
9 + - remove trailing_slash support of router helpers.
10 +
5 11 ## v0.7.0
6 12
7 13 No substantial changes, just restructured the project.
  @@ -1,9 +1,9 @@
1 1 {<<"links">>,
2 2 [{<<"Source">>,<<"https://github.com/combo-lab/combo">>},
3 3 {<<"Changelog">>,
4 - <<"https://github.com/combo-lab/combo/blob/v0.7.0/CHANGELOG.md">>}]}.
4 + <<"https://github.com/combo-lab/combo/blob/v0.8.0/CHANGELOG.md">>}]}.
5 5 {<<"name">>,<<"combo">>}.
6 - {<<"version">>,<<"0.7.0">>}.
6 + {<<"version">>,<<"0.8.0">>}.
7 7 {<<"description">>,
8 8 <<"A web framework, that combines the good parts of modern web development.">>}.
9 9 {<<"elixir">>,<<"~> 1.18">>}.
  @@ -17,9 +17,8 @@
17 17 <<"lib/mix/tasks/combo_static_digest.ex">>,<<"lib/combo.ex">>,
18 18 <<"lib/combo">>,<<"lib/combo/proxy.ex">>,<<"lib/combo/filtered_params.ex">>,
19 19 <<"lib/combo/naming.ex">>,<<"lib/combo/html.ex">>,
20 - <<"lib/combo/channel.ex">>,<<"lib/combo/verified_routes.ex">>,
21 - <<"lib/combo/safe_html.ex">>,<<"lib/combo/code_reloader">>,
22 - <<"lib/combo/code_reloader/proxy.ex">>,
20 + <<"lib/combo/channel.ex">>,<<"lib/combo/safe_html.ex">>,
21 + <<"lib/combo/code_reloader">>,<<"lib/combo/code_reloader/proxy.ex">>,
23 22 <<"lib/combo/code_reloader/mix_listener.ex">>,
24 23 <<"lib/combo/code_reloader/server.ex">>,<<"lib/combo/live_reloader.ex">>,
25 24 <<"lib/combo/proxy">>,<<"lib/combo/proxy/dispatcher.ex">>,
  @@ -47,7 +46,6 @@
47 46 <<"lib/combo/template/ceex_engine/compiler/assigns.ex">>,
48 47 <<"lib/combo/template/ceex_engine/compiler/attr.ex">>,
49 48 <<"lib/combo/template/ceex_engine/compiler/io_builder.ex">>,
50 - <<"lib/combo/template/ceex_engine/compiler/debug_annotation.ex">>,
51 49 <<"lib/combo/template/ceex_engine/compiler/engine.ex">>,
52 50 <<"lib/combo/template/html_encoder.ex">>,
53 51 <<"lib/combo/template/ceex_engine.ex">>,
  @@ -59,10 +57,11 @@
59 57 <<"lib/combo/html/form_field.ex">>,<<"lib/combo/html/formatter.ex">>,
60 58 <<"lib/combo/html/components.ex">>,<<"lib/combo/html/form_data.ex">>,
61 59 <<"lib/combo/html/form.ex">>,<<"lib/combo/controller.ex">>,
62 - <<"lib/combo/controller">>,<<"lib/combo/controller/pipeline.ex">>,
63 - <<"lib/combo/code_reloader.ex">>,<<"lib/combo/router.ex">>,
64 - <<"lib/combo/channel">>,<<"lib/combo/channel/server.ex">>,
65 - <<"lib/combo/conn.ex">>,<<"lib/combo/socket.ex">>,<<"lib/combo/static">>,
60 + <<"lib/combo/url_builder.ex">>,<<"lib/combo/controller">>,
61 + <<"lib/combo/controller/pipeline.ex">>,<<"lib/combo/code_reloader.ex">>,
62 + <<"lib/combo/router.ex">>,<<"lib/combo/channel">>,
63 + <<"lib/combo/channel/server.ex">>,<<"lib/combo/conn.ex">>,
64 + <<"lib/combo/socket.ex">>,<<"lib/combo/static">>,
66 65 <<"lib/combo/static/cache.ex">>,<<"lib/combo/static/compressor">>,
67 66 <<"lib/combo/static/compressor/gzip.ex">>,
68 67 <<"lib/combo/static/compressor.ex">>,<<"lib/combo/static/digester.ex">>,
  @@ -89,7 +88,8 @@
89 88 <<"lib/combo/flash.ex">>,<<"lib/combo/template.ex">>,<<"lib/combo/router">>,
90 89 <<"lib/combo/router/route.ex">>,<<"lib/combo/router/console_formatter.ex">>,
91 90 <<"lib/combo/router/resource.ex">>,<<"lib/combo/router/scope.ex">>,
92 - <<"priv">>,<<"priv/logo">>,<<"priv/logo/combo.svg">>,<<"priv/static">>,
91 + <<"lib/combo/router/helpers.ex">>,<<"priv">>,<<"priv/logo">>,
92 + <<"priv/logo/combo.svg">>,<<"priv/static">>,
93 93 <<"priv/static/live_reloader.min.js.map">>,
94 94 <<"priv/static/live_reloader.min.js">>,<<"mix.exs">>,<<".formatter.exs">>,
95 95 <<"README.md">>,<<"CHANGELOG.md">>,<<"LICENSE">>,
  @@ -1365,8 +1365,6 @@ defmodule Combo.Conn do
1365 1365 put_router_url(conn, user.account_name <> ".example.com")
1366 1366 end
1367 1367
1368 - > Following docs should be fixed.
1369 -
1370 1368 Now when you call `Routes.some_route_url(conn, ...)`, it will use the router
1371 1369 url set above. Keep in mind that, if you want to generate routes to the
1372 1370 current domain, it is preferred to use `Routes.some_route_path` helpers,
  @@ -1383,8 +1381,6 @@ defmodule Combo.Conn do
1383 1381 @doc """
1384 1382 Sets the URL string or `%URI{}` to be used for the URL generation of statics.
1385 1383
1386 - > Following docs should be fixed.
1387 -
1388 1384 Using this function on a `%Plug.Conn{}` struct tells `static_url/2` to use
1389 1385 the given information for URL generation instead of the `%Plug.Conn{}`'s
1390 1386 endpoint configuration (much like `put_router_url/2` but for static URLs).
  @@ -1468,7 +1464,7 @@ defmodule Combo.Conn do
1468 1464
1469 1465 """
1470 1466 def current_url(%Plug.Conn{} = conn) do
1471 - Combo.VerifiedRoutes.unverified_url(conn, current_path(conn))
1467 + Combo.URLBuilder.url(conn, current_path(conn))
1472 1468 end
1473 1469
1474 1470 @doc ~S"""
  @@ -1503,15 +1499,15 @@ defmodule Combo.Conn do
1503 1499 For example, to get the current URL always in HTTPS format:
1504 1500
1505 1501 def current_secure_url(conn, params \\ %{}) do
1506 - current_uri = MyAppWeb.Endpoint.url_struct()
1507 - current_path = Combo.Controller.current_path(conn, params)
1508 - Combo.VerifiedRoutes.unverified_url(%URI{current_uri | scheme: "https"}, current_path)
1502 + current_uri = URI.new!(Combo.URLBuilder.url(conn, params))
1503 + current_secure_uri = %URI{current_uri | scheme: "https"}
1504 + URI.to_string(current_secure_uri)
1509 1505 end
1510 1506
1511 1507 If you want all generated URLs to always have a certain schema, host, etc,
1512 1508 you may use `put_router_url/2`.
1513 1509 """
1514 1510 def current_url(%Plug.Conn{} = conn, %{} = params) do
1515 - Combo.VerifiedRoutes.unverified_url(conn, current_path(conn, params))
1511 + Combo.URLBuilder.url(conn, current_path(conn, params))
1516 1512 end
1517 1513 end
  @@ -731,45 +731,6 @@ defmodule Combo.HTML do
731 731 <p>Howdy from the named slot!</p>
732 732 ```
733 733
734 - ## Debug annotations
735 -
736 - CEEx support adding debug annotations to the rendered templates.
737 -
738 - Debug annotations are special HTML comments that help to identify which
739 - component is used for rendering content of rendered templates.
740 -
741 - For example, imagine the following template:
742 -
743 - ```ceex
744 - <.header>
745 - <.button>Save</.button>
746 - </.header>
747 - ```
748 -
749 - By enabling debug annotations, the rendered templates would receive the
750 - comments like this:
751 -
752 - ```html
753 - <!-- @caller lib/demo_web/home_live.ex:20 -->
754 - <!-- <DemoWeb.Components.header> lib/demo_web/components.ex:123 -->
755 - <header class="p-5">
756 - <!-- @caller lib/demo_web/home_live.ex:48 -->
757 - <!-- <DemoWeb.Components.button> lib/demo_web/components.ex:456 -->
758 - <button class="px-2 bg-indigo-500 text-white">Save</button>
759 - <!-- </DemoWeb.Components.button> -->
760 - </header>
761 - <!-- </DemoWeb.Components.header> -->
762 - ```
763 -
764 - To enable debug annotations, put following configuration into
765 - `config/dev.exs` file:
766 -
767 - ```elixir
768 - config :combo, :template, debug_annotations: true
769 - ```
770 -
771 - Note that changing this configuration will require `mix clean` and a full recompile.
772 -
773 734 ## Code formatting
774 735
775 736 You can automatically format CEEx template files (using .ceex extension) and
  @@ -79,6 +79,21 @@ defmodule Combo.Presence do
79 79
80 80 See `c:list/1` for more information on the presence data structure.
81 81
82 + ## Custom dispatcher
83 +
84 + It's possible to customize the dispatcher module used to broadcast.
85 + By default, `Combo.Channel.Server` is used, which is the same dispatcher
86 + used by channels. To customize the dispatcher, pass the `:dispatcher` option
87 + when using `Combo.Presence`:
88 +
89 + use Combo.Presence,
90 + otp_app: :my_app,
91 + pubsub_server: MyApp.PubSub,
92 + dispatcher: MyApp.CustomDispatcher
93 +
94 + See `m:Combo.PubSub#module-custom-dispatching` for more information on
95 + custom dispatchers.
96 +
82 97 ## Fetching Presence Information
83 98
84 99 Presence metadata should be minimized and used to store small,
  @@ -417,9 +432,11 @@ defmodule Combo.Presence do
417 432 pubsub_server =
418 433 opts[:pubsub_server] || raise "use Combo.Presence expects :pubsub_server to be given"
419 434
435 + dispatcher = opts[:dispatcher] || Combo.Channel.Server
436 +
420 437 Combo.Tracker.start_link(
421 438 __MODULE__,
422 - {module, task_supervisor, pubsub_server},
439 + {module, task_supervisor, pubsub_server, dispatcher},
423 440 opts
424 441 )
425 442 end
  @@ -455,7 +472,7 @@ defmodule Combo.Presence do
455 472 end
456 473
457 474 @doc false
458 - def init({module, task_supervisor, pubsub_server}) do
475 + def init({module, task_supervisor, pubsub_server, dispatcher}) do
459 476 state = %{
460 477 module: module,
461 478 task_supervisor: task_supervisor,
  @@ -463,7 +480,8 @@ defmodule Combo.Presence do
463 480 topics: %{},
464 481 tasks: :queue.new(),
465 482 current_task: nil,
466 - client_state: nil
483 + client_state: nil,
484 + dispatcher: dispatcher
467 485 }
468 486
469 487 client_state =
  @@ -507,12 +525,13 @@ defmodule Combo.Presence do
507 525 Task.shutdown(task)
508 526
509 527 Enum.each(computed_diffs, fn {topic, presence_diff} ->
510 - Combo.Channel.Server.local_broadcast(
511 - state.pubsub_server,
512 - topic,
513 - "presence_diff",
514 - presence_diff
515 - )
528 + broadcast = %Combo.Socket.Broadcast{
529 + topic: topic,
530 + event: "presence_diff",
531 + payload: presence_diff
532 + }
533 +
534 + Combo.PubSub.local_broadcast(state.pubsub_server, topic, broadcast, state.dispatcher)
516 535 end)
517 536
518 537 new_state =
Loading more files…