|
1 | 1 | %% cascade '_base.tx' |
2 | 2 |
|
3 | | -%% override footer -> { |
4 | | - <!-- Syntax Hilighting Support --> |
5 | | - <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.2/build/highlight.min.js"></script> |
6 | | - <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.2/build/languages/perl.min.js"></script> |
7 | | - <script>hljs.highlightAll();</script> |
8 | | -%% } |
9 | | - |
10 | | -%% override header -> { |
11 | | - <!-- Syntax Hilighting Support --> |
12 | | - <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.2/build/styles/default.min.css"> |
13 | | - |
14 | | - |
15 | | - <style> |
16 | | - .inline-code { |
17 | | - font-family: monospace; |
18 | | - background-color: #eee; |
19 | | - } |
20 | | - |
21 | | - h2, h3, h4, h5, h6 { |
22 | | - padding-top: 1em; |
23 | | - padding-bottom: 0.5em; |
24 | | - font-weight: bold; |
25 | | - display: flex; |
26 | | - align-items: center; |
27 | | - } |
28 | | - h1 { font-size: 2em; } |
29 | | - h2 { font-size: 1.5em; } |
30 | | - h3 { font-size: 1.25em; } |
31 | | - h4 { font-size: 1em; } |
32 | | - h5 { font-size: 0.75em; } |
33 | | - h6 { font-size: 0.5em; } |
34 | | - |
35 | | - h1::after, h2::after, h3::after, h4::after, h5::after, h6::after { |
36 | | - content: ''; |
37 | | - flex: 1; |
38 | | - margin-left: 1rem; |
39 | | - height: 1px; |
40 | | - background-color: #000; |
41 | | - } |
42 | | - |
43 | | - p { |
44 | | - text-indent: 1.5em; |
45 | | - } |
46 | | - </style> |
47 | | -%% } |
48 | | - |
49 | | -%% override content -> { |
50 | | - <p style="margin-top: 1.5em">HouseNewsWire is meant to be a starting point for building your own webapp. It is a fully functional webapp that supports user registration, login. It has a simple dashboard with one to many message posting and per-user mark-as-read feature.</p> |
51 | | - |
52 | | -<p>The creation process is detailed <a href="https://modfoss.com/building-house-new-wire.html">in this blog post</a> so that one could follow that guide and arrive at having written the same application. The repository created in that documentation is available <a href="https://github.com/symkat/HouseNewsWire/">on GitHub @ symkat/HouseNewsWire</a>.</p> |
53 | | - |
54 | | -<p>You can try out the application at <a href="https://housenewswire.com/">House News Wire</a>.</p> |
55 | | - |
56 | | -<h2>Running With Docker</h2> |
57 | | - |
58 | | -<p>This docker-compose.yml file will start HouseNewsWire and it will be accessable at <a href="http://127.0.0.1:5000">http://127.0.0.1:5000</a>.</p> |
59 | | - |
60 | | -<pre><code class="yaml"> |
61 | | -version: '3' |
62 | | - |
63 | | -services: |
64 | | - website: |
65 | | - image: symkat/housenewswire:latest |
66 | | - container_name: hnw-web |
67 | | - ports: |
68 | | - - 5000:5000 |
69 | | - database: |
70 | | - image: postgres:11 |
71 | | - container_name: hnw-db |
72 | | - environment: |
73 | | - - POSTGRES_PASSWORD=housenewswire |
74 | | - - POSTGRES_USER=housenewswire |
75 | | - - POSTGRES_DB=housenewswire |
76 | | - volumes: |
77 | | - - ./schema.sql:/docker-entrypoint-initdb.d/000_schema.sql:ro |
78 | | - - database:/var/lib/postgresql/data |
79 | | - |
80 | | -volumes: |
81 | | - database: |
82 | | - |
83 | | -</code></pre> |
84 | | - |
85 | | -<p>Make sure to bring in the schema.sql file to the same directory as the <span class="inline-code">docker-compose.yaml</span> file.</p> |
86 | | - |
87 | | -<pre><code class="bash"> |
88 | | -curl -Lo schema.sql https://raw.githubusercontent.com/symkat/HouseNewsWire/master/Database/etc/schema.sql |
89 | | - |
90 | | -</code></pre> |
91 | | - |
92 | | -<p>Once these files exist, you should be able to start HouseNewsWire with <span class="inline-code">docker-compose</span>:</p> |
93 | | - |
94 | | -<pre><code class="bash"> |
95 | | -symkat@test:~/hnw$ ls |
96 | | -docker-compose.yml schema.sql |
97 | | -symkat@test:~/hnw$ docker-compose up |
98 | | -symkat@test:~/hnw$ docker-compose up |
99 | | -Starting hnw-db ... done |
100 | | -Starting hnw-web ... done |
101 | | -Attaching to hnw-db, hnw-web |
102 | | -hnw-db | |
103 | | -hnw-db | PostgreSQL Database directory appears to contain a database; Skipping initialization |
104 | | - |
105 | | -</code></pre> |
106 | | - |
107 | | -<h2>Forking and Development Environment</h2> |
108 | | - |
109 | | -<p>Before you begin you should have an environment that supports development. <a href="https://github.com/symkat/modfoss_devel">modFoss Devel</a> includes the configuration I use for Debian 10 machines, and installs dependencies that are needed by the build processes for this project.</p> |
110 | | - |
111 | | -<p>Once a development environment exists, you'll want to fork the repo.</p> |
112 | | - |
113 | | -<pre><code class="bash"> |
114 | | -symkat@test:~$ git clone git@github.com:symkat/HouseNewsWire.git |
115 | | -Cloning into 'HouseNewsWire'... |
116 | | -... |
117 | | -Resolving deltas: 100% (25/25), done. |
118 | | -symkat@test:~$ cd HouseNewsWire/ |
119 | | - |
120 | | -</code></pre> |
121 | | - |
122 | | -<p>Once forked, install the modules you'll use to control the development environment. This will take a couple of minutes, on a 2GiB Linode machine it took about 10 minutes.</p> |
123 | | - |
124 | | -<pre><code class="bash"> |
125 | | -symkat@test:~/HouseNewsWire$ cpanm App::plx App::opan Carton Dist::Zilla |
126 | | -... |
127 | | -Building and testing Dist-Zilla-6.017 ... OK |
128 | | -Successfully installed Dist-Zilla-6.017 |
129 | | -140 distributions installed |
130 | | - |
131 | | -</code></pre> |
132 | | - |
133 | | -<p>Once these modules are installed, you can build the <span class="inline-code">HouseNewsWire::DB</span> package.</p> |
134 | | - |
135 | | -<pre><code class="bash"> |
136 | | -symkat@test:~/HouseNewsWire/Database$ dzil build |
137 | | -[DZ] beginning to build HouseNewsWire-DB |
138 | | -[DZ] writing HouseNewsWire-DB in HouseNewsWire-DB-0.001 |
139 | | -[DZ] building archive with Archive::Tar; install Archive::Tar::Wrapper 0.15 or newer for improved speed |
140 | | -[DZ] writing archive to HouseNewsWire-DB-0.001.tar.gz |
141 | | -[DZ] built in HouseNewsWire-DB-0.001 |
142 | | -symkat@test:~/HouseNewsWire/Database$ |
143 | | - |
144 | | -</code></pre> |
145 | | - |
146 | | -<p>This package is now built, so you can set up the Web app itself to use it, and install of the dependencies for the webapp.</p> |
147 | | - |
148 | | -<pre><code class="bash"> |
149 | | -symkat@test:~/HouseNewsWire/Web$ plx --userinit |
150 | | -# plx --bareinit |
151 | | -Resolving perl 'perl' via PATH |
152 | | -# plx --config libspec add 25.perl5.ll perl5 |
153 | | -symkat@test:~/HouseNewsWire/Database$ cd ../Web/ |
154 | | -symkat@test:~/HouseNewsWire/Web$ plx --init |
155 | | -Resolving perl 'perl' via PATH |
156 | | -symkat@test:~/HouseNewsWire/Web$ plx --config libspec add 00tilde.ll $HOME/perl5 |
157 | | -symkat@test:~/HouseNewsWire/Web$ plx --config libspec add 40HNW-DB.ll $HOME/HouseNewsWire/Database/lib |
158 | | - |
159 | | -</code></pre> |
160 | | - |
161 | | -<p>What you have just done is, first set up <a href="https://metacpan.org/pod/App::plx">plx</a> for your user account. Then you configured <span class="inline-code">plx</span> in the <span class="inline-code">~/HouseNewsWire/Web</span> directory. When you use <span class="inline-code">plx</span>, it will include libraries from <span class="inline-code">~/perl5/</span>, <span class="inline-code">~/HouseNewsWire/Database/lib</span>. It will include, and more modules can be installed to the directories <span class="inline-code">~/HouseNewsWire/Web/devel</span> and <span class="inline-code">~/HouseNewsWire/Web/local</span>. The <span class="inline-code">devel/</span> directory is used for modules that help you develop, while the <span class="inline-code">local/</span> directory is for modules that the application is using.</p> |
162 | | - |
163 | | -<p>Now it's time to install all of the dependancies. The first three commands use <a href="https://metacpan.org/pod/App::opan">opan</a> to set up <span class="inline-code">HouseNewsWire::DB</span> as a module that can be included in automatic installation with carton and other tools that interact with cpan. The last <span class="inline-code">plx</span> command installs all of the packages that HouseNewsWire::Web depends on and takes about 10 minutes to run on a 2GiB machine. Finally, you'll want to install <a href="https://github.com/symkat/App-Dex">dex</a> to use the commands defined in the directory.</p> |
164 | | - |
165 | | -<pre><code class="bash"> |
166 | | -symkat@test:~/HouseNewsWire/Web$ plx opan init |
167 | | -symkat@test:~/HouseNewsWire/Web$ plx opan add ../Database/HouseNewsWire-DB-0.001.tar.gz |
168 | | -symkat@test:~/HouseNewsWire/Web$ plx opan merge |
169 | | -symkat@test:~/HouseNewsWire/Web$ plx opan carton install |
170 | | -Web application available at http://localhost:44211/ |
171 | | -Installing modules using /home/symkat/HouseNewsWire/Web/cpanfile |
172 | | -Successfully installed Module-Build-0.4231 |
173 | | -Successfully installed Module-Runtime-0.016 |
174 | | -... |
175 | | -symkat@test:~/HouseNewsWire/Web$ curl --create-dirs -Lo ~/bin/dex https://raw.githubusercontent.com/symkat/App-Dex/master/scripts/dex |
176 | | - % Total % Received % Xferd Average Speed Time Time Time Current |
177 | | - Dload Upload Total Spent Left Speed |
178 | | -100 635k 100 635k 0 0 8471k 0 --:--:-- --:--:-- --:--:-- 8471k |
179 | | -symkat@test:~/HouseNewsWire/Web$ chmod u+x ~/bin/dex |
180 | | -symkat@test:~/HouseNewsWire/Web$ . ~/.profile |
181 | | - |
182 | | -</code></pre> |
183 | | - |
184 | | -<p>Now it's time to run it all. You'll want to bring up two more terminals. One to run the database from and one to run the webapp from.</p> |
185 | | - |
186 | | -<pre><code class="bash"> |
187 | | -symkat@test:~$ cd HouseNewsWire/ |
188 | | -symkat@test:~/HouseNewsWire$ dex |
189 | | -db : Control Devel DB Only |
190 | | - start : Start devel db on localhost via docker. |
191 | | - stop : Stop devel db on localhost via docker. |
192 | | - status : Show status of devel db. |
193 | | - reset : Wipe devel db data. |
194 | | -docker : Run Docker Container Environment (Web + DB) |
195 | | - start : Start Docker Container Environment |
196 | | - stop : Stop Docker Container Environment |
197 | | - status : Show status of Docker Container Environment |
198 | | - reset : Wipe data from Docker Container Environment |
199 | | -build : Build HouseNewsWire container |
200 | | -symkat@test:~/HouseNewsWire$ dex db start |
201 | | -Creating network "database_default" with the default driver |
202 | | -Creating volume "database_database" with default driver |
203 | | -Pulling database (postgres:11)... |
204 | | -11: Pulling from library/postgres |
205 | | -62deabe7a6db: Pull complete |
206 | | -... |
207 | | -housenewswire-database | 2021-04-30 17:21:20.647 UTC [1] LOG: database system is ready to accept connections |
208 | | - |
209 | | -</code></pre> |
210 | | - |
211 | | -<p>The database is now running in that terminal. In another terminal you'll want to run the webapp itself.</p> |
212 | | - |
213 | | -<pre><code class="bash"> |
214 | | -symkat@test:~/HouseNewsWire/Web$ plx starman |
215 | | -2021/04/30-17:22:11 Starman::Server (type Net::Server::PreFork) starting! pid(4088) |
216 | | -Resolved [*]:5000 to [0.0.0.0]:5000, IPv4 |
217 | | -Binding to TCP port 5000 on host 0.0.0.0 with IPv4 |
218 | | -... |
219 | | -[info] HouseNewsWire::Web powered by Catalyst 5.90128 |
220 | | - |
221 | | -</code></pre> |
222 | | - |
223 | | -<p>Now you should be able to go to your <a href="http://Your-IP:5000/register">http://Your-IP:5000/register</a> to create an account and have it saved in the database. You can now work on the code directly and restart it to have changes appear in your web browser.</p> |
224 | | - |
225 | | - |
| 3 | +%% around content -> { |
| 4 | + <nav aria-label="breadcrumb"> |
| 5 | + <ol class="breadcrumb"> |
| 6 | + <li class="breadcrumb-item active"><a href="[% $c.uri_for_action( '/index' ) %]">Home</a></li> |
| 7 | + </ol> |
| 8 | + </nav> |
| 9 | + |
| 10 | + %% for $messages -> $message { |
| 11 | + <div class="card my-4"> |
| 12 | + <div class="card-body"> |
| 13 | + %% if ( $message.message.url ) { |
| 14 | + <h5 class="card-title"> |
| 15 | + <span style="font-size: 0.8em"><a href="[% $c.uri_for_action( '/topicchannel/get_topic', $message.channel.name ) %]">t/[% $message.channel.name %]</a>: </span> |
| 16 | + <a href="[% $message.message.url %]">[% $message.message.title %]</a> |
| 17 | + <span class="text-mute" style="font-size: 0.6em">([% $message.message.url | domain %])</span> |
| 18 | + </h5> |
| 19 | + %% } else { |
| 20 | + <h5 class="card-title"> |
| 21 | + <span style="font-size: 0.8em"><a href="[% $c.uri_for_action( '/topicchannel/get_topic', $message.channel.name ) %]">t/[% $message.channel.name %]</a>: </span> |
| 22 | + <a href="[% $c.uri_for_action( '/topicchannel/get_topic_message', $message.channel.name, $message.message.id, $message.message.slug ) %]">[% $message.message.title %]</a> |
| 23 | + <span class="text-mute" style="font-size: 0.6em">(text post)</span> |
| 24 | + </h5> |
| 25 | + %% } |
| 26 | + <br /> |
| 27 | + <a href="[% $c.uri_for_action( '/topicchannel/get_topic_message', [ ], $message.channel.name, $message.message.id, $message.message.slug ) %]" class="card-link">Comments ([% $message.message.comment_count %])</a> |
| 28 | + <a class="card-link" href="[% $c.uri_for_action( '/userchannel/get_user', [ $message.author.name ] ) %]">u/[% $message.author.name %]</a> |
| 29 | + <small><span title="[% $message.message.created_at.strftime('%Y %T') %]">[% $message.message.time_ago %]</span></small> |
226 | 30 | </div> |
| 31 | + </div> |
| 32 | + %% } |
227 | 33 | %% } |
228 | | - |
229 | | - |
230 | | - |
231 | | - |
232 | | - |
0 commit comments