theforumhelpers.github.io icon indicating copy to clipboard operation
theforumhelpers.github.io copied to clipboard

Feature Request: use relative urls

Open jeffalo opened this issue 4 years ago β€’ 27 comments
trafficstars

looking through the source code, there are so many places where stuff points to theforumhelpers.github.io. this makes development tedious. why not just use relative urls like

fetch("/forumhelpers/"+dataSet+".json")

instead of

fetch("https://theforumhelpers.github.io/forumhelpers/"+dataSet+".json")

another example of this was in #152 where some obscure <base> element was used when it could have just been as simple as adding a slash before the paths. like <link rel="stylesheet" type="text/css" href="/resources/stylesheet.css"> instead of <link rel="stylesheet" type="text/css" href="resources/stylesheet.css">

is there a specific development reason not to? this will allow development to be so much easier.

jeffalo avatar May 10 '21 15:05 jeffalo

I tried to fix that, but Firefox denied the CORS request because "it was not https". πŸ˜• Idk why your own filesystem would be blocked from using fetch, but oh well.

gosoccerboy5 avatar May 10 '21 15:05 gosoccerboy5

I tried to fix that, but Firefox denied the CORS request because "it was not https". πŸ˜• Idk why your own filesystem would be blocked from using fetch.

are you running stuff as a file url (aka double clicking a html file)? there are security reasons browsers do this to prevent html files from being malicious.

jeffalo avatar May 10 '21 15:05 jeffalo

I tried to fix that, but Firefox denied the CORS request because "it was not https". πŸ˜• Idk why your own filesystem would be blocked from using fetch.

are you running stuff as a file url (aka double clicking a html file)? there are security reasons browsers do this to prevent html files from being malicious.

Yea, just opening it from vscode with the "open in browser" extension. Why, is there some way I can work around the fetch being blocked?

gosoccerboy5 avatar May 10 '21 15:05 gosoccerboy5

Yea, just opening it from vscode with the "open in browser" extension. Why, is there some way I can work around the fetch being blocked?

theres probably some browser option for it.. but why not run in a proper localhost development server? heres mine it tries to simulate github pages.

jeffalo avatar May 10 '21 15:05 jeffalo

looking through the source code, there are so many places where stuff points to theforumhelpers.github.io. this makes development tedious. why not just use relative urls like

fetch("/forumhelpers/"+dataSet+".json")

instead of

fetch("https://theforumhelpers.github.io/forumhelpers/"+dataSet+".json")

This is because fetch requests cannot be performed to a local file. Therefore, there would be no way to test the page locally without adding some hard coded data for it to display. Therefore, it is better that it pulls the current live data so that the page actually displays with people on it.

another example of this was in #152 where some obscure <base> element was used when it could have just been as simple as adding a slash before the paths. like <link rel="stylesheet" type="text/css" href="/resources/stylesheet.css"> instead of <link rel="stylesheet" type="text/css" href="resources/stylesheet.css">

is there a specific development reason not to? this will allow development to be so much easier.

This is because adding a slash would work on the site, but not locally. For example, on Windows, using a slash would redirect to C:/

Both of these changes are actually designed to make development easier, not more difficult. If you have any suggestions about how this could be worked around while still using relative URLS, feel free to share them!

Accio1 avatar May 10 '21 15:05 Accio1

This is because adding a slash would work on the site, but not locally. For example, on Windows, using a slash would redirect to C:/

@Accio1 @jeffalo You know for the links and the whole C:/ or file:// thing you could simply replace the code in the header with this:

function reference(link) {
	const headerContent = `
	<a href="./" target="_parent">
		<img src="./resources/icon.png" width="64px" height="64px" class="nav_homeicon">
	</a>
	<h1 class="nav_title">The Forum Helpers</h1>
	<a href="./forumhelpers/index.html" class="nav_button" target="_parent">List Of Forum Helpers</a>
	<a href="https://scratch.mit.edu/studios/3688309/" class="nav_button" target="_blank">Our Scratch Studio</a>
	<a href="https://theforumhelpers.github.io/QuickReply/" class="nav_button" target="_parent">QuickReply</a>

	<div class="expandableDropdown">
		<a class="expandableLink" href="${link}forumhelpers">List Of Forum Helpers</a>
		<a class="expandableLink" href="https://scratch.mit.edu/studios/3688309/">Our Scratch Studio</a>
		<a class="expandableLink" href="https://theforumhelpers.github.io/QuickReply/">QuickReply</a>
	</div>
	document.getElementById("header").innerHTML = headerContent;

	const footerContent = 
	<div class="footer_content">
			<a href="./contributors/index.html" class="FHULink" target="_parent">Contributors</a>
			<br>
			<a href="https://github.com/theforumhelpers/theforumhelpers.github.io" class="FHULink" target="_parent">Github Repository</a>
			<br>
			Be moist <img src="https://cdn.scratch.mit.edu/scratchr2/static/__4f1f321e080ee4987f163566ecc0dd26__/djangobb_forum/img/smilies/cool.png">
	</div>
	document.getElementById("footer").innerHTML = footerContent;
}

(Changes all links to ./folder/index.html)

The <base> wouldn't be necessary.

leahcimto avatar May 10 '21 22:05 leahcimto

This is because adding a slash would work on the site, but not locally. For example, on Windows, using a slash would redirect to C:/

@Accio1 @jeffalo You know for the links and the whole C:/ or file:// thing you could simply replace the code in the header with this:

function reference(link) {
	const headerContent = `
	<a href="./" target="_parent">
		<img src="./resources/icon.png" width="64px" height="64px" class="nav_homeicon">
	</a>
	<h1 class="nav_title">The Forum Helpers</h1>
	<a href="./forumhelpers/index.html" class="nav_button" target="_parent">List Of Forum Helpers</a>
	<a href="https://scratch.mit.edu/studios/3688309/" class="nav_button" target="_blank">Our Scratch Studio</a>
	<a href="https://theforumhelpers.github.io/QuickReply/" class="nav_button" target="_parent">QuickReply</a>

	<div class="expandableDropdown">
		<a class="expandableLink" href="${link}forumhelpers">List Of Forum Helpers</a>
		<a class="expandableLink" href="https://scratch.mit.edu/studios/3688309/">Our Scratch Studio</a>
		<a class="expandableLink" href="https://theforumhelpers.github.io/QuickReply/">QuickReply</a>
	</div>
	document.getElementById("header").innerHTML = headerContent;

	const footerContent = 
	<div class="footer_content">
			<a href="./contributors/index.html" class="FHULink" target="_parent">Contributors</a>
			<br>
			<a href="https://github.com/theforumhelpers/theforumhelpers.github.io" class="FHULink" target="_parent">Github Repository</a>
			<br>
			Be moist <img src="https://cdn.scratch.mit.edu/scratchr2/static/__4f1f321e080ee4987f163566ecc0dd26__/djangobb_forum/img/smilies/cool.png">
	</div>
	document.getElementById("footer").innerHTML = footerContent;
}

(Changes all links to ./folder/index.html)

The wouldn't be necessary.

@leahcimto feel free to submit a fix for this!

Accio1 avatar May 11 '21 22:05 Accio1

@Accio1 Working on it now

leahcimto avatar May 11 '21 23:05 leahcimto

Sorry for the delay, I hope to have it done soon.

leahcimto avatar May 16 '21 11:05 leahcimto

Sorry for the delay, I hope to have it done soon.

All good! No rush

Accio1 avatar May 16 '21 13:05 Accio1

I'm going to un-assign me since I'm a bit busy at the moment and don't want to hold this up. I also am having some trouble with it.

leahcimto avatar May 21 '21 20:05 leahcimto

@Accio1 can i pls be assigned

Shluffy avatar Jun 13 '21 18:06 Shluffy

@Shluffy how would you plan to implement this?

Accio1 avatar Jun 13 '21 18:06 Accio1

@Shluffy how would you plan to implement this?

use / rather then the github things in certain cases. I could make a mock-up

Shluffy avatar Jun 13 '21 18:06 Shluffy

@Shluffy how would you plan to implement this?

use / rather then the github things in certain cases. I could make a mock-up

Using / won't work. That means anyone developing locally will have the relative URLS link to the root of their filesystem. Any changes made have to work both locally and on the actual site.

Accio1 avatar Jun 13 '21 20:06 Accio1

@Accio1 Is there a known easy way to do this?

(I think I know how to do it albeit not in a straightforward way)

BarelySmooth avatar Jun 17 '21 03:06 BarelySmooth

@Accio1 Is there a known easy way to do this?

(I think I know how to do it albeit not in a straightforward way)

Not that I can think of

gosoccerboy5 avatar Jun 17 '21 13:06 gosoccerboy5

@Accio1 Is there a known easy way to do this? (I think I know how to do it albeit not in a straightforward way)

Not that I can think of

If no such solution exists, then @Accio1, can I try reloving it?

BarelySmooth avatar Jun 17 '21 13:06 BarelySmooth

@Accio1 Is there a known easy way to do this? (I think I know how to do it albeit not in a straightforward way)

Not that I can think of

If no such solution exists, then @Accio1, can I try reloving it?

@BarelySmooth what solution do you have in mind?

Accio1 avatar Jun 17 '21 13:06 Accio1

@Accio1 Use Javascript to add the β€œhref” attribute to the tag. We can use javascript code to determine what should go in there.

BarelySmooth avatar Jun 21 '21 08:06 BarelySmooth

@Accio1 bump? (so that you get notified...)

BarelySmooth avatar Jun 27 '21 18:06 BarelySmooth

@BarelySmooth feel free to submit a PR. I am interested to see how you implement your solution.

Accio1 avatar Jun 27 '21 20:06 Accio1

i'm not sure why you want to make sure the basic HTML files will continue to work. it seems like too much inconvinence for very little reward.

https://stackoverflow.com/questions/40204913/difference-between-localhost-and-opening-html-file

they explain that it's best to match your production environment (github pages). there's so many static file server plugins for many editors, it doesn't make sense to continue supporting opening the file in a web browser unless for some reason notepad is the best code editor people have.

if it's that a local development server is too complicated for new contributers, you could add something to the readme on how to use something like repl.it to edit the site.

i'd say that all the hacks you have to come up with for the files to work in a browser make it much harder to develop, not easier.

jeffalo avatar Jun 28 '21 08:06 jeffalo

I'll like to note that filesystems shouldn't support 404.html files. Also, can I be assigned?

FunctionalMetatable avatar Sep 17 '21 17:09 FunctionalMetatable

@FunctionalMetatable I've assigned you. Feel free to build off @BarelySmooth's code in #260

Accio1 avatar Sep 17 '21 18:09 Accio1

there's so many static file server plugins for many editors

There's also some static file servers that don't depend on a code editor, like http-server for node.js. All you need is 2 commands (plus an extra install if you don't have node.js already, minus one command if you have http-server installed already) to get a server up and running.

CST1229 avatar Sep 17 '21 19:09 CST1229

Oops, i dont know much about this 404.html relative files so i probably shouldnt do this (Sorry @accio1)

FunctionalMetatable avatar Sep 18 '21 07:09 FunctionalMetatable