数字商品店和博客使用Elixir(Phoenix框架)创建

网友投稿 758 2022-10-30

数字商品店和博客使用Elixir(Phoenix框架)创建

数字商品店和博客使用Elixir(Phoenix框架)创建

Authentic Pixels

Digital goods shop & blog created using Phoenix Framework (Elixir)

This is the source code for my new website - Authentic Pixels. Through Authentic Pixels, I plan to deliver high quality free & premium web resources including Bootstrap HTML templates, startup landing pages, UI kits, mockups & themes for Ghost & Wordpress.

Demo & Screenshots

View the live website here - Authentic Pixels

Here are some screenshots of the admin area.

This project has been a great learning experience for me. Coming from Ruby on Rails, there are a lot of things that are done differently in Elixir/Phoenix and building this app has helped me understand the "Elixir way" of doing things.

Some of the things that this project helped me wrap my head around are -

Nested records & associations (e.g: Product has many variants)Handling many-to-many associations and validating themUploading imagesTestingSwitching to Webpack from BrunchCreating Sitemaps and running a cron task to regularly run the sitemap generation taskDeploying (to a Digital Ocean box using Dokku)Sending HTML emails.Separating admin area from frontend using differnt layouts and scopes in router.ex

I will be writing about this is a lot more detail on my blog soon.

Installation

Clone the repository and install the dependencies

git clone git@github.com:authentic-pixels/exshop.gitcd exshopmix deps.getnpm install

Create the database and run the migrations

mix ecto.createmix ecto.migrate

Create an admin user. You can change the email and password in priv/repo/seeds.exs file.

mix run priv/repo/seeds.exs

Add your Cloudinary keys. Create a file called dev.secret.exs inside config folder with the following contents. Be sure to change the 'name', 'api_key' and 'api_secret' fields.

use Mix.Configconfig :cloudini, api_key: "CHANGE_ME", api_secret: "CHANGE_ME", name: "CHANGE_ME", stub_requests: false, http_options: [timeout: 15000]

Start the server

iex -S mix phoenix.server

Now visit http://localhost:4000/ to see the frontend version. To access the admin area, visit http://localhost:4000/admin. You can login with the email and password set in priv/repo/seeds.exs.

Running tests

Set up your test database

MIX_ENV=test mix ecto.reset

Run all the tests on file change

mix test.watch

Todo

Create sitemaps Cron task to update sitemaps frequently Add archives page to blog Create RSS feeds Explore Google AMP versions for product/post pages Write integration tests for admin area

Credits

The Elixir/Phoenix community is really welcoming & responsive. There are tons of nice examples and packages that helped me with my learning. Here are some of the elixir packages that I am using in this project -

Comeonin for password hashingtest.watch for running testsBamboo for sending emailsCloudini for uploading images to CloudinaryQuantum for running cron tasksCurtail for truncating HTML snippetsXML builder for generating SitemapsKerosene for pagination

For any questions/comments/suggestions, drop me a line at - bharani@authenticpixels.com or send me a tweet.

Thanks,

Bharani, Authentic Pixels - Free & Premium Web Resources

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:asp.net GridView、DataGrid行单元格自动合并
下一篇:通过百度地图API获取用户所在地理位置信息
相关文章

 发表评论

暂时没有评论,来抢沙发吧~