Linking pages together [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have been working with a knowledge graph where each unique subject has a number of properties. Each subject has a unique URI ex lets take this website: https://www.deutsche-digitale-bibliothek.de/person/gnd/118575775?lang=en
for a particular person
I know it is a stupid question but I am new to html and javascript. So if I have a link to that URI do I have to create an html file for each subject? What do /person/gnd/... refer to exactly?

Essentially, every slash after the domain is considered a route or pattern. The way that route works depends on the configuration of the web server.
Host-Based
Host based routing relies on the web server to route/forward the traffic, and in most cases it is in fact using a physical directory on the filesystem. This is the traditional way web applications worked.
Path-Based
Path based routing uses what is commonly referred to as a "front controller" to route the request. In this scenario, the web server routes/forwards all traffic to one file (commonly index.xxx). Inside that file you have an application router that matches patterns based on the URI. If it finds a match, that particular code will run and the result is returned.
Here is a link that also explains it: https://dzone.com/articles/the-three-http-routing-patterns-you-should-know

If I have a link to that URI do I have to create an html file for each subject?
Thank god no! An URL like http://example.com/some/path is basically a protocol (http://) + a server name (example.com) + a path (/some/path). The old-school way was to indeed have a resource for each path, but that is not required: given a certain path, the server is free to respond with whatever it wants.
I can't say that for sure but I highly suspect deutsche-digitale-bibliothek.de to have preformatted page for all people, and then custom person infos is being loaded thereafter. The bottom line is that it is both unecessary and not advised to, in the case when a lot of similar pages exist, have one HTML file for each of them.
What do /person/gnd/... refer to exactly?
That is the path. That's the segment that is sent to the server as part of the URL as specified in the HTTP protocol.

Related

Which HTTP request method should be used for a like button [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
A like button is something we see on YouTube or Facebook, there is a counter associated with it.
I wonder how we should go about implement such a button. Specifically how should we communicate with the backend when a user clicks on this button? Should the button use GET or POST to talk to the backend? It makes sense to me for using POST since we are incrementing the number of likes on the backend but some tutorial I found said we should use GET since POST is typically used in the context of a form to POST the form data to the backend.
I know this is quite an open ended question but I been googling the answer for a while and haven't found a convincing one.
I would say it depends on your backend framework convention of it. If you build your own backend from scratch, you may want to follow an existing convention from other projects.
Taking ruby on rails as an example for my answer, its convention is to map HTTP verbs and urls to certain actions for "resourceful routes", which is described on https://guides.rubyonrails.org/routing.html#crud-verbs-and-actions.
RFC2616 also describes the difference between PUT and POST:
The fundamental difference between the POST and PUT requests is
reflected in the different meaning of the Request-URI. The URI in a
POST request identifies the resource that will handle the enclosed
entity. That resource might be a data-accepting process, a gateway to
some other protocol, or a separate entity that accepts annotations. In
contrast, the URI in a PUT request identifies the entity enclosed with
the request -- the user agent knows what URI is intended and the
server MUST NOT attempt to apply the request to some other resource.
If the server desires that the request be applied to a different URI
As the comments on your question suggest, I'd also go with PUT.

What is the best way to make a multilingual site? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to make landing page on 2 languages, swapping language by click on the flag.
How I understand, I need to save language state in user's localstorage / cookies.
I see here 3 options:
Upload on user machine .json with content on 2 languages. At the opening of page script will check localstorage for availability of lang variable and after it fill page by JS.
Save lang variable in cookies, and at appeal to the server, server must make magic and send back page built on user language.
Make duplicates of each page in each language.
Question 1:
Which way better, when and why? (cases: one page landing, site with many pages)
Question 2:
When I make duplicates of page, is it normal to have no index.html in root directory at all, but:
/en/index.html
/ru/index.html
and .htaccess file that redirect to /en/ by default, check cookies for lang variable, and if exist redirect user to specific folder.
Question 1:
Option 1:
Good practice if you have some sort of frontend framework (like Angular or React).
But if you have a static (or only serverside rendering) page it is not really the way to go. Because it add unnecessary complexity to your code.
Option 2:
Good way to do it if you only have backend rendering (for example with PHP).
Option 3:
Do this only if you have static webpage (only HTML/CSS) which does not change. And you don't have programming experience at all.
Question 2:
Well no you always have a index.html but you can redirect to the index.html of the default language.
I would store each one of translations in a json file (en.json, ru.json) and change languages using url parameters. index.html?lang=ru (This way you don't have to handle different paths)
If the url parameter exists, save it on localstorage, load the respective json and fill the page with the tanslated strings.
If there is no url parameter, look in the localstorage for a language. If there is nothing there, assume a default (en, for example) and load the translated strings.

What all tools needed to design/publish websites? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am currently in the process of learning web design. I have learned Java, HTML, SQL, Python and am working on CSS and Javascript. I am learning these because the names of these languages pop up alot when i read about web design. So far i have seen the power of HTML, i can type code and open it as a HTML page and it's a webpage. My question is, what to do when you have all the tools to make the website? How does this website get to be on the World Wide Web? I have done a lot of research and i just don't think i understand the logic behind it. I see that i can purchase a domain name, but how do i bridge the gap between, lets say a simple HTML webpage and getting it to pop up on google? Thanks guys!
The domain register (GoDaddy for example) will point your domain to your hosting server (using the domain name servers or DNS for short), then your hosting server will serve your HTML/PHP/CSS files to anyone requesting them.
Using the submit URL link on google (https://www.google.com/webmasters/tools/submit-url) you can tell Google "hey, i got a new domain, come and check it out!" so Google will index it shortly (may vary between 2-14 days.
You need a server to host it on. The easiest way to do this is to use a cloud service such as Amazon's AWS. In fact, if all you are building is a static html/javascript webpage, you can probably just host it on s3.
http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html

Can I read and edit files that belong to the website folder using only html and javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am creating a website that must be able to login using the credentials that are saved in a text file(login.txt).After logging in the person must be able to add and remove images(images folder).
These images will then later be used to create a gallery that all users will be able to view.
What I want to know is can i achieve these results by only making use of HTML and JavaScript or must i also make use of server side languages like php or asp.net ?
note : I have done a good amount of research and still wasn't able to find an accurate answer for this question.
Any advice will be useful. Thanks ahead...
Short answer: You have to use a server
I assume you already know Javascript, so my advice is use Node.js.
You have to use a server side language because other users need to see the gallery , besides the ones that are uploading. So you can't use localStorage to save the images, because the front-end is private to the user, not global to every user (like a database or a server).
Some suggestions:
Use a database for user details, is faster, safer, and more maintainable
Define a Rest API on the server-side
On the front-end make a Single page application (using desired framework/libraries), using TDD principle
You should to use a server side language.
And if you save the credentials in a text file then anyone can reach these infos with that file url. ( Eg: http://yoursite.com/login.txt )
What I want to know is can i achieve these results by only making use of HTML and JavaScript or must i also make use of server side languages like php or asp.net ?
You'll need something on the server. That something might be:
Web server software that supports using the PUT verb to put files in a directory on the server. The general term for this is DAV or, in the web context, WebDAV. Apache, for instance, supports it with mod_dav. I've never tried it, but it may be possible to set up Apache with simple authentication (probably not with a plain text username/password file, though) and enable WebDAV for authenticated users. Your client-side code could then send PUT requests via ajax.
A server-side programming environment of some kind whether that's PHP, ASP.Net, NodeJS, or something else.
A content management system of some kind that already provides the ability you would otherwise write.

Can I hide html page? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
let's say i have a website example.com and a page example.com/DHAS5KJ1H45GAS.html. There is no links to said page anywhere except mysql database.
I'm assuming there is a setting to make search engines ignore the page (noindex, nofollow).
So my question: is there a program that can find all website's pages?
PS: I'm trying to make a page accessible only for users that know the passcode (without registration), i have mysql database with code/link pairs.
Maybe there is a better way to do this?
If you give a file a random name and don't have it linked anywhere publicly (and don't have indexing enabled in your web server), there is theoretically no way that it would be found by anyone without the link.
Do keep in mind, however, that anything you put in the URL will get stored to the user's browser history (someone who REALLY wanted to invade your website might use bruteforce CSS history knocking to exploit this if your codes weren't sufficiently random), and that it'd be pretty easy for anyone who had access to share the URL.
Create a robots.txt file in the root of your web directory, and set the content to:
User-agent: *
Disallow: /
This will prevent the site from being indexed by search engines. You can make the settings as specific as you'd like to allow/disallow pages more specifically, if need be.
If this file has constant name you can apply mod_rewrite. Simply create the file .htaccess in the folder where the file is located and put following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?DHAS5KJ1H45GAS\.html$ - [F,L]
</IfModule>

Categories