Giter Club home page Giter Club logo

Comments (11)

doxtop avatar doxtop commented on May 22, 2024

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.

radetsky avatar radetsky commented on May 22, 2024

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.

radetsky avatar radetsky commented on May 22, 2024

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.

radetsky avatar radetsky commented on May 22, 2024

Если я пропатчу 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.

radetsky avatar radetsky commented on May 22, 2024

Нашел в полученной странице следующий код:

var transition = {pid: 'g2gCZ2QAEXNreWxpbmVAMTI3LjAuMC4xAAAFPQAAAAABaANiAAAFdGIACWrzYgAEt9s=', port:'8000'} Одной проблемой меньше, но mime кроме грязного хака я не знаю как починить. :(

from n2o.

radetsky avatar radetsky commented on May 22, 2024

Я не наблюдаю установку 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.

doxtop avatar doxtop commented on May 22, 2024

проверил у себя, все таки оно автоматически определяет mime type, все что это внутри < html >< /html > должно быть text\html автоматически.
как это все натюнить, смотри в настройках приложения mimetypes и провайдь конфигурацию, там настроек на все случаи жизни.

from n2o.

radetsky avatar radetsky commented on May 22, 2024

Можешь показать свой конфиг ?

from n2o.

doxtop avatar doxtop commented on May 22, 2024

у меня девалтный конфиг. твой новый шаблон содержит html? можешь дать мне этот шаблон?

from n2o.

radetsky avatar radetsky commented on May 22, 2024

Улетело почтой.

from n2o.

radetsky avatar radetsky commented on May 22, 2024

Н-да. Причина оказалась в 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)

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.