Comments (11)
mime types are not related to dtl and templates i think.
check you mimetypes application running, check the cowboy dispatch rules configuration...
need more info about what you are trying to do to know what is wrong :)
from n2o.
Originally it was your example/template of n2o-application named 'skyline'.
For example let's take a look on login page.
main() ->
[#dtl{file="login", ext="dtl", bindings=[
{title,<<"My Title">>},
{form, form()},
{body, body()}
]}
].
If I use your prod.dtl as template all works fine. If I set newly created login.dtl mime type is broken. I did not any changes to cowboy dispatch rules and I do not know where is it.
from n2o.
Ok, I find in web_sup.erl dispatch_rules() but I did not change it.
dispatch_rules() ->
cowboy_router:compile(
[{'', [
{"/static/[...]", cowboy_static, [{directory, {priv_dir, ?APP, [<<"static">>]}},
{mimetypes, {fun mimetypes:path_to_mimes/2, default}}]},
{"/rest/:bucket", n2o_rest, []},
{"/rest/:bucket/:key", n2o_rest, []},
{"/rest/:bucket/:key/[...]", n2o_rest, []},
{"/ws/[...]", bullet_handler, [{handler, n2o_bullet}]},
{'', n2o_cowboy, []}
]}]).
from n2o.
Если я пропатчу wf_core:run() вот так:
Req2 = wf:response(Html,Ctx2#context.req),
Req3 = wf:header(<<"Content-Type">>,<<"text/html; charset=utf-8">>,Req2),
{ok, _ReqFinal} = wf:reply(200, Req3).
То, mime насильно устанавливается в text/html, то переменная transition не появляется в рамках выполнения js в броузере.
from n2o.
Нашел в полученной странице следующий код:
var transition = {pid: 'g2gCZ2QAEXNreWxpbmVAMTI3LjAuMC4xAAAFPQAAAAABaANiAAAFdGIACWrzYgAEt9s=', port:'8000'}
Одной проблемой меньше, но mime кроме грязного хака я не знаю как починить. :(from n2o.
Я не наблюдаю установку mime type.
Request URL:http://localhost:8000/
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:CGISESSID=d7576982f0032b7951a886f5ed09880f; n2o-sid=+ikgHbIPalYudCMZrH1Leg==
Host:localhost:8000
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Response Headers
HTTP/1.1 200 OK
connection: keep-alive
server: Cowboy
date: Fri, 04 Apr 2014 14:59:28 GMT
content-length: 6390
set-cookie: n2o-sid=+ikgHbIPalYudCMZrH1Leg==; Version=1; Expires=Sat, 05-Apr-2014 14:59:29 GMT; Max-Age=86400; Path=/
И еще: заменил login.dtl на prod.dtl и mime заработал.
А если в prod.dtl поменять содержимое на login.dtl, то mime опять ломается.
Вывод, какая-то привязка к чему-то в самом тексте шаблона.
from n2o.
проверил у себя, все таки оно автоматически определяет mime type, все что это внутри < html >< /html > должно быть text\html автоматически.
как это все натюнить, смотри в настройках приложения mimetypes и провайдь конфигурацию, там настроек на все случаи жизни.
from n2o.
Можешь показать свой конфиг ?
from n2o.
у меня девалтный конфиг. твой новый шаблон содержит html? можешь дать мне этот шаблон?
from n2o.
Улетело почтой.
from n2o.
Н-да. Причина оказалась в BOM:
The byte order mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. It is encoded at U+FEFF byte order mark (BOM). BOM use is optional, and, if used, should appear at the start of the text stream.
Куда наливать ?
from n2o.
Related Issues (20)
- Fire event on keypress/keydown HOT 4
- Apps couldn't be loaded: [kvs,mnesia] HOT 2
- question - Machine specs for the wrk benchmark? HOT 1
- n20 book link is broken on readme
- no function clause matching lists:flatten HOT 1
- no function clause matching lists:flatten HOT 5
- Change ws.send to wsn.send in all JS and NITRO renderers HOT 1
- bert.js int_to_bytes("true") causes node/v8 to crash
- bert.js decode error on the server: badarg HOT 1
- call to an undefined module ? HOT 1
- Автор наркоман HOT 1
- xhr.js has been deleted HOT 2
- Fails on basic setup HOT 1
- N2O to support latest Cowboy 2.x HOT 6
- Update n2o_mqtt to support EMQ X 3.x
- Adjust n2o_ring:send for IoT project
- Support TCP Connections
- n2o crash at startup: HOT 5
- from or form in record #cx ? HOT 4
- There is no samples folder inside n2o HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from n2o.