Skip to content

Commit 6a3b23f

Browse files
author
Nathan Shafer
committed
Initial checkin
0 parents  commit 6a3b23f

22 files changed

+871
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/_build
2+
/cover
3+
/deps
4+
erl_crash.dump
5+
*.ez

LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# MIT License
2+
3+
Copyright (c) 2015 Nathan Shafer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Plug.Assign
2+
3+
A simple plug to allow setting variables in a connection.
4+
5+
## Installation
6+
7+
The package can be installed from Hex:
8+
9+
1. Add plug_assign to your list of dependencies in `mix.exs`:
10+
11+
def deps do
12+
[{:plug_assign, "~> 1.0.0"}]
13+
end
14+
15+
2. Fetch and install the dependencies
16+
17+
$ mix deps.get
18+
19+
2. Define assigns as part of your plug stack
20+
21+
plug Plug.Assign, foo: "bar", bar: true, baz: 42
22+
23+
Or Set variables for templates to use in a Phoenix Pipeline
24+
25+
pipeline :admin do
26+
plug Plug.Assign, admin: true
27+
end
28+
29+
Or directly in a Phoenix Controller
30+
31+
defmodule Blog.Admin.PostController do
32+
use Blog.Web, :Controller
33+
34+
plug Plug.Assign, subsection: :posts
35+
plug Plug.Assign, %{read_request: true} when action in [:index, :show]
36+
...
37+
end

config/config.exs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is responsible for configuring your application
2+
# and its dependencies with the aid of the Mix.Config module.
3+
use Mix.Config
4+
5+
# This configuration is loaded before any dependency and is restricted
6+
# to this project. If another project depends on this project, this
7+
# file won't be loaded nor affect the parent project. For this reason,
8+
# if you want to provide default values for your application for
9+
# 3rd-party users, it should be done in your "mix.exs" file.
10+
11+
# You can configure for your application as:
12+
#
13+
# config :plug_assign, key: :value
14+
#
15+
# And access this configuration in your application as:
16+
#
17+
# Application.get_env(:plug_assign, :key)
18+
#
19+
# Or configure a 3rd-party app:
20+
#
21+
# config :logger, level: :info
22+
#
23+
24+
# It is also possible to import configuration files, relative to this
25+
# directory. For example, you can emulate configuration per environment
26+
# by uncommenting the line below and defining dev.exs, test.exs and such.
27+
# Configuration from the imported file will override the ones defined
28+
# here (which is why it is important to import them last).
29+
#
30+
# import_config "#{Mix.env}.exs"

doc/404.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="x-ua-compatible" content="ie=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>404 – plug_assign v1.0.0</title>
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<meta name="generator" content="ExDoc v0.10.0">
10+
<link rel="stylesheet" href="dist/app.css" />
11+
<script src="dist/sidebar_items.js"></script>
12+
</head>
13+
<body data-type="extras">
14+
15+
<div class="main">
16+
<button class="sidebar-toggle">
17+
<i class="icon-menu"></i>
18+
</button>
19+
<section class="sidebar">
20+
<button class="sidebar-toggle">
21+
<i class="icon-menu"></i>
22+
</button>
23+
24+
25+
<a href="Plug.Assign.html" class="sidebar-projectLink">
26+
<div class="sidebar-projectDetails">
27+
<h1 class="sidebar-projectName">
28+
plug_assign
29+
</h1>
30+
<h2 class="sidebar-projectVersion">
31+
v1.0.0
32+
</h2>
33+
</div>
34+
35+
</a>
36+
37+
<div class="sidebar-search">
38+
<i class="icon-search"></i>
39+
<input type="text" class="sidebar-searchInput" placeholder="search" autocomplete="off" />
40+
</div>
41+
42+
<ul class="sidebar-listNav">
43+
<li><a id="extras-list" href="#full-list">Pages</a></li>
44+
45+
46+
<li><a id="modules-list" href="#full-list">Modules</a></li>
47+
48+
49+
50+
51+
52+
</ul>
53+
54+
<ul id="full-list" class="sidebar-fullList"></ul>
55+
<div class="sidebar-noResults"></div>
56+
</section>
57+
58+
<section class="content">
59+
<div id="content" class="content-inner">
60+
61+
62+
<h2>Page not found</h2>
63+
64+
<p>Sorry, but the page you were trying to get to, does not exist. You
65+
may want to try searching this site using the sidebar or using our
66+
<a href="extra-api-reference.html" title="API Reference">API Reference</a> page to find what
67+
you were looking for.</p>
68+
69+
<footer class="footer">
70+
<p>
71+
<span class="line">
72+
Built using
73+
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.10.0),
74+
</span>
75+
<span class="line">
76+
designed by
77+
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
78+
</span>
79+
</p>
80+
</footer>
81+
</div>
82+
</section>
83+
</div>
84+
<script src="dist/app.js"></script>
85+
</body>
86+
</html>
87+

doc/Plug.Assign.html

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="x-ua-compatible" content="ie=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Plug.Assign – plug_assign v1.0.0</title>
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<meta name="generator" content="ExDoc v0.10.0">
10+
<link rel="stylesheet" href="dist/app.css" />
11+
<script src="dist/sidebar_items.js"></script>
12+
</head>
13+
<body data-type="modules">
14+
15+
<div class="main">
16+
<button class="sidebar-toggle">
17+
<i class="icon-menu"></i>
18+
</button>
19+
<section class="sidebar">
20+
<button class="sidebar-toggle">
21+
<i class="icon-menu"></i>
22+
</button>
23+
24+
25+
<a href="Plug.Assign.html" class="sidebar-projectLink">
26+
<div class="sidebar-projectDetails">
27+
<h1 class="sidebar-projectName">
28+
plug_assign
29+
</h1>
30+
<h2 class="sidebar-projectVersion">
31+
v1.0.0
32+
</h2>
33+
</div>
34+
35+
</a>
36+
37+
<div class="sidebar-search">
38+
<i class="icon-search"></i>
39+
<input type="text" class="sidebar-searchInput" placeholder="search" autocomplete="off" />
40+
</div>
41+
42+
<ul class="sidebar-listNav">
43+
<li><a id="extras-list" href="#full-list">Pages</a></li>
44+
45+
46+
<li><a id="modules-list" href="#full-list">Modules</a></li>
47+
48+
49+
50+
51+
52+
</ul>
53+
54+
<ul id="full-list" class="sidebar-fullList"></ul>
55+
<div class="sidebar-noResults"></div>
56+
</section>
57+
58+
<section class="content">
59+
<div id="content" class="content-inner">
60+
61+
62+
<h1>
63+
Plug.Assign
64+
65+
66+
<a href="http://github.com/nshafer/plug_assign" title="View Source" class="view-source" rel="help">
67+
<i class="icon-code"></i>
68+
</a>
69+
70+
</h1>
71+
72+
73+
<section id="moduledoc" class="docstring">
74+
<p>Provides a Plug for adding assignments to the current connection.</p>
75+
<h2>Example</h2>
76+
<pre><code class="elixir">plug Plug.Assign, foo: &quot;bar&quot;, bar: true, baz: 42</code></pre>
77+
<h2>Example of use in a Phoenix Pipeline</h2>
78+
<pre><code class="elixir">pipeline :admin do
79+
plug Plug.Assign, admin: true
80+
end</code></pre>
81+
<h2>Example of use in a Phoenix Controller</h2>
82+
<pre><code class="elixir">defmodule Blog.Admin.PostController do
83+
use Blog.Web, :Controller
84+
85+
plug Plug.Assign, subsection: :posts
86+
plug Plug.Assign, %{read_request: true} when action in [:index, :show]
87+
...
88+
end</code></pre>
89+
90+
</section>
91+
92+
93+
94+
<section id="summary" class="details-list">
95+
<h1 class="section-heading">
96+
<a class="hover-link" href="#summary">
97+
<i class="icon-link"></i>
98+
</a>
99+
Summary
100+
</h1>
101+
102+
103+
104+
<div class="summary-functions summary">
105+
<h2>
106+
<a href="#functions">Functions</a>
107+
</h2>
108+
<div class="summary-row">
109+
<div class="summary-signature">
110+
<a href="#call/2">call(conn, assigns)</a>
111+
</div>
112+
113+
<div class="summary-synopsis"><p>Callback implementation for <code class="inline">c:Plug.call/2</code></p>
114+
</div>
115+
116+
</div>
117+
<div class="summary-row">
118+
<div class="summary-signature">
119+
<a href="#init/1">init(assigns)</a>
120+
</div>
121+
122+
<div class="summary-synopsis"><p>Callback implementation for <code class="inline">c:Plug.init/1</code></p>
123+
</div>
124+
125+
</div>
126+
127+
</div>
128+
129+
130+
131+
132+
133+
134+
</section>
135+
136+
137+
138+
139+
140+
<section id="functions" class="details-list">
141+
<h1 class="section-heading">
142+
<a class="hover-link" href="#functions">
143+
<i class="icon-link"></i>
144+
</a>
145+
Functions
146+
</h1>
147+
<div class="detail" id="call/2">
148+
<div class="detail-header">
149+
<a href="#call/2" class="detail-link" title="Link to this function">
150+
<i class="icon-link"></i>
151+
</a>
152+
<span class="signature">call(conn, assigns)</span>
153+
154+
<a href="http://github.com/nshafer/plug_assign" class="view-source" rel="help" title="View Source">
155+
<i class="icon-code"></i>
156+
</a>
157+
158+
</div>
159+
160+
<section class="docstring">
161+
<p>Callback implementation for <code class="inline">c:Plug.call/2</code>.</p>
162+
163+
</section>
164+
</div>
165+
<div class="detail" id="init/1">
166+
<div class="detail-header">
167+
<a href="#init/1" class="detail-link" title="Link to this function">
168+
<i class="icon-link"></i>
169+
</a>
170+
<span class="signature">init(assigns)</span>
171+
172+
<a href="http://github.com/nshafer/plug_assign" class="view-source" rel="help" title="View Source">
173+
<i class="icon-code"></i>
174+
</a>
175+
176+
</div>
177+
178+
<section class="docstring">
179+
<p>Callback implementation for <code class="inline">c:Plug.init/1</code>.</p>
180+
181+
</section>
182+
</div>
183+
184+
</section>
185+
186+
187+
188+
189+
190+
<footer class="footer">
191+
<p>
192+
<span class="line">
193+
Built using
194+
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.10.0),
195+
</span>
196+
<span class="line">
197+
designed by
198+
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
199+
</span>
200+
</p>
201+
</footer>
202+
</div>
203+
</section>
204+
</div>
205+
<script src="dist/app.js"></script>
206+
</body>
207+
</html>
208+

0 commit comments

Comments
 (0)