Git Product home page Git Product logo

cb_admin's Introduction

Chicago Boss: Start small, dream big

Build Status

Attention! This is a master branch supporting Erlang 18. For older Erlang versions use legacy branch.

Chicago Boss is a server framework inspired by Rails and written in Erlang. It offers all the conveniences of modern web development, including Comet. What sets Chicago Boss apart from other non-Erlang frameworks is that it can handle large amounts of traffic without any drop in performance. What sets Chicago Boss apart from other Erlang frameworks is that it is easy to set up and use.

WARNING: Chicago Boss does not work with Erlang R16B03 due to an error in erl_syntax

60-second Quickstart

After downloading and extracting, type

make
make app PROJECT=mynewproject
cd ../mynewproject
./init-dev.sh

For Windows, type

windows-make.bat
windows-make.bat app PROJECT=mynewproject
cd ..\mynewproject
start-server.bat

Then visit http://localhost:8001/ in your browser. Congratulations, you have a web server. There will be a lot of PROGRESS REPORTs on your console but everything should be running smoothly.

The project name should be a legal Erlang atom, i.e. start with a lowercase letter and contain only letters, digits, and underscores (for easy compatibility is recommended name the project dir and app name the same).

Dependencies

Admin Interface

You probably want to install the CB admin interface. Download it from

<https://github.com/ChicagoBoss/cb_admin>

Upgrades

Uprading used to be a pain but now it is easy. See README_UPGRADE

Database Setup

By default CB uses an in-memory database that needs no configuration. To start working with an actual database, See README_DATABASE

Philosophy and Features

Why another web framework? Because Rails apps are slow and Node apps are messy. Chicago Boss takes advantage of functional programming and under-the-hood compiler magic to provide clean, understandable controller logic, Django-style templates, and an ORM based on Erlang's parameterized modules. The best part is that the network I/O is 100% asynchronous so you can seamlessly integrate Comet endpoints into your app, and you never have to worry about a slow database query dragging down unrelated requests.

CB ships with all the tools you need to build a feature-ful website, including sessions, URL routing, filtering requests and post-processing responses, frameworks for sending and receiving email, JSON generation, Comet via long-poll and message queues, and internationalization (i18n). Read on for details.

Databases. Chicago Boss currently supports MySQL, PostgreSQL, Tokyo Tyrant, Mnesia, MongoDB, and Riak. In CB 0.5.4 and later, you can mix and match databases by configuring Boss to use vertical shards. For SQL databases, the conventions are similar to Rails (plural nouns for the table names, object_id for foreign keys, etc.).

BossRecords. Boss's take on ActiveRecord is called a BossRecord, which is an Erlang parameterized module on steroids. You instantiate a BossRecord like a regular parameterized module:

Article = article:new('id', "This is a title", "This is a body")

But then CB generates functions and attaches them to BossRecords, so you can write code like

{ok, SavedArticle} = Article:save()

Before saving to the database, the save() function will call a function called validation_tests(), where you can perform custom validation logic.

CB also generates getter functions which can be invoked directly in templates, so in your template you can write things like

{{ article.title }}

Speaking of which...

Templates. Chicago Boss uses ErlyDTL, an Erlang implentation of Django template language. In fact, Chicago Boss originated with a rewrite of ErlyDTL, and the same person maintains both projects so you always get the latest ErlyDTL features. Templates can access and loop over values stored in proplists, dictionaries, and BossRecords, so you can move data from the database to your templates with a minimum of massaging.

In addition, templates are tightly integrated with Boss's i18n machinery. The admin interface automatically parses templates for translatable strings, and Boss can choose which language to serve based on the request's Accept-Languages header and the calculated translation coverage for a particular page. Multi-language websites are easy to develop with Chicago Boss.

Controllers. Erlang's pattern-matching is a perfect fit for writing controller logic. Your controllers are passed the URL method (GET, POST) and a list of URL tokens, and just need to return a tuple telling Boss what to do, for example:

  • {ok, Variables} - render the default template with Variables
  • {render_other, Variables} - render another template
  • {redirect, URL} - redirect the request
  • {json, Proplist} - encode the Proplist as JSON and send to the client
  • {output, Data} - send Data to the client

If you come from Rails, you'll instantly notice the benefit of Erlang's language design: you don't need an ugly case request.method statement inside every action, you never have atrocities like render and return, and you can always see every variable that is in scope. In CB apps, controller logic is always concise and usually a pleasure to read.

Sessions. You can configure sessions to be stored in memory (ETS) or in an Mnesia database. The boss_session and boss_flash modules provide functions for storing and retrieving session information.

Routes. By default, Chicago Boss uses the same routing conventions as Ruby on Rails (/controller/action/id). You can customize the routes and provide a base URL in the priv/application.routes file. Of course, most routing occurs with the pattern-matching controller logic, e.g.

posts('GET', ["category", Category]) ->

You can then generate URLs to match controller patterns in your templates like so:

{% url action="posts" category="some category" %}

Email. Chicago Boss ships with a miniature MVC for sending multipart emails. Emails can be templated with ErlyDTL, and it is easy to provide plain-text and HTML versions of the same email. In testing environments, email can be sent directly to the recipient, or in production can be relayed to an SMTP server.

A Chicago Boss server can also receive email over SMTP. Each email address maps to a function in your incoming mail controller, so it is easy to write well-organized email applications. Your email controller has access to the exact same resources as your web controllers, including database requests, BossRecord instantiation, and the message queue; web and email are fully integrated.

Comet. It's simple to write a Comet endpoint in Chicago Boss. Unlike any other language, Erlang gives you the benefits of asynchronous network communcation without using callbacks. Here is a trivial example of a long-poll controller:

longpoll('GET', [Channel]) ->
    {ok, Timestamp, Messages} = boss_mq:pull(Channel, last),
    {json, [{timestamp, Timestamp}, {messages, Messages}]}.

The call to pull blocks until a message is received. Because processes are cheap in Erlang, the overhead of keeping alive a blocking request is very small (just a few kilobytes of memory, compared to megabytes in Rails). You can thus keep alive thousands of Comet request with just a few megabytes of memory. Also notice that the controller logic remains nice and clean (no callbacks). We can perform an arbitrary sequence of asynchronous network requests without increasing the scope level.

Events. An interesting feature of Chicago Boss is the events API called BossNews. With it, you can watch a record or a set of records for changes, then execute a callback when a change is witnessed. Combined with long-polling, you can provide a real-time view of your database on your website. Events can also be used to provide a clean separation of business logic and notification logic.

Tests. Chicago Boss has a kick-ass testing framework. Once you try it you won't go back. That's all I'll say for now.

Future Work

Most of Chicago Boss's planned features have been implemented at this point. It hasn't really been tested in a distributed environment, but it's already running on a few public-facing websites, and many more internal websites (or so I am told). It would be nice to add more databases (such as CouchDB and Oracle) and support horizontal sharding. The last main feature before 1.0 will be the ability to distribute apps written in Chicago Boss as standalone OTP applications.

Further Reading

See the FAQ and API files located at

http://www.chicagoboss.org/

If you need help getting started, check the new pdf tutorial:

http://www.chicagoboss.org/tutorial.pdf

Be sure to also check the wiki

https://github.com/ChicagoBoss/ChicagoBoss/wiki

There's also the mailing list:

http://groups.google.com/group/chicagoboss

If you want to contribute to CB

CODING_STANDARDS.md

View the CHANGELOG.md

CHANGELOG.md

cb_admin's People

Contributors

aherranz avatar burbas avatar choptastic avatar cstar avatar danikp avatar drobakowski avatar evanmiller avatar hiaw avatar imperialwicket avatar jgordor avatar majastanislawska avatar mihawk avatar rambocoder avatar ruanpienaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cb_admin's Issues

Assets return empty reply from server unless {allow_ip_blocks, ["127.0.0.1"]}

On a deploy of HEAD SHA: 3951cdd requests for stylesheets return an "empty status from server" unless the request is from localhost.

Say cb_admin is properly configured under another CB app, and allow_ip_blocks = a public IP, requests to /admin will load the HTML correctly, however the page will not contain styles because when the browser requests to:

/admin/static/stylesheets/application.css?1298394796

CB returns an empty response (also crashes the nginx worker that handled it..)

My workaround is to set allow_ip_blocks to 127.0.0.1 and rewrite the headers to be 127.0.0.1 inside the HTTP server.

Adding cb_admin to current ChicagoBoss installation

I just installed ChicagoBoss following the github instructions.

Then, I created a project:

make
make app PROJECT=myproject
cd ../myproject

Everything's cool so far, now, I want to add the admin interface such as cb_admin, so I add to myproject rebar.conf this line {cb_admin, ".*", {git, "git://github.com/ChicagoBoss/cb_admin.git", "HEAD"}} so it will become:

{deps, [
{boss, ".", {git, "https://github.com/ChicagoBoss/ChicagoBoss.git", {tag, "v0.9.beta-1"}}}
{cb_admin, ".
", {git, "git://github.com/ChicagoBoss/cb_admin.git", "HEAD"}}
]}.
{plugin_dir, ["priv/rebar"]}.
{plugins, [boss_plugin]}.
{eunit_compile_opts, [{src_dirs, ["src/test"]}]}.
{lib_dirs, ["../ChicagoBoss/deps/elixir/lib"]}.

So I run ./rebar get-deps compile, but it keeps throwing me this error:

ERROR: Failed to load /home/kristian/erlang-projects/myproject /rebar.config: {error,
{3,
erl_parse,
["syntax error before: ",
"'{'"]}}

Please, anybody has an idea about this?

My erlang version is 19

Thanks in advance

[info] GET /admin/admin/access_denied [cb_admin] 200 0ms

I'm installing cb_admin and i don't understand how to access to /admin on a real server and not from localhost due to the lack of documentation.
I succeeded to access from localhost as you can see :
admin
(this screen copy was done by phantomjs accessing to http://localhost:8001/admin)
But when i want to access to http://real_ip_address:8001/admin from localhost or from outside i have the following error : Error in controller, see console.log for details
and rerouting to : http://real_ip_address:8001/admin/admin/access_denied
Here is the console log :

./init-dev.sh
Erlang R16B (erts-5.10.1) [source] [64-bit] [async-threads:10] [kernel-poll:false]


=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.42.0>},
                       {name,alarm_handler},
                       {mfargs,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.43.0>},
                       {name,overload},
                       {mfargs,{overload,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.41.0>},
                       {name,sasl_safe_sup},
                       {mfargs,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.44.0>},
                       {name,release_handler},
                       {mfargs,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
         application: sasl
          started_at: experimental@experimental

=PROGRESS REPORT==== 23-Aug-2014::22:16:55 ===
          supervisor: {local,kernel_safe_sup}
             started: [{pid,<0.49.0>},
                       {name,timer_server},
                       {mfargs,{timer,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,1000},
                       {child_type,worker}]
Eshell V5.10.1  (abort with ^G)
(experimental@experimental)1> 
=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
         application: syntax_tools
          started_at: experimental@experimental

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
         application: compiler
          started_at: experimental@experimental

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,gr_sup}
             started: [{pid,<0.58.0>},
                       {name,gr_counter_sup},
                       {mfargs,{gr_counter_sup,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,gr_sup}
             started: [{pid,<0.59.0>},
                       {name,gr_param_sup},
                       {mfargs,{gr_param_sup,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,gr_sup}
             started: [{pid,<0.60.0>},
                       {name,gr_manager_sup},
                       {mfargs,{gr_manager_sup,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
         application: goldrush
          started_at: experimental@experimental

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,lager_sup}
             started: [{pid,<0.65.0>},
                       {name,lager},
                       {mfargs,{gen_event,start_link,[{local,lager_event}]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,worker}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,lager_sup}
             started: [{pid,<0.66.0>},
                       {name,lager_handler_watcher_sup},
                       {mfargs,{lager_handler_watcher_sup,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 23-Aug-2014::22:16:56 ===
          supervisor: {local,lager_sup}
             started: [{pid,<0.67.0>},
                       {name,lager_crash_log},
                       {mfargs,
                           {lager_crash_log,start_link,
                               ["log/crash.log",65536,10485760,[{hour,0}],5]}},
                       {restart_type,permanent},
                       {shutdown,5000},
                       {child_type,worker}]
22:16:56.320 [info] Application lager started on node experimental@experimental
22:16:56.340 [info] Application crypto started on node experimental@experimental 
22:16:56.351 [info] Application mimetypes started on node experimental@experimental
22:16:56.383 [info] Starting Boss in development mode....

22:16:56.392 [info] Start Database Adapter boss_db_adapter_mock options [{adapter,mock},{cache_enable,false},{cache_prefix,db},{shards,[]},{is_master_node,true},{db_host,"localhost"},{db_port,1978}]
22:16:56.432 [info] Starting master services on experimental@experimental

22:16:56.446 [info] Application tinymq started on node experimental@experimental 
22:16:56.473 [info] SSL:[]

22:16:56.477 [info] Starting cowboy... on experimental@experimental

22:16:56.480 [info] Application cowlib started on node experimental@experimental 
22:16:56.484 [info] Application ranch started on node experimental@experimental
22:16:56.495 [info] Application cowboy started on node experimental@experimental 
22:16:56.495 [info] Starting http listener... on 0.0.0.0:8001 

22:16:56.547 [info] Loading application experimental
22:16:56.557 [notice] Compile file "/home/erlang/experimental/src/test/functional/experimental_test.erl" with options [{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.573 [notice] Deprecated lager_file_backend config detected, please consider updating it
22:16:56.584 [notice] Compile file "/home/erlang/experimental/src/mail/experimental_outgoing_mail_controller.erl" with options [{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.593 [notice] Compile file "/home/erlang/experimental/src/mail/experimental_incoming_mail_controller.erl" with options [{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.604 [info] Compile controller /home/erlang/experimental/src/controller/experimental_greeting_controller.erl
22:16:56.604 [notice] Compile file "/home/erlang/experimental/src/controller/experimental_greeting_controller.erl" with options [debug_info,{pre_revert_transform,#Fun<boss_controller_compiler.add_routes_to_forms.1>},{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.614 [notice] Compile file "/home/erlang/experimental/src/view/lib/tag_modules/experimental_custom_tags.erl" with options [{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.622 [notice] Compile file "/home/erlang/experimental/src/view/lib/filter_modules/experimental_custom_filters.erl" with options [{out_dir,undefined},{include_dirs,["/home/erlang/experimental/include"]},{compiler_options,[{parse_transform,lager_transform},return_errors]}] 
22:16:56.624 [info] Compile Modules "src/view/lib/tag_html"  experimental_view_lib_tags
22:16:56.669 [notice] Compile file "/home/erlang/experimental/priv/init/experimental_01_news.erl" with options [{include_dirs,["/home/erlang/experimental/include"]}] 
22:16:56.676 [notice] Compile file "./deps/cb_admin/priv/init/cb_admin_01_news.erl" with options [{include_dirs,["/home/erlang/experimental/include"]}] 
22:17:05.214 [notice] ApplicationForPath cb_admin
22:17:05.217 [info] Boss Route cb_admin "admin" "index" []
22:17:05.261 [warning] lager_error_logger_h dropped 80 messages in the last second that exceeded the limit of 50 messages/sec
22:17:05.261 [info] GET /admin [cb_admin] 302 0ms
22:17:05.367 [notice] ApplicationForPath cb_admin
22:17:05.369 [notice] Request Method 'GET'
22:17:05.369 [notice] Tokens []
22:17:05.370 [error] Error in controller error {badmatch,{cb_admin_admin_controller,{simple_bridge_request_wrapper,mochiweb_request_bridge,{mochicow_request,#Port<0.27290>,'GET',"/admin/admin/access_denied",'HTTP/1.1',{7,{"host",{"host","real_ip_address:8001"},{"accept",{"accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},nil,{"accept-language",{"accept-language","fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3"},{"accept-encoding",{"accept-encoding","gzip, deflate"},nil,nil},{"cookie",{"cookie","_boss_session=7822e2a5487da1ae98bd63f29a682713e8b57c73"},{"connection",{"connection","keep-alive"},nil,nil},nil}}},{"user-agent",{"user-agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Firefox/31.0"},nil,nil}}},<<>>},false,[],[],none},"7822e2a5487da1ae98bd63f29a682713e8b57c73"}} [{boss_controller_adapter_pmod,action,2,[{file,"src/boss/controller_adapters/boss_controller_adapter_pmod.erl"},{line,99}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,363}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,355}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,334}]},{boss_web_controller_handle_request,process_dynamic_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,242}]},{boss_web_controller_handle_request,process_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,232}]},{boss_web_controller_handle_request,set_timer,7,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,148}]},{boss_web_controller_handle_request,build_dynamic_response,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,122}]}]
22:17:05.372 [info] GET /admin/admin/access_denied [cb_admin] 200 0ms

Infinite loop in compiling cb_admin when added as a dependency

Experimenting more with cb_admin and finding that I get an infinite loop when adding cb_admin as a dependency to a newly generated project, both when running ./rebar compile or just when launching with init-dev.sh.

It just loops forever and starts eating up RAM. I'm not sure what it's hanging on, other than it's happening during the pre-compile phase (the ==> cb_admin (pre-compile) message never even makes it to the screen.

Odd, because it works just fine as a standalone.

Anyway, this is mostly just a note for myself for later so I don't forget. I'll be inspecting the nature of the boss_plugin to see what's happening there.

Though if anyone has any ideas, I'm all ears.

"unhandled and unrecoverable error" on /admin/model/voter

I'm working through the Evening with Chicago Boss tutorial
https://github.com/ChicagoBoss/ChicagoBoss/wiki/An-Evening-With-Chicago-Boss

When I visit http://localhost:8001/admin/model/voter, as the tutorial suggests, this error shows up in the browser:

An unhandled and unrecoverable error occurred. Please check error logs.

The error logs have this to say:

14:08:13.057 [notice] ApplicationForPath cb_admin
14:08:13.058 [info] Route: "/model/voter"Url
[]
14:08:13.059 [error] Unhandled Error: error:function_clause Stacktrace: [{string,tokens1,[49,"/",[]],[{file,"string.erl"},{line,226}]},{cb_admin_lib,-require_ip_address/1-fun-0-,3,[{file,"/Users/issactrotts/erlang/evening/deps/cb_admin/src/lib/cb_admin_lib.erl"},{line,24}]},{lists,foldr,3,[{file,"lists.erl"},{line,1274}]},{cb_admin_lib,require_ip_address,1,[{file,"/Users/issactrotts/erlang/evening/deps/cb_admin/src/lib/cb_admin_lib.erl"},{line,22}]},{boss_controller_adapter_pmod,before_filter,2,[{file,"src/boss/controller_adapters/boss_controller_adapter_pmod.erl"},{line,58}]},{boss_web_controller,apply_before_filters,3,[{file,"src/boss/boss_web_controller.erl"},{line,365}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,300}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,287}]}]

The error message is cryptic. I tried pasting it into the erl shell, but it can't digest the dash (-) in -require_ip_address.

Rendering erlang:now() is broken

Hi,

Having timestamps in you data is kind of standard, Rails has created_at and updated_at, etc. I was trying to do the same and included StartTime and EndTime in my model (kind of similar to the Rails timestamps but not quite).

After pulling up the records in CB_Admin it renders like this:

http://cl.ly/image/2P30381W3X2N

Here is the relevant code

cb_admin/src/view/model/show.html

{% if datatype == "datetime" %}
<span id="{{ record.id }}-{{ key }}">{{ val|date:"N j, Y, P" }}</span>
{% else %}

I am fairly new to CB so I had no idea what date:"N j, Y, P" is doing but I guess it is the same as in the Django template builtin.

https://docs.djangoproject.com/en/1.1/ref/templates/builtins/#date

Unfortunately you can't pass in the erlang:now() output to this built in function because it renders it incorrectly as you can see the screenshot above.

In Erlang I would fix it something like this:

{{Year,Month,Day},{Hour,Min,Sec}} = calendar:now_to_local_time(erlang:now()).
lists:flatten(io_lib:format("~p : ~p : ~p - ~p : ~p : ~p", [Year, Month, Day, Hour, Min, Sec])).

My question would be: how is this supposed to be fixed? Could I invoke an Erlang function from the template or I need to format the timestamp before I pass it in?

Thank you in advance!

rebar get-deps can't get erlang-uuid dependency

when run ./rebar get-deps, I got this error report:

Pulling uuid from {git,"git://gitorious.org/avtobiff/erlang-uuid.git",
                       {tag,"9cfe9666f1"}}
Cloning into 'uuid'...
fatal: unable to connect to gitorious.org:
gitorious.org[0: 64.13.172.37]: errno=Connection refused

ERROR: git clone -n git://gitorious.org/avtobiff/erlang-uuid.git uuid failed with error: 128 and output:
Cloning into 'uuid'...
fatal: unable to connect to gitorious.org:
gitorious.org[0: 64.13.172.37]: errno=Connection refused

It seems git://gitorious.org/avtobiff/erlang-uuid.git is not accessible any more?

Upgrade BEAM code cause Mnesia and Ranch crash

We use Mnesia as application's database, when use the cb_admin's upgrade beam code, the mnesia and ranch will be crashed.

11:09:29.166 [error] Supervisor mnesia_kernel_sup had child mnesia_tm started with mnesia_tm:start() at <0.105.0> exit with reason killed in context child_terminated
11:09:29.166 [error] Supervisor mnesia_kernel_sup had child mnesia_tm started with mnesia_tm:start() at <0.105.0> exit with reason reached_max_restart_intensity in context shutdown
11:09:29.167 [error] Supervisor mnesia_sup had child mnesia_kernel_sup started with mnesia_kernel_sup:start() at <0.100.0> exit with reason shutdown in context child_terminated
11:09:29.167 [error] Supervisor mnesia_sup had child mnesia_kernel_sup started with mnesia_kernel_sup:start() at <0.100.0> exit with reason reached_max_restart_intensity in context shutdown
11:09:29.182 [info] Application mnesia exited with reason: shutdown
11:09:29.772 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,28} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.191.0> exit with reason killed in context child_terminated
11:09:29.773 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,29} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.192.0> exit with reason killed in context child_terminated
11:09:29.773 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,5} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.168.0> exit with reason killed in context child_terminated
11:09:29.773 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,1} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.164.0> exit with reason killed in context child_terminated
11:09:29.773 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,2} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.165.0> exit with reason killed in context child_terminated
11:09:29.773 [error] Supervisor {<0.163.0>,ranch_acceptors_sup} had child {acceptor,<0.163.0>,6} started with ranch_acceptor:start_link(#Port<0.22521>, ranch_tcp, <0.162.0>) at <0.169.0> exit with reason killed in context child_terminated

By reading the mnesia source code, I found this comment in mnesia_sp.erl module

%% To able to generate nice crash reports we need a catch on the highest level.
%% This code can't be purged so a code change is not possible.
%% And hence this a simple module.

So I solved this problem temporarily by filtering mnesia and ranch related modules from code:all_loaded()

Some people also commit this issue in mail list
https://groups.google.com/forum/#!topic/chicagoboss/sKN7Bvpeskc

Strange "vsn" value in Applications loaded pour cb_admin

As you can see at #35 snapshot, there is a strange value of cb_admin:vsn in Applications loaded, instead of "0.7.1' we have "/bin/sh: 1: 0.7.1: not found" ...

Applications loaded

    {kernel,"ERTS CXC 138 10","2.16.1"}
    {lager,"Erlang logging framework","2.0.3"} 
    {cowboy,"Small, fast, modular HTTP server.","0.9.0"}
    {mimetypes,"mimetypes","1.0"}
    {cb_admin,"Chicago Boss Admin Interface","/bin/sh: 1: 0.7.1: not found"}
    {goldrush,"Erlang event stream processor","0.1.6"}
    {boss,"Chicago Boss web framework, now serving three flavors of Comet", "0.8.11"}
    {crypto,"CRYPTO version 2","2.3"}
    {stdlib,"ERTS CXC 138 10","1.19.1"}
    {cowlib,"Support library for manipulating Web protocols.","0.4.0"}
    {syntax_tools,"Syntax tools","1.6.11"}
    {compiler,"ERTS CXC 138 10","4.9.1"}
    {tinymq,"TinyMQ: a diminutive message queue","0.1.1"}
    {ranch,"Socket acceptor pool for TCP protocols.","0.9.0"}
    {sasl,"SASL CXC 138 11","2.3.1"}

Searching :
cb_admin.app.src : {vsn, "0.7.1"} OK
cb_admin_admin_controller.erl :
{modules_loaded, ModulesLoaded} is set by application:info()
Searching for "loaded" in boss, i went to boss_load.rel :

make_computed_vsn({unknown, Val} ) ->Val;
make_computed_vsn(Cmd ) ->
    VsnString = os:cmd(Cmd),
    string:strip(VsnString, right, $\n).

error rebar compile

when i execute:

./rebar compile

i have error:

==> cb_admin (pre_compile)
ERROR: pre_compile failed while processing /opt/cb_admin: {'EXIT',
    {undef,
        [{boss_rebar,all_ebin_dirs,
             [[{boss,
                   [{path,"../ChicagoBoss"},
                    {vm_cookie,"abc123"},
                    {applications,[cb_admin]},
                    {db_host,"localhost"},
                    {db_port,1978},
                    {db_adapter,mock},
                    {log_dir,"log"},
                    {server,cowboy},
                    {port,8001},
                    {session_adapter,mock},
                    {session_key,"_boss_session"},
                    {session_exp_time,525600}]},
               {cb_admin,
                   [{path,"../cb_admin"},
                    {allow_ip_blocks,["127.0.0.1"]},
                    {base_url,"/admin"}]}],
              "/opt/cb_admin/src/cb_admin.app.src"],
             []},
         {boss_plugin,init,3,[{file,"priv/rebar/boss_plugin.erl"},{line,85}]},
         {boss_plugin,pre_compile,2,
             [{file,"priv/rebar/boss_plugin.erl"},{line,104}]},
         {rebar_core,run_modules,4,[]},
         {rebar_core,execute,4,[]},
         {rebar_core,process_dir0,6,[]},
         {rebar_core,process_commands,2,[]},
         {rebar,main,1,[]}]}}

Please tell me
Thank you for your job
Спасибо вам за ваш труд

Installation/Dependency Error

@ChicagoBoss , I got error but not assuming why i get it.

Check below:

00:53:33.325 [error] gen_server <0.114.0> terminated with reason: call to undefined function crypto:hash_init/2 from boss_session_controller:generate_session_id/0 line 81
00:53:33.358 [error] CRASH REPORT Process <0.114.0> with 0 neighbours exited with reason: call to undefined function crypto:hash_init(sha, <<246,58,20,109,198,111,251,49,117,40,170,234,91,10,63,24,51,51,56,83,167,62,142,126,104,51,29,...>>) in gen_server:terminate/6 line 747
00:53:33.358 [error] Supervisor {<0.112.0>,poolboy_sup} had child boss_session_controller started with {boss_session_controller,start_link,undefined} at <0.114.0> exit with reason call to undefined function crypto:hash_init(sha, <<246,58,20,109,198,111,251,49,117,40,170,234,91,10,63,24,51,51,56,83,167,62,142,126,104,51,29,...>>) in context child_terminated

Is there any dependancy remain which i need to add, or something else?

Provide an option for changing model directory

It would be helpful if instead of copying/symlinking models to cb_admin/src/model and updating the model_modules key, it would be possible to specify a model_dir key which takes a directory and loads all models from it (including when running in production mode).

@nivertech

model view can not display datetime with '0000-00-00 00:00:00'

I'm a rookie on chicagoboss.. while working on mysql with timestamp I had faced cb_admin got crashed when timestamp is set as '0000-00-00 00:00:00' and Error message is folllowing:
[error] <0.320.0>@boss_web_controller_render:render_with_template:284 Error in view cb_admin_view_model_model_html error:function_clause Stacktrace: [{erlydtl_dateformat,monthname,[0],[{file,"src/filter_lib/erlydtl_dateformat.erl"},{line,409}]},{erlydtl_dateformat,tag_to_value,5,[{file,"src/filter_lib/erlydtl_dateformat.erl"},{line,265}]},{erlydtl_dateformat,replace_tags,7,[{file,"src/filter_lib/erlydtl_dateformat.erl"},{line,103}]},{cb_admin_view_model_model_html,-render_internal/2-fun-10-,6,[{file,""},{line,1157}]},{lists,mapfoldl,3,[{file,"lists.erl"},{line,1352}]},{lists,mapfoldl,3,[{file,"lists.erl"},{line,1353}]},{erlydtl_runtime,forloop,4,[{file,"src/erlydtl_runtime.erl"},{line,408}]},{cb_admin_view_model_model_html,-render_internal/2-fun-11-,5,[{file,""},{line,1434}]}]

to make a workaround on this issue, I had to change cb_admin view mode templates(model.html and show.html)
to date:"Y-m-d H:i:s" from date:"N j, Y,P"

hope this help to any one who has the same issue.. hope cb_admin can enhance this case or make a documentation somewhere.

/admin/model/model template or controller broken

Js in Generated page (/admin/model/model) is broken, because variable timestamp has wrong value (Js mistake). And model view dont work.
In Head of page, last script (dynamicaly generated.)

base_url = "/admin";
var topic_string = "";
var timestamp = {1404,954953,474808};
$(document).ready(function() {
if (topic_string) {
watch_topic(topic_string, timestamp);
}
});

Lager error while compilation

When I do:

./rebar get-deps compile

During lager compilation, I get the following error:

==> lager (pre_compile)
ERROR: pre_compile failed while processing /tmp/cb_admin/deps/lager: {'EXIT',
    {undef,
        [{rebar_config,get_xconf,
             [{config,"/tmp/cb_admin/deps/lager",
                  [{erl_opts,[debug_info]},
                   {erl_first_files,["src/lager_util.erl"]},
                   {cover_enabled,true},
                   {edoc_opts,[{stylesheet_file,"./priv/edoc.css"}]},
                   local,
                   {erl_opts,[debug_info]},
                   {template_dir,"."},
                   {deps,
                       [{lager,".*",
                            {git,"git://github.com/basho/lager.git",
                                {tag,"1.2.2"}}},
                        {boss_db,".*",
                            {git,"git://github.com/evanmiller/boss_db.git",
                                "HEAD"}},
                        {tinymq,".*",
                            {git,"git://github.com/evanmiller/tinymq.git",
                                "HEAD"}},
                        {tiny_pq,".*",
                            {git,"git://github.com/evanmiller/tiny_pq.git",
                                "HEAD"}},
                        {erlydtl,".*",
                            {git,"git://github.com/evanmiller/erlydtl.git",
                                "HEAD"}},
                        {jaderl,".*",
                            {git,"git://github.com/evanmiller/jaderl.git",
                                "HEAD"}},
                        {lfe,".*",
                            {git,"git://github.com/rvirding/lfe.git",
                                "fb7c96eb17"}},
                        {gen_smtp,".*",
                            {git,"git://github.com/Vagabond/gen_smtp.git",
                                "0558786233"}},
                        {mochiweb,".*",
                            {git,"git://github.com/mochi/mochiweb.git",
                                {tag,"v2.4.2"}}},
                        {simple_bridge,".*",
                            {git,
                                "git://github.com/nitrogen/simple_bridge.git",
                                "f12c2a571c"}},
                        {poolboy,".*",
                            {git,"git://github.com/devinus/poolboy.git",
                                {tag,"1.0.0"}}},
                        {cowboy,".*",
                            {git,"git://github.com/extend/cowboy.git",
                                {tag,"0.8.2"}}},
                        {mochicow,".*",
                            {git,"git://github.com/evanmiller/mochicow.git",
                                "r16-compat"}}]},
                   {erlydtl_opts,
                       [{doc_root,"src/boss"},
                        {out_dir,"ebin"},
                        {source_ext,".dtl"},
                        {module_ext,[]}]},
                   {lib_dirs,["deps/elixir/lib"]},
                   {deps,
                       [{boss,".*",
                            {git,
                                "git://github.com/evanmiller/ChicagoBoss.git",
                                "HEAD"}}]},
                   {plugin_dir,["priv/rebar"]},
                   {plugins,[boss_plugin]},
                   {eunit_compile_opts,[{src_dirs,["src/test"]}]}]},
              base_dir,undefined],
             []},
         {boss_plugin,is_base_dir,1,
             [{file,"priv/rebar/boss_plugin.erl"},{line,143}]},
         {boss_plugin,pre_compile,2,
             [{file,"priv/rebar/boss_plugin.erl"},{line,106}]},
         {rebar_core,run_modules,4,[]},
         {rebar_core,execute,4,[]},
         {rebar_core,process_dir0,6,[]},
         {rebar_core,process_each,5,[]},
         {rebar_core,process_dir0,6,[]}]}}
me@me:/tmp/cb_admin$ 

I am running R15B01.

cb_admin doesn't compile against R16

==> cb_admin (compile)
src/controller/cb_admin_admin_controller.erl:1: parameterized modules are no longer supported
src/controller/cb_admin_admin_controller.erl:10: variable 'Req' is unbound
src/controller/cb_admin_admin_controller.erl:25: variable 'Req' is unbound
....

Compiling error

I am unable to link it with my project , i did all the settings accordingly but it showing me the routing error.Any help will be appreciated.

where i tried to compile cb_admin with get-deps and i got following error

ERROR: Compiling template src/boss/boss_html_errors_template.dtl failed:
{ok,boss_html_errors_template}

i tried it by cloning as well as by downloading zip file but nothing works for me

Any help?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.