Coder Social home page Coder Social logo

nitrogen / nitrogen Goto Github PK

View Code? Open in Web Editor NEW
945.0 40.0 159.0 8.17 MB

Nitrogen Web Framework for Erlang (now with websockets!)

Home Page: http://nitrogenproject.com

License: MIT License

Shell 16.39% Perl 16.76% Erlang 45.92% Makefile 13.74% CSS 1.21% HTML 1.57% Emacs Lisp 3.66% Batchfile 0.23% Vim Script 0.51%
erlang javascript webframework websockets

nitrogen's Introduction

Nitrogen Web Framework for Erlang

Nitrogen is an Erlang-based web framework that allows you to develop infinitely scaleable, Ajax-rich web applications using a pure Erlang technology stack.

See the Nitrogen Project website for additional information.

Upgrading from Nitrogen 2 to Nitrogen 3?

If you are using a Nitrogen 2 structured project, run the following two commands from the root of your Nitrogen 2-based project.

WARNING: Make sure you commit to version control before running this - it will change your working directory heavily

WARNING 2: Running scripts directly from the internet is dumb. Review this script's code before you run it. But if you really want to do it this way, here you go.

curl -o https://raw.githubusercontent.com/nitrogen/nitrogen/master/scripts/upgrade_to_nitrogen3.sh
bash upgrade_to_nitrogen3.sh

The first line downloads the upgrade script to your local project directory

The second line runs that script

Getting Started

Follow the tutorial at http://nitrogenproject.com/doc/tutorial.html

Building Nitrogen on Linux and OSX

The Getting Started guide covers this.

Building Nitrogen on FreeBSD

Install Erlang from

Make sure you have gmake installed, and use gmake instead of make

Example:

$ gmake rel_cowboy

Building Nitrogen on Windows

Instructions for building on windows can be found in rel/overlay/win

Want to contribute?

nitrogen_core is where you would find the vast majority of Nitrogen's codebase, should you wish to contribute or make changes.

Read our contribution guidelines to get started contributing to Nitrogen! (they're not strict, just recommendations)

nitrogen's People

Contributors

aseidlitz avatar bjnortier avatar borisfaure avatar carlotm avatar choptastic avatar fbrau avatar fgallaire avatar flambard avatar fooflare avatar h4cc avatar jadahl avatar jaydoane avatar jbcorwin avatar jdavisp3 avatar jongretar avatar leobm avatar marsik avatar mmullis avatar olivier-boudeville avatar qbit avatar rajivr avatar robsc avatar rustyio avatar skeltoac avatar stuart-thackray avatar stuartt4 avatar vinoski avatar vkoivula avatar wardbekker avatar zussitarze 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  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  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

nitrogen's Issues

make rel_yaws fails

make rel_yaws fails to build a nitrogen project with yaws, looks like it has to do with a link created in nitrogen/apps

Unable to upload files while using conversejs

I am using coversejs for chats in my nitrogen application. While using coversejs in my template, #upload{} is not working. It triggers upload start event and failed to upload the file. After removing the conversejs everything seems working fine. What needs to be done to work with conversejs?

#upload record and JQ Mobile trigger('create')

after adding #upload record to my page and applying trigger('create') I can't call openFile dialog by clicking "select file". without using trigger('create') it works ok.

I guess problem in element_upload.erl of nitrogen_core lib but I can't find what exactly is wrong.

utf8 not work in html template file

I wrote some code like this in template of bare.html:

<h1>TITLE IN TEMPLATE: 欢迎</h1>
<h1>TITLE IN ERL: [[[page:title()]]]</h1>

and the page function is:

title() -> "欢迎".

Then I got a page like this:

TITLE IN TEMPLATE: Ƭ¢È¿�
TITLE IN ERL: 欢迎

the utf8 code in erl worked well, but failed in html template.
Why?

Problem Updating the Panel

Updating panels where ones name is the substring of another fails if the substring panel is the latter one defined on the page. Example:

panel { id=metachatHistory, class=chat_history },

panel { id=chatHistory, class=chat_history }

If they are defined in this order when chatHistory is updated with wf:update metachatHistory is updated instead. Clearly it is matching the substring since if the order is changed it works fine.

Thanks,
Tristan

`bin/nitrogen console` errors with `rel_yaws`

Running Debian Wheezy with the latest pull from this github repo.

  1. use make rel_yaws to install (no errors)
  2. cd rel/nitrogen
  3. use bin/nitrogen console to start the server (prints some INFO messages, starts listening on 127.0.0.1:8000)
  4. visit http://localhost:8000 with a browser

Expected: the default demo app page with "Hello..." message and simple button postback.

Result: The browser displays

  Internal error, yaws code crashed

  ERROR erlang  code  crashed:
   File: appmod:0
  Reason: {{badrecord,headers},
           [{nitrogen_yaws,out,1,[{file,"src/nitrogen_yaws.erl"},{line,5}]},
            {yaws_server,deliver_dyn_part,8,
                         [{file,"src/yaws_server.erl"},{line,2652}]},
            {yaws_server,aloop,3,[{file,"src/yaws_server.erl"},{line,1167}]},
            {yaws_server,acceptor0,2,[{file,"src/yaws_server.erl"},{line,1025}]},
            {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}
  Req: {http_request,'GET',{abs_path,"/"},{1,1}}
  Stack: [{nitrogen_yaws,out,1,[{file,"src/nitrogen_yaws.erl"},{line,5}]},
          {yaws_server,deliver_dyn_part,8,
                       [{file,"src/yaws_server.erl"},{line,2652}]},
          {yaws_server,aloop,3,[{file,"src/yaws_server.erl"},{line,1167}]},
          {yaws_server,acceptor0,2,[{file,"src/yaws_server.erl"},{line,1025}]},
          {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]

The console provides the following error reports

  =ERROR REPORT==== 28-Apr-2012::17:44:53 ===
  Error in simple_bridge_request:make/2 - error - {badrecord,headers}
  [{yaws_request_bridge,headers,1,
       [{file,"src/yaws_bridge_modules/yaws_request_bridge.erl"},{line,44}]},
   {simple_bridge_request_wrapper,header,2,
       [{file,"src/simple_bridge_request_wrapper.erl"},{line,29}]},
   {simple_bridge_multipart,is_multipart_request,1,
       [{file,"src/simple_bridge_multipart.erl"},{line,55}]},
   {simple_bridge_multipart,parse,1,
       [{file,"src/simple_bridge_multipart.erl"},{line,49}]},
   {simple_bridge_request,make_nocatch,2,
       [{file,"src/simple_bridge_request.erl"},{line,23}]},
   {simple_bridge_request,make,2,
       [{file,"src/simple_bridge_request.erl"},{line,14}]},
   {nitrogen_yaws,out,1,[{file,"src/nitrogen_yaws.erl"},{line,5}]},
   {yaws_server,deliver_dyn_part,8,[{file,"src/yaws_server.erl"},{line,2652}]}]
  =ERROR REPORT==== 28-Apr-2012::17:44:53 ===
  Error in simple_bridge_request:make/2 - error - {badrecord,headers}
  [{yaws_request_bridge,headers,1,
       [{file,"src/yaws_bridge_modules/yaws_request_bridge.erl"},{line,44}]},
   {simple_bridge_request_wrapper,header,2,
       [{file,"src/simple_bridge_request_wrapper.erl"},{line,29}]},
   {simple_bridge_multipart,is_multipart_request,1,
       [{file,"src/simple_bridge_multipart.erl"},{line,55}]},
   {simple_bridge_multipart,parse,1,
       [{file,"src/simple_bridge_multipart.erl"},{line,49}]},
   {simple_bridge_request,make_nocatch,2,
       [{file,"src/simple_bridge_request.erl"},{line,23}]},
   {simple_bridge_request,make,2,
       [{file,"src/simple_bridge_request.erl"},{line,14}]},
   {nitrogen_yaws,out,1,[{file,"src/nitrogen_yaws.erl"},{line,5}]},
   {yaws_server,deliver_dyn_part,8,[{file,"src/yaws_server.erl"},{line,2652}]}]

Plugins with route pages and app configuration

Hi Jess,

first of all, if you are busy stop reading here and leave it until you have some time (no hurry) :).

I have made some modifications in Plugin system to add some configuration and route template pages. This changes are in https://github.com/fooflare/nitrogen/tree/plugins_configuration but it is just experimental because I made some tests but I am sure that it is not enough. I created another repo with a plugin based on the nitro_login app https://github.com/fooflare/nitrogen_login. The idea is to install the plugin and make it work as if it was a normal app and make it as modular as possible (more ideas than another thing).

Now, the explanation of how it works right now: first of all, after adding the plugin to the rebar configuration and the dependencies of the plugin are installed, the plugin configuration changes are made, in the example two changes: one in vm.args (bcrypt is added to start and a config file that has nothing, it was added just to test) and another adding the config file (as I said, it is empty). If you run the plugin target in the makefile, it checks if the configuration file exists before adding it to the etc folder of the application and if the lines of vm.args already exists (I made a regular expression "trying" to avoid characters that can take to errors).

The next target was to find a way to add the route pages to the application. One thing that I thought was to change the extension of the erlang files (.erl to .route), maybe it is not the best way but... Why I did this? Well. the first reason, because it was a easy way to locate the files, but when this files are installed in site/src/plugin_name, they are renamed with the .erl extension automatically. The second was to avoid to be compiled code in the lib/plugin_folder that it is not necessary to be loaded. To know where install these files, I made another regular expression to check if it has a prefix (in the example, login_) and create the folder to put these pages inside. This solution has a problem and it is that it can take to errors if you want to create a file with '_' in the name and you want it in the root of the url (p.e. with create_account.erl), in my example there is no problem but... I have to think on it. As in the case of configuration files, it checks if they exist to not make modifications in files that already exist and could be modified before (p.e. when you make update-deps and then make plugins).

I am sure that I forget something, but this is more or less the most important. I don't know if you wanted to do something like this, but I did it because looked interesting for me and will be the way I will try to make modular my future developments. If you think that can be useful, I would like that you have a look at it and test it with the example of the login plugin.

Thanks for you patience and regards.

Test Nitrogen on FreeBSD

Compiling on FreeBSD is currently a mess, as the Makefile expects gmake on FreeBSD.

This needs to compile and generate a release cleanly on FreeBSD.

I can't make the latest version in my macbook-pro

I have try the different erlang/otp platform such as R16, R17, but I receive the make error yet.
If I download a compiled version for mac, it worked well, and I can make again in that compiled version.

%%%
......
Compiled src/index.erl
Compiled src/nitrogen_cowboy.erl
Compiled src/mobile.erl
Compiled src/nitrogen_sup.erl
==> nitrogen (compile)
Generating a default cookie in /etc/vm.args
readlink: illegal option -- f
usage: readlink [-n] [file ...]
readlink: illegal option -- f
usage: readlink [-n] [file ...]
sed: -i may not be used with stdin
make[2]: *** [replace_project_name] Error 1
make[1]: *** [rel] Error 2
make: *** [rel_cowboy] Error 2

Trying to build nitrogen latest, got problems with ocamlbuild

It says

 ERROR: Unable to generate spec: read file info /usr/lib/erlang/man/man1/ocamlbuild.native.1.gz failed

What is this? This is the directory

 mattias@ubuntu:/usr/lib/erlang/man/man1$ ls ocaml*
 ocaml.1.gz              ocamldebug.1.gz    ocamllex.1.gz      ocamlopt.opt.1.gz
 ocamlbuild.byte.1.gz    ocamldep.1.gz      ocamllex.opt.1.gz  ocamloptp.1.gz
 ocamlbuild.native.1.gz  ocamldep.opt.1.gz  ocamlmklib.1.gz    ocamlprof.1.gz
 ocamlc.1.gz             ocamldoc.1.gz      ocamlmktop.1.gz    ocamlrun.1.gz
 ocamlc.opt.1.gz         ocamldoc.opt.1.gz  ocamlobjinfo.1.gz  ocamlyacc.1.gz
 ocamlcp.1.gz            ocamldumpobj.1.gz  ocamlopt.1.gz
 mattias@ubuntu:/usr/lib/erlang/man/man1$ 

"Scanning source files..." never seems to end

I installed nitrogen, and am following the tutorial (http://nitrogenproject.com/doc/tutorial.html). I get to "Install & run nitrogen" part which instructs to recompile by typing:

sync:go()

at the nitrogen console. This immediately returns, but the changes I make to index.erl do not appear.

I then try the next compile method:

bin/dev compile
(I also try "./bin/dev compile" for completeness)

at the bash shell. Although bash returns immediately (there is no signal from nitrogen), the console I have open in another bash window (running the nitrogen console) shows this:

([email protected])1> Starting Sync (Automatic Code Compiler / Reloader)
Scanning source files...

It appears that something is happening here, but this status msg never stops. The console hangs on this "Scanning..." message forever. And no compiling of the files takes place; I reload & the changes are not there. I have to Ctrl-C to get out of this hung loop of "Scanning...".

Any ideas? I am a erl noob, so it could be me...

I am using Erlang 5.9 (R15B).

Building HEAD from scratch fails

It fails at get-deps: https://gist.github.com/c2306b881cddc7fd2b95

I have it reproducing consistently on my computer and another agner contributor's computer as well. Not sure what's happening exactly — didn't have much time to look into this; but thought you might be interested to know.

It works the same way if agner is not used: simply git cloning the repo and running ./rebar get-deps produce the same error.

Change the value of textbox in a simple button click (update)

i have in my web page two textbox:
....

textbox{id=my_textbox1, text=" " },

textbox{id=my_textbox2, text=" " },

button {id=my_button, text="go", postback=click}

....

i want do something like:

event(click)->
wf:update(my_textbox2, #textbox{text=wf:q(my_textbox1)}).

but this why it dosn't work for me.....:/

thanks for your help

In Place TextBox - Problem with OriginalText

No matter how many times you change the text and save it, if you click cancel and try and edit again, the original text is displayed in the editable input box.

Steps to reproduce:
Create an inline_textbox with the text "default text"
Click to edit the text
Change the text to "new text"
Click OK (the text should now read "new text")
Click to edit the text (the input box should now read "new text")
Click Cancel (the text should still read "new text")
Click to edit the text (the input box now reads "default text", but should read "new text")

"data_field" and "body" tag params

Why not allowed to use data_fields params for almost all tags, in jquery mobile it can be done in

elems, , etc.
Other issue is deny to use body parameter for

tag, and maybe some other tags. It needs for me to build collapsible list with thumbnails for example.
and one more thing. I realy missed for ability to set some my own porperties for tags

. may be it's not so usable but i guess it is need for better nitrogen to jqm\js\html compatibility.

p.s: nitrogen is realy cool :)

.#dev breaks make

$ make rel_inets
...
ERROR: Unable to generate spec: read file info /usr/local/lib/erlang/lib/nitrogen-master/rel/overlay/common/bin/.#dev failed

Deleting that file allows make to proceed.

README.markdown has bad instructions

After downloading the code, and "cd"-ing into the nitrogen directory,
it says,

### On Mac OSX / Linux
    cd Quickstart 
    ./quickstart.sh

BUT, there is no Quickstart directory.

Security flaw

When user opens page with content like

body() ->
    wf:comet(fun() -> counter(1) end),
    #panel { id=p_container, body=[
        #label { text="Messages so far:" },
        #panel { id=p_messages }
    ]}.

counter/1 is spawned, but never killed if user didn't load .js files for some reason.

'rebar generate' hangs

I tried both an Ubuntu and an OpenSUSE installation. On Ubuntu (10.4 LTS) I use R15B, on OpenSUSE it is R14B02. Then I installed nitrogen (latest source) in ' /usr/local/lib/erlang/modules', setting ERL_LIBS pointing to this path). The 'make compile' succeeds, the make 'rel_inets' hangs (100% CPU) in 'rel_inner' on the 'rebar generate' command. Any suggestions?

`#spinner{}` causes server error

Putting a #spinner{} element on a page causes an Internal Server Error page to be displayed instead of the intended page.

Steps to reproduce:

  1. Start with the standard index.erl page that ships with nitrogen
  2. Add a line to inner_body that reads #spinner{}, (omit the comma, if this is the last line, obviously)
  3. Save the page and let sync recompile it (this causes no errors, just emits two INFO REPORT notices saying that index.erl has been recompiled and reloaded)
  4. Browse to http://localhost:8000

Expected: The standard startup page with a hidden spinner element at the specified position.

Observed: Internal Server Error in the browser, and the following error dumped to console

=INFO REPORT==== 31-Jul-2012::19:14:34 ===
{error,error,undef,
       [{wf,render,
            [{panel,is_element,element_panel,".wfid_temp416077",
                    ".wfid_temp416077",undefined,true,
                    [spinner,[".wfid_temp416077",[]]],
                    [],
                    {image,is_element,element_image,undefined,undefined,
                           undefined,true,[],[],"/nitrogen/spinner.gif",
                           undefined},
                    [],true}],
            []},
        {wf_render_elements,call_element_render,2,
                            [{file,"src/lib/wf_render_elements.erl"},
                             {line,112}]},
        {wf_render_elements,render_element,1,
                            [{file,"src/lib/wf_render_elements.erl"},
                             {line,100}]},
        {wf_render_elements,render_elements,2,
                            [{file,"src/lib/wf_render_elements.erl"},
                             {line,34}]},
        {lists,foldl,3,[{file,"lists.erl"},{line,1197}]},
        {wf_render_elements,render_elements,2,
                            [{file,"src/lib/wf_render_elements.erl"},
                             {line,29}]},
        {lists,foldl,3,[{file,"lists.erl"},{line,1197}]},
        {wf_render_elements,render_elements,2,
                            [{file,"src/lib/wf_render_elements.erl"},
                             {line,29}]}]}

Environment Notes:

  • Debian Wheezy 64-bit running on a Core i3
  • Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false], Eshell V5.9.1
  • Nitrogen from commit d88e01282370599ac878199aa92505307284175c made with make rel_yaws (subsequent commits seem to do nothing related to elements)

Tutorial "More Event Examples", wf:wire doesn't work with several #event in []

wf:wire(mybutton, [
    #event { type=mouseover, postback=my_mouseover_event }
    #event { type=click, postback=my_click_event }
    #event { type=mouseout, postback=my_mouseout_event }
]),

As in the tutorial will result in only the last one working.
This instead does work, but makes me really wish the shorter way would, too:

wf:wire(mybutton, #event { type=mouseover, postback=my_mouseover_event }),
wf:wire(mybutton, #event { type=click, postback=my_click_event }),
wf:wire(mybutton, #event { type=mouseout, postback=my_mouseout_event }),

BTW, on the same tutorial slide, there's an MyEvent that should be OtherEvent. But many thanks for writing it in the first place ;)

Release generation should initialize the ability to create a release from the target project

Right now, the standard Nitrogen setup creates a release which includes Nitrogen code. This is great for development, but when it comes time for upgrading, it'd be nice to be able to take advantage of the actual auto-release upgrade system built into Erlang.

This is where a generatable release comes in.

Essentially, this would set up a rel directory with a default reltool.config file. Then include a make release rule for the Makefile, and in the end it would create an actual release for the project to do a more seamless hot upgrade than relying on sync

In short: from the nitrogen repo:

make rel_whatever creates an initial development environment for working, then from that "development release", make release would create the actual production-level release for the destination machine.

Meck compile error

I get this error generating webmachine project:

Compiling /home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl failed:
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:51: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:345: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:382: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:383: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:415: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:416: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:422: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:423: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:429: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
/home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck/src/meck_proc.erl:430: type dict/0 is deprecated and will be removed in OTP 18.0; use use dict:dict/0 or preferably dict:dict/2
ERROR: compile failed while processing /home/fooflare/workspace/repos/Nitrogen-fork/rel/nitrogen/lib/meck: rebar_abort
Makefile:10: recipe for target 'compile' failed
make[4]: *** [compile] Error 1

Seems that updating webmachine to tag 1.10.6 the problem is fixed, but I am not sure if simple_bridge can have issues with that version. Forgetting the deprecation messages, this version of meck doesn't compile with R17.1 and as you can see the error message is very detailed :)

slim release dependency problem

I have a nitrogen slim_cowboy app that appears to be pulling in an incompatible version of simple_bridge. The app builds from the original clone directory, but when I create a new clone (same machine, same erlang version) and build it, it fails at runtime with:

=ERROR REPORT==== 29-Sep-2014::17:05:20 ===
Error in simple_bridge:make/2 - error - function_clause
[{cowboy_simple_bridge,init,
[{sbw,cowboy_simple_bridge,
{cowboy_bridge,#Ref<0.0.0.250>},
...
                       [{file,"src/cowboy_bridge_modules/cowboy_simple_bridge.erl"},
                        {line,46}]},

full gist here

I compared the version of simple_bridge in both clones and it appears the failing one is at the new 2.0 beta. I recloned and edited rebar.config to use v1.4.1 of simple_bridge, and got a different failure. I then tried v.1.4.0 with the same result.

I could keep going and try different combinations, but I'm sure an expert probably knows immediately which versions to use...

nitrogen project setup replaces keywords anywhere in path

The support\nitrogen escript replaces keywords anywhere in the path, not just the filename and content.

For example, I do all my development under d:\development\projects[projectname].
when executing "nitrogen create testproject" it gets up to creating the Makefile (the first thing that uses nitrogen_file:copy_file/3) and fails.

Instead of "d:/development/PROJECTS/testproject/Makefile"
it tries to create "d:/development/testprojectS/testproject/Makefile"

The following patch corrects the problem by passing along the DestDir param to copy_file/4 (which is a simple modification from copy_file/3, which is no longer used)

diff -u d:\development\erlang\nitrogen\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\src\project/nitrogen_file.erl src\project/nitrogen_file.erl
--- d:\development\erlang\nitrogen\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\src\project/nitrogen_file.erl    2009-05-03 07:43:24 +1000
+++ src\project/nitrogen_file.erl   2009-09-20 18:07:18 +1000
@@ -4,7 +4,7 @@
 % See MIT-LICENSE for licensing information.
 -module(nitrogen_file).
 -include_lib("kernel/include/file.hrl").
--export([create_page/2, copy_file/2, copy_file/3]).
+-export([create_page/2, copy_file/2, copy_file/3, copy_file/4]).

 create_page(Url, Dir) ->
     SrcFile = nitrogen_project:src_path("priv/skel/PAGE.erl"),
@@ -27,7 +27,17 @@
     ok = file:write_file(ParsedDestFile, list_to_binary(Contents)),
     file:write_file_info(ParsedDestFile, Mode).

+copy_file(SrcFile, DestFile, Changes, DestRoot) ->
+    ParsedDestFile = filename:join(DestRoot, replace_content(Changes, DestFile)),
+    io:format("Creating file: ~p~n", [filename:basename(ParsedDestFile)]),
+    {ok, Mode} = file:read_file_info(SrcFile),
+    {ok, Bin} = file:read_file(SrcFile),
+    Contents = replace_content(Changes, binary_to_list(Bin)),
+    ok = file:write_file(ParsedDestFile, list_to_binary(Contents)),
+    file:write_file_info(ParsedDestFile, Mode).

+   
+   
 %% Internal Functions
 url_to_file(Dir, Url) ->
     Tokens = string:tokens(Url, "/"),
diff -u d:\development\erlang\nitrogen\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\src\project/nitrogen_project.erl src\project/nitrogen_project.erl
--- d:\development\erlang\nitrogen\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\rklophaus-nitrogen-19b6f15aecead6e0cb0d1de9317551bf1ef735ab\src\project/nitrogen_project.erl 2009-05-03 07:43:24 +1000
+++ src\project/nitrogen_project.erl    2009-09-20 18:04:58 +1000
@@ -38,13 +38,13 @@
 copy_template_files(Name, DestDir) ->
     Changes = [{"PROJECT", Name},{"PAGE", "web_index"}],
     FileList = [
-                { "priv/skel/Makefile", filename:join(DestDir, "Makefile")},
-                { "priv/skel/Emakefile", filename:join(DestDir, "Emakefile")},
-                { "priv/skel/template.html", filename:join(DestDir, "wwwroot/template.html")},
-                { "priv/skel/start.sh", filename:join(DestDir, "start.sh")},
-                { "priv/skel/PAGE.erl", filename:join(DestDir, "src/pages/web_index.erl")},
-                { "priv/skel/PROJECT.app", filename:join(DestDir, "ebin/PROJECT.app")},
-                { "priv/skel/PROJECT_app.erl", filename:join(DestDir, "src/PROJECT_app.erl")}
+                { "priv/skel/Makefile", "Makefile"},
+                { "priv/skel/Emakefile", "Emakefile"},
+                { "priv/skel/template.html", "wwwroot/template.html"},
+                { "priv/skel/start.sh", "start.sh"},
+                { "priv/skel/PAGE.erl", "src/pages/web_index.erl"},
+                { "priv/skel/PROJECT.app", "ebin/PROJECT.app"},
+                { "priv/skel/PROJECT_app.erl", "src/PROJECT_app.erl"}
                ],
-    [ nitrogen_file:copy_file(src_path(Src), Dest, Changes) || {Src,Dest} <- FileList ].
+    [ nitrogen_file:copy_file(src_path(Src), Dest, Changes, DestDir) || {Src,Dest} <- FileList ].

Adding custom library to nitrogen

I add custom library which used by my site src code. First add to apps list in reltool_base.config, than

make rel_cowboy

and than add my site folder.
Is this correct method for adding new libs to project or this could be done in more simple way?

make rel_inets fails

I wanted to follow the tutorial: http://nitrogenproject.com/doc/tutorial.html but the make rel_inets step fails.

Erlang R14B02 (erts-5.8.3)
OS: Linux (Ubuntu 11)

Message:

make[1]: Betrete Verzeichnis '/home/marco/Projects/nitrogen'
==> rel (generate)
ERROR: Unable to generate spec: read file info /usr/lib/erlang/man/man1/precat.1 failed
Copying /usr/lib/erlang/lib/erl_interface-3.7.3
escript: exception error: no match of right hand side value
{error,{1,
[99,112,58,32,107,97,110,110,32,86,101,114,122,101,
105,99,104,110,105,115,32,226,128,158,47,104,111,
109,101,47,109,97,114,99,111,47,80,114,111,106,101,
99,116,115,47|...]}}
make[1]: *** [rel_inner] Fehler 127

Can I support json request?

In python or ruby, I can make a response in the same controller code for json or html.

Can I do with the JSON request in nitrogen?
For example, the request is:
"/hello.json"
And I should make a response:
"{"hello"}"

"./dev page foo" no longer works

"./dev page foo" works as expected in Nitrogen 2.0.4 (git eb71ee...). Git versions since then don't work at all for me until 9a274a... at which point, once sync:go() is invoked either at the console or by "./dev compile", changes to index.erl are automatically noticed and compiled, but nothing else ever gets compiled at all.

Typo in rebar.config deps

Hello,

just a small fix:
in rebar, the following dep
{sync, "0.1.*", {git, "git://github.com/rklophaus/Sync", "HEAD"}}

must be changed to:
{sync, "0.1.*", {git, "git://github.com/rklophaus/sync", "HEAD"}}

Nitrogen Error on Startup

I'm getting an error when starting up bin/nitrogen console. It initially happenined on a project I was putting together, but it also happens with the default nitrogen project.

 =ERROR REPORT==== 5-Jun-2012::16:18:28 ===
 ERROR: "Failed to start: ~s~n" - [{case_clause,
                                                             {ok,[]}}]
 (no error logger present) error: "Error in process <0.102.0> with exit valu\"gen_event.erl\"},{line,219}]},{proc_lib,exit_p,2,[{file,\"proc_lib.erl\"}

Both files only seem to be present in .beam form, so I can't see what the errors in gen_event.erl and proc_lib.erl are.

I've tried doing a fresh clone of the nitrogen source and building it again, but the error persists. Did I accidentally change some piece of state that nitrogen depends on? It doesn't seem to have anything to do with Erlang itself, since systems other than nitrogen start up fine.

Testing System Thoughts

As I begin implementing the testing suite into my larger applications, I'm finding things that would come in handy:

  1. "Watching" for the creation of a DOM element as the trigger for a test, also possibly as the trigger that a test was successful
  2. Making it more "CT"-like, where instead of expecting a boolean return, it just expects a non-crash return
  3. Better handling changing pages while maintaining test state. It's a little finicky right now.

That's all for now, I'm sure this will expand as I have more thoughts.

erl Crash dump - Cannot allocate *** bytes of memory

root@devtool3:/usr/local/lib/erlang/lib/nitrogen-2.0.4# make rel_inets./rebar get-deps
==> nitrogen_core (get-deps)
==> nprocreg (get-deps)
==> simple_bridge (get-deps)
==> sync (get-deps)
==> rel (get-deps)
==> nitrogen-2.0.4 (get-deps)
./rebar compile
==> nitrogen_core (compile)
==> nprocreg (compile)
==> simple_bridge (compile)
==> sync (compile)
==> rel (compile)
==> nitrogen-2.0.4 (compile)
make[1]: Entering directory `/usr/local/lib/erlang/lib/nitrogen-2.0.4'
==> rel (generate)

Crash dump was written to: erl_crash.dump
eheap_alloc: Cannot allocate 2280657000 bytes of memory (of type "heap").
Aborted
make[1]: *** [rel_inner] Error 134
make[1]: Leaving directory `/usr/local/lib/erlang/lib/nitrogen-2.0.4'
make: *** [rel_inets] Error 2

Hello!
OS: Ubuntu 11.04 x64
Erl: R14B03
Before this error I have problem with .#dev file with is adviced to delete - I do it.
But then I can't build nitrogen with any size of memory - from 1Gb to 8Gb (I tested it 5 times).

Problems to generate a project with rebar 2.5.1

Hi Jesse,
I had problems with the master branch generating a project. The problem is related with the last version of rebar, because I changed to version 2.5.0 and it built successfully. This is the log, with the rebar_core error, I had with 2.5.1:

make[2]: Entering directory '/home/fooflare/workspace/repos/Nitrogen'
==> rel (generate)
Copying /usr/lib/erlang/lib/erl_interface-3.7.17
Generating "nitrogen/rebar.config"
make[3]: Entering directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
Using Erlang in /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/erts-6.1/bin/erl
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/cowboy to be an app dir (containing ebin/.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/ranch to be an app dir (containing ebin/
.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/mimetypes to be an app dir (containing ebin/.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/nitrogen_core to be an app dir (containing ebin/
.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/nprocreg to be an app dir (containing ebin/.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/simple_bridge to be an app dir (containing ebin/
.app), but no .app found.
WARN: Expected /home/fooflare/workspace/repos/Nitrogen/rel/nitrogen/lib/sync to be an app dir (containing ebin/.app), but no .app found.
Uncaught error in rebar_core: {'EXIT',
{{badmatch,{error,enoent}},
[{rebar_utils,otp_release1,1,
[{file,"src/rebar_utils.erl"},{line,391}]},
{rebar_utils,get_arch,0,
[{file,"src/rebar_utils.erl"},{line,92}]},
{rebar_port_compiler,default_env,0,
[{file,"src/rebar_port_compiler.erl"},
{line,574}]},
{rebar_port_compiler,setup_env,2,
[{file,"src/rebar_port_compiler.erl"},
{line,181}]},
{rebar_core,'-setup_envs/2-fun-0-',2,
[{file,"src/rebar_core.erl"},{line,522}]},
{lists,foldl,3,
[{file,"lists.erl"},{line,1261}]},
{rebar_core,maybe_execute,8,
[{file,"src/rebar_core.erl"},{line,293}]},
{rebar_core,process_dir1,7,
[{file,"src/rebar_core.erl"},{line,258}]}]}}
Makefile:13: recipe for target 'get-deps' failed
make[3]: *
* [get-deps] Error 1
make[3]: Leaving directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
make[3]: Entering directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
Generating a default cookie in /etc/vm.args
make[3]: Leaving directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
make[3]: Entering directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
cp: no se puede efectuar `stat' sobre «lib/nitrogen_core/www/»: No existe el fichero o el directorio
Makefile:19: recipe for target 'copy-static' failed
make[3]: *
* [copy-static] Error 1
make[3]: Leaving directory '/home/fooflare/workspace/repos/Nitrogen/rel/nitrogen'
Makefile:313: recipe for target 'rel_inner' failed
make[2]: *** [rel_inner] Error 2
make[2]: Leaving directory '/home/fooflare/workspace/repos/Nitrogen'
Makefile:203: recipe for target 'rel' failed
make[1]: *** [rel] Error 2
make[1]: Leaving directory '/home/fooflare/workspace/repos/Nitrogen'
Makefile:80: recipe for target 'rel_cowboy' failed
make: *** [rel_cowboy] Error 2

Thanks.

Upload errors go nowhere (missing postback)

If an upload results in an error (e.g. post_too_big) then that error is sent to the hidden iframe and no handling is possible.

An error should trigger a postback so the page can do something (e.g. ask for a smaller file).

starting nitrogen fails (Sabayon Linux)

I checked out nitrogen from the git repository and compiled with both versions R15B03 and R15B, in both situations I get the following error when starting nitrogen with
./bin/nitrogen console

Exec: /home/bart/Workspaces/nitrogen.git/rel/nitrogen/erts-5.9/bin/erlexec -boot /home/bart/Workspaces/nitrogen.git/rel/nitrogen/releases/2.1.0/nitrogen -embedded -config /home/bart/Workspaces/nitrogen.git/rel/nitrogen/etc/app.config -config /home/bart/Workspaces/nitrogen.git/rel/nitrogen/etc/inets.config -args_file /home/bart/Workspaces/nitrogen.git/rel/nitrogen/etc/vm.args -- console
Root: /home/bart/Workspaces/nitrogen.git/rel/nitrogen
(no error logger present) error: "Error in process <0.0.0> with exit value: {function_clause,[{init,prepare_run_args,[{eval,[<<27 bytes>>,<<1 byte>>]}],[]},{init,map,2,[]},{init,boot,1,[]}]}\n"

I use sabayon linux, the erlang version with the distribution is R15B03 the R15B I compiled myself.

Plugin System Autoimport CSS and/or Javascript?

Right now, the plugin system autoimports the Erlang headers from each Nitrogen plugin, and it does copy the static resources, but it would be nice if it was intelligent enough to make a javascript or CSS file similar in nature to the plugins.hrl - one that automatically imports the CSS and javascript files from each plugin without having to manually reference them in your template.

The gotcha here is load order. To specify:

  • The easy one for loading the right files in order is load them in alphabetical order, and then can be specified like (01-myfile.js, 02-otherfile.js, etc).
  • Alternatively, it could be specified in the nitrogen.plugin file as a config, which would specify the load order, and any file not mentioned would not be auto-imported. This has the benefit of not requiring renaming any files.

Food for thought!

Add the ability to name a generated release

By default, a generated release is called 'nitrogen', creates a directory called 'nitrogen', and uses a 'nitrogen.app.src' and all the other specifics. But it's more common that a user will want to create an app that uses nitrogen, not one that's necessarily named nitrogen. As such, being able to create a new project using something similar to rebar's or chicagoboss's approach with make rel_yaws PROJECT=myapp, which would properly name files and also ensure that one doesn't need to create a custom config handler for this.

Food for thought.

Nitrogen download files

Hello Jesse!

Just recently pulling new version of nitrogen. It works nice.

My issue is how to allow download a files over nitrogen. Is it possible initiate from the event handler?
Currently I found that I should set a header like this

wf:header("Content-Disposition", "attachment; filename=\"" ++ wf:qs("filename") ++ "\""),

but if i douing this in a page render functions I downloading current page with html tags or empty file.

Also i try manualy set response body with

wf_context:data({file,FileName}),

but this no effects.
I know that using {file, Path} in response data is not encouraged, but in my case this is definitly small files

Please add enabled property to #button

It seems like one currently has to mess with a script action to toggle enabled/disabled.

It should be straightforward to add a button that defaults to disabled (to only enable it once associated fields have some input).

Moving a slim release to a system with a different version of Erlang

Currently, if you move a generated slim release to a machine with a different version of Erlang, it will simply fail to start. The "easy" solution is to generate a release on the target machine and replace the contents of the "releases" directory.

This is a hack approach, however, there should be a more elegant solution. Ideally something like make fix-release or something.

Unable to specify rows, cols for text area

The #textarea record has no method to input rows and cols attributes causing nitrogen generated textarea html elements to fail W3C markup validation. Is there any way to set these attributes?

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.