Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instruction on how to visit HTML document from browser #62

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yubrshen
Copy link

@yubrshen yubrshen commented Nov 5, 2015

It took me 45 minutes by googling to figure out how to actually do "Visit the document from your browser" as a new user. So I feel that the time can be saved by adding the instruction of how to in README.md:
+1. (setq httpd-root "~/web-page-making") web-page-making is the directory where the HTML document to be visited is.
+2. At your browser's URL field enter: http://127.0.0.1:8080/index.html 8080 is the value of httpd-port and index.html is the HTML document name.

@johnmastro
Copy link

Just as a pointer (not really related to the substance of the pull request), you could use a convenience function along these lines to browse the file the current buffer is visiting. It's untested, and there are lots of things about it you might want to change, but maybe it will be useful nonetheless.

(defun browse-this-file (file)
  (interactive (list (buffer-file-name)))
  (unless (and file (file-exists-p file))
    (error "File does not exist: ‘%s" file))
  (unless (process-status "httpd")
    (httpd-start))
  (let ((name (file-name-nondirectory file))
        (httpd-root (file-name-directory file)))
    (browse-url (format "http://127.0.0.1:%s/%s" httpd-port name))))

@khalidchawtany
Copy link

When I first tried skweer-mode, I looked everywhere to find a solution as to why HTML part was not working. I watched tuts on youtube and looked in the docs yet found no solution.
I wish this was available back then 👍

I cannot remember which tutorial pointed out that httpd-root must be set properly.

@yubrshen
Copy link
Author

yubrshen commented Nov 6, 2015

I still couldn't drive web browser from emacs with skewer-load-buffer,
although manually I could load the HTML document at
localhost:8080/index.html. I suspect that I'm using web-mode, not
html-mode.

I'll study your suggestion above.

Thanks for replying.!

Yu

On Fri, Nov 6, 2015 at 8:37 AM, John Mastro notifications@github.com
wrote:

Just as a pointer (not really related to the substance of the pull
request), you could use a convenience function along these lines to browse
the current file in your browser. It's untested and there are lots of
things you might want to change about it but maybe it will be useful
nonetheless.

(defun browse-this-file (file)
(interactive (list (buffer-file-name)))
(unless (and file (file-exists-p file))
(error "File does not exist: ‘%s’" file))
(unless (process-status "httpd")
(httpd-start))
(let ((name (file-name-nondirectory file))
(httpd-root (file-name-directory file)))
(browse-url (format "http://127.0.0.1:%s/%s" httpd-port name))))


Reply to this email directly or view it on GitHub
#62 (comment).

@skeeto
Copy link
Owner

skeeto commented Nov 6, 2015

I don't really want to recommend users use the underlying simple-httpd server for hosting their page. It's both unnecessary and insufficient.

It's unnecessary because your document can be hosted anywhere, including directly from your filesystem, no server needed. You can even Skewer websites you don't control (though this is becoming less possible as more security controls are being put into place on the web). For example, create hello.html in your home directory, add this element to the head,

<script src="http://localhost:8080/skewer"></script>

And open the HTML file (e.g. file://...) in your browser while Skewer is active in Emacs. That's it. This is explained step-by-step in the "Manual version" section of the README.

I say it's insufficient because you really shouldn't be using simple-httpd as your production host, especially not if it's connected to the Internet. Emacs isn't secure enough for that. So just use whatever platform you intend to use for actual hosting.

Since you were stuck for 45 minutes, may I ask what was unclear in the README under "Manual version" at "To skewer your own document"? That's where I intended to cover this exact information.

@yubrshen
Copy link
Author

yubrshen commented Nov 7, 2015

Hi Christopher,

Thanks for addressing my problems!

My pull request was due to the fact that I was and is not able to see the
modification to HTML document reflected in the browser.

I did the following procedure:

  1. Load skewer-mode.el
  2. Start the HTTP server (httpd-start)
  3. Include "http://localhost:8080/skewer" as a script (see example.html
    and check your httpd-port)
  4. Visit the document from your browser (by the
    expression: file:///D:/download/hello.html)
  5. Manually Mx skewer-mode and Mx skewer-html-mode
  6. Modify hello.html and save the buffer
  7. Mx skewer-load-buffer

I expected to see the effects of the edit. But I didn't see it. Only until
I manually reload the page, then I see it.

I did not do the following as I don't know what to do:

  1. Load the dependencies

I did see any complaints of lack of dependencies though.

As I had the problem of seeing the effect, so I thought that I might need
more elaborate way of loading the HTML document, but it still didn't work.

Now, I understand that my pull request is due to misunderstanding. It's no
longer needed. But it would be helpful to provide more detailed information
on how to load the dependencies,
and the way to load the page with file:///D:/download/hello-word.html for
example.

I'm running with emacs Prelude in Windows 7. For HTML, it ran with
web-mode. (I'm not sure if this an issue, it's not the html-mode that you
mentioned in README.
I even tried to manually use html-mode and skewer-html-mode, and still Mx
skewer-load-buffer still has no effect.)

Please let me know any other information needed, and how I can debug my
problem.

Thanks again!

Yu

On Sat, Nov 7, 2015 at 6:36 AM, Christopher Wellons <
notifications@github.com> wrote:

I don't really want to recommend users use the underlying simple-httpd
server for hosting their page. It's both unnecessary and insufficient.

It's unnecessary because your document can be hosted anywhere, including
directly from your filesystem, no server needed. You can even Skewer
websites you don't control (though this is becoming less possible as more
security controls are being put into place on the web). For example, create
hello.html in your home directory, add this element to the head,

<script src="http://localhost:8080/skewer"></script>

And open the HTML file (e.g. file://...) in your browser while Skewer is
active in Emacs. That's it. This is explained step-by-step in the "Manual
version" section of the README.

I say it's insufficient because you really shouldn't be using
simple-httpd as your production host, especially not if it's connected to
the Internet. Emacs isn't secure enough for that. So just use whatever
platform you intend to use for actual hosting.

Since you were stuck for 45 minutes, may I ask what was unclear in the
README under "Manual version" at "To skewer your own document"? That's
where I intended to cover this exact information.


Reply to this email directly or view it on GitHub
#62 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants