Skip to content

Fixes #1129 - #1130

Closed
dmelikhov wants to merge 1 commit into
git:masterfrom
dmelikhov:master
Closed

dmelikhov wants to merge 1 commit into
git:masterfrom
dmelikhov:master

Conversation

@dmelikhov

Copy link
Copy Markdown

No description provided.

@pedrorijo91

Copy link
Copy Markdown
Member

Hey @Dibro89, thanks for doing this PR!

Have you tried to run it locally? I'm finding some issues:

  1. The template engine is not parsing correctly because you are now using js

image

  1. The download is not starting automatically at http://localhost:3000/download/win

I still hadn't the time to look through the code, will try to do it ASAP, but it seems we have some tweaks to do to make it work as before at least

@download = @download64
@bitness = "64-bit"
else
@download = @download32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these download and bitness variables are passed to the template. Since they are not defined now, we see the (#{@download32.version.name}) in the rendered page.

@dmelikhov dmelikhov Feb 2, 2018 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using download and bitness ruby variables in the template anymore.
You are seeing this because I don't know how to properly inject ruby variables into JS-code blocks. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't dig enough to be sure about this, but don't we need the download variable to start the download variable automatically? (I'll find sometime today to have a deeper look on this)

@dmelikhov dmelikhov Feb 3, 2018 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrorijo91 Before you were detecting 'bitness' and the correct version to download on the server side, but I've changed it in a way so everything now depends on the client side. You can take a look at another file in the commit and see how it is should work now. Download link is also detected on the client side and then placed in an iframe as before.

@dmelikhov

dmelikhov commented Feb 2, 2018 •

Copy link
Copy Markdown
Author

@pedrorijo91 Sorry, I'm not really good with Ruby.
I've hoped it would replace variables in JS-script blocks as it does it in HTML.
How should I write them so they will be interpolated by Ruby?

@pedrorijo91

Copy link
Copy Markdown
Member

no worries @Dibro89 :)

I'm not sure how to inject js variables too (not sure if possible at all). But you can simply add a <span id='some-variable'></span> and inject the text in js no?

@dmelikhov

dmelikhov commented Feb 3, 2018 •

Copy link
Copy Markdown
Author

@pedrorijo91 The text is already injecting from JS into HTML, but we also need to inject it into JS.
Please look at /app/controllers/downloads_controller.rb in the commit

@dmelikhov

Copy link
Copy Markdown
Author

@pedrorijo91 Please, try after this commit.

@pedrorijo91

Copy link
Copy Markdown
Member

Did you updated the PR @Dibro89 ? maybe you forgot to push?

@dmelikhov

Copy link
Copy Markdown
Author

@pedrorijo91 I did, but I've also squashed some commits, I thought you will be able to pull.

@pedrorijo91

Copy link
Copy Markdown
Member

If you don't push your commits I can't pull them @Dibro89, or am I missing something? As you can see, this PR only contains the commit you did yesterday

@dmelikhov

Copy link
Copy Markdown
Author

@pedrorijo91 I've pushed a second commit after it and then squashed them with the name of first. You can look at the date - 7 hours from now. Just re-clone the repo please.

@pedrorijo91

Copy link
Copy Markdown
Member

there's something weird going on...where are you seeing 7 hours from now? I see 1 day ago

image

image

@dmelikhov

dmelikhov commented Feb 3, 2018 •

Copy link
Copy Markdown
Author

In history I have the same, true. But in the conversation I can see this:
image
Also there's a new reference in the issue... at the end

@pedrorijo91 pedrorijo91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be working just fine :) thanks for the effort! just some comments, let me know your thoughts

var download_url = '<%= @download32.url %>';
}

document.write(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on js, but from what I know, document.write is not recommended, and other approaches such DOM manipulation are preferred.

https://stackoverflow.com/questions/4537963/what-are-alternatives-to-document-write

If you have a good argument for using document.write (if you have a nice experience in JS and are sure about this), let us know, and I won't oppose :)

@dmelikhov dmelikhov Feb 3, 2018 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm definitely not an expert too. :)
But I suppose if we use DOM-manipulation - it can create a slight (maybe even not noticeable) delay.
And I don't see any reason why we should not use document.write(...) there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think the delay would be noticeable since it's just a small piece of logic. And having placeholders on the DOM + moving this code into a .js file, seems a cleaner approach than having these <script> tags in the middle of the HTML.

since the issue is already fixed by the new cache rule (#1129 (comment)), I would prefer to have the clean approach.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Dibro89, are you interested in trying the other approach? Otherwise I may try it by myself so that we can compare :)

<p>
<%= raw "<strong>If your download hasn't started, <a href=\"#{@download.url}\">click here to download manually</a>.</strong>" %>
</p>
<script>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this script into some .js file? there's a app/assets/javascripts/site.js with most of the javascript used in this app

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can't because it is injecting HTML just in time and it is not possible if we move the script somewhere else.
But if you want to manipulate DOM – we can move it.

<%= raw "The current source code release is version <strong>#{@latest.name}</strong>. If you want the newer version, you can build it from <a href=\"#{@source_url}\">the source code</a>." %>
</p>
<iframe frameborder="0" height="1" src="<%= @download.url %>" width="1"></iframe>
<script>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this script

@pedrorijo91

Copy link
Copy Markdown
Member

the issue is solved, will postpone this change for #1143

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.

2 participants