JuliaGizmos / Escher.jl

Composable Web UIs in Julia
https://juliagizmos.github.io/Escher.jl
Other
335 stars 63 forks source link

Broken example in docs/index.jl #91

Closed astrieanna closed 8 years ago

astrieanna commented 8 years ago

I'm trying to go through the tutorial on escher-jl.org, but I keep running into examples that won't run. I'm currently having trouble with Pattern 2, Example 1. At first, it wouldn't work because it couldn't find pad, which is in Compose (which is not imported in the text of the example). Even with the added using, it still presents an error message -- one that I'm not sure how to resolve.

Code with added using:

using Compose

function main(window)
    push!(window.assets, "tex")

    txt = tex("T = 2\\pi\\sqrt{L\\over g}")
    txt1 = fontcolor("#499", txt)
    txt2 = pad(5mm, txt1)
    txt3 = fillcolor("#eeb", txt2)

    vbox(txt, txt1, txt2, txt3)
end

Error message (from the terminal; webpage is blank):

Error handling websocket connection:
MethodError: `length` has no method matching length(::Patchwork.Elem{:xhtml,symbol("ka-tex")})
 in convert at /Users/leah/.julia/v0.4/Patchwork/src/Patchwork.jl:53
 in call at /Users/leah/.julia/v0.4/Patchwork/src/Patchwork.jl:74
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/layout.jl:462
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/layout.jl:471
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/tile.jl:89
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/layout.jl:290
 in start_updates at /Users/leah/.julia/v0.4/Escher/src/cli/serve.jl:114
 in anonymous at /Users/leah/.julia/v0.4/Escher/src/cli/serve.jl:180
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:15
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in splitquery at /Users/leah/.julia/v0.4/Mux/src/basics.jl:28
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in wcatch at /Users/leah/.julia/v0.4/Mux/src/websockets_integration.jl:12
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in todict at /Users/leah/.julia/v0.4/Mux/src/basics.jl:21
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:12 (repeats 2 times)
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/server.jl:38
 in handle at /Users/leah/.julia/v0.4/WebSockets/src/WebSockets.jl:354
 in on_message_complete at /Users/leah/.julia/v0.4/HttpServer/src/HttpServer.jl:393
 in on_message_complete at /Users/leah/.julia/v0.4/HttpServer/src/RequestParser.jl:104
 in http_parser_execute at /Users/leah/.julia/v0.4/HttpParser/src/HttpParser.jl:92
 in process_client at /Users/leah/.julia/v0.4/HttpServer/src/HttpServer.jl:365
 in anonymous at task.jl:448
astrieanna commented 8 years ago

This error message about length missing a method is also reproducible with:

using Compose

function main(window)
    txt = tex("T = 2\\pi\\sqrt{L\\over g}")
    fillcolor("#eeb", fontcolor("#499", pad(5mm, txt)))
end
rohitvarkey commented 8 years ago

pad is an Escher function also. Removing using Compose should get it to work.

I can't reproduce the error on Escher master (after removing using Compose). Also I'm not sure why pad wasn't' found. It has been exported by Escher. https://github.com/shashi/Escher.jl/blob/f3d8ab2fc732d1f40ff6be9f08e0f619fd3b17ee/src/basics/layout.jl#L54

astrieanna commented 8 years ago

Have you tried it with the tagged version of Escher/Compose?

On Sat, Sep 19, 2015 at 9:38 PM, Rohit Varkey Thankachan < notifications@github.com> wrote:

pad is an Escher function also. Removing using Compose should get it to work.

I can't reproduce the error on Escher master (after removing using Compose). Also I'm not sure why pad wasn't' found. It has been exported by Escher. https://github.com/shashi/Escher.jl/blob/f3d8ab2fc732d1f40ff6be9f08e0f619fd3b17ee/src/basics/layout.jl#L54

— Reply to this email directly or view it on GitHub https://github.com/shashi/Escher.jl/issues/91#issuecomment-141748127.

rohitvarkey commented 8 years ago

Just did. Works fine.

astrieanna commented 8 years ago

I removed the using Compose; after updating my packages that doesn't seem to be required. I'm still seeing the length problem.

I run escher --serve in the directory with my Julia file (hello.jl), and try to load http://localhost:5555/hello.jl. I get an error in the terminal and a blank webpage.

My code:

function main(window)
    txt = tex("T = 2\\pi\\sqrt{L\\over g}")
    fillcolor("#eeb", fontcolor("#499", pad(5mm, txt)))
end

The error in the terminal:

Error handling websocket connection:
MethodError: `length` has no method matching length(::Patchwork.Elem{:xhtml,symbol("ka-tex")})
 in convert at /Users/leah/.julia/v0.4/Patchwork/src/Patchwork.jl:53
 in call at /Users/leah/.julia/v0.4/Patchwork/src/Patchwork.jl:74
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/layout.jl:401
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/layout.jl:410
 in wrapmany at /Users/leah/.julia/v0.4/Escher/src/basics/util.jl:51
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/typography.jl:116
 in render at /Users/leah/.julia/v0.4/Escher/src/basics/embellishment.jl:126
 in start_updates at /Users/leah/.julia/v0.4/Escher/src/cli/serve.jl:116
 in anonymous at /Users/leah/.julia/v0.4/Escher/src/cli/serve.jl:180
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:15
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in splitquery at /Users/leah/.julia/v0.4/Mux/src/basics.jl:28
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in wcatch at /Users/leah/.julia/v0.4/Mux/src/websockets_integration.jl:12
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in todict at /Users/leah/.julia/v0.4/Mux/src/basics.jl:21
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:12 (repeats 2 times)
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/Mux.jl:8
 in anonymous at /Users/leah/.julia/v0.4/Mux/src/server.jl:38
 in handle at /Users/leah/.julia/v0.4/WebSockets/src/WebSockets.jl:354
 in on_message_complete at /Users/leah/.julia/v0.4/HttpServer/src/HttpServer.jl:393
 in on_message_complete at /Users/leah/.julia/v0.4/HttpServer/src/RequestParser.jl:104
 in http_parser_execute at /Users/leah/.julia/v0.4/HttpParser/src/HttpParser.jl:92
 in process_client at /Users/leah/.julia/v0.4/HttpServer/src/HttpServer.jl:365
 in anonymous at task.jl:448

My package versions:

$ julia -e "Pkg.status()"
6 required packages:
 - Escher                        0.1.0
 - Gadfly                        0.3.16
 - HDF5                          0.5.5
 - Homebrew                      0.1.16
 - Jewel                         1.0.6
 - MbedTLS                       0.1.3
61 additional packages:
 - ArgParse                      0.2.12
 - ArrayViews                    0.6.4
 - Benchmark                     0.1.0
 - BinDeps                       0.3.17
 - Blosc                         0.1.4
 - Calculus                      0.1.10
 - Codecs                        0.1.4
 - Color                         0.4.8
 - ColorTypes                    0.1.4
 - Colors                        0.5.3
 - Compat                        0.7.2
 - Compose                       0.3.15
 - Contour                       0.0.7
 - DataArrays                    0.2.18
 - DataFrames                    0.6.9
 - DataStructures                0.3.13
 - Dates                         0.4.4
 - Distances                     0.2.0
 - Distributions                 0.8.6
 - Docile                        0.5.19
 - DualNumbers                   0.1.3
 - FactCheck                     0.4.0
 - FixedPointNumbers             0.0.10
 - FunctionalCollections         0.1.2
 - GZip                          0.2.18
 - Graphics                      0.1.3
 - Grid                          0.3.11
 - Hexagons                      0.0.4
 - Hiccup                        0.0.1
 - HttpCommon                    0.2.3
 - HttpParser                    0.1.0
 - HttpServer                    0.1.3
 - ImmutableArrays               0.0.10
 - Iterators                     0.1.9
 - JSON                          0.4.6
 - JuliaParser                   0.6.3
 - KernelDensity                 0.1.1
 - LNR                           0.0.1
 - Lazy                          0.10.0
 - Loess                         0.0.4
 - MacroTools                    0.2.0
 - Markdown                      0.3.0
 - Mux                           0.1.0
 - NaNMath                       0.1.0
 - Nettle                        0.1.10
 - Optim                         0.4.2
 - Options                       0.2.4
 - PDMats                        0.3.5
 - Patchwork                     0.1.7
 - Reactive                      0.2.2
 - Reexport                      0.0.3
 - Requires                      0.2.0
 - SHA                           0.1.2
 - Showoff                       0.0.5
 - SortingAlgorithms             0.0.6
 - StatsBase                     0.7.2
 - StatsFuns                     0.1.3
 - TextWrap                      0.1.4
 - URIParser                     0.1.0
 - WebSockets                    0.1.0
 - WoodburyMatrices              0.1.2
shashi commented 8 years ago

@astrieanna the last bug is because of https://github.com/shashi/Patchwork.jl/pull/9, now fixed in Patchwork - I'm tagging a release of Patchwork and Escher right now. Sorry for all the trouble.

A better way to resolve the pad issue is to use Escher.pad instead.

shashi commented 8 years ago

https://github.com/one-more-minute/Requires.jl/issues/11 breaks a ton of stuff right now.

shashi commented 8 years ago

Tagged!