From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ms/learn/accessibility/index.html | 89 ++++++ files/ms/learn/html/forms/index.html | 340 +++++++++++++++++++++ .../add_responsive_image_to_a_webpage/index.html | 170 +++++++++++ files/ms/learn/html/howto/index.html | 153 ++++++++++ files/ms/learn/html/index.html | 48 +++ files/ms/learn/index.html | 94 ++++++ .../berurusan_dengan_fail/index.html | 103 +++++++ .../ms/learn/memulakan_pembelajaran_web/index.html | 57 ++++ .../memasang_perisian_asas/index.html | 58 ++++ .../server-side/express_nodejs/forms/index.html | 276 +++++++++++++++++ .../ms/learn/server-side/express_nodejs/index.html | 77 +++++ files/ms/learn/server-side/index.html | 59 ++++ files/ms/learn/soalan_lazim/index.html | 119 ++++++++ 13 files changed, 1643 insertions(+) create mode 100644 files/ms/learn/accessibility/index.html create mode 100644 files/ms/learn/html/forms/index.html create mode 100644 files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html create mode 100644 files/ms/learn/html/howto/index.html create mode 100644 files/ms/learn/html/index.html create mode 100644 files/ms/learn/index.html create mode 100644 files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html create mode 100644 files/ms/learn/memulakan_pembelajaran_web/index.html create mode 100644 files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html create mode 100644 files/ms/learn/server-side/express_nodejs/forms/index.html create mode 100644 files/ms/learn/server-side/express_nodejs/index.html create mode 100644 files/ms/learn/server-side/index.html create mode 100644 files/ms/learn/soalan_lazim/index.html (limited to 'files/ms/learn') diff --git a/files/ms/learn/accessibility/index.html b/files/ms/learn/accessibility/index.html new file mode 100644 index 0000000000..22617a9e99 --- /dev/null +++ b/files/ms/learn/accessibility/index.html @@ -0,0 +1,89 @@ +--- +title: Accessibility +slug: Learn/Accessibility +tags: + - ARIA + - Accessibility + - Articles + - Beginner + - CSS + - CodingScripting + - HTML + - JavaScript + - Landing + - Learn + - Module + - NeedsTranslation + - TopicStub +translation_of: Learn/Accessibility +--- +
{{LearnSidebar}}
+ +

Learning some HTML, CSS, and JavaScript is useful if you want to become a web developer. Beyond mechanical use, it's important to learn how to use these technologies responsibly so that all readers might use your creations on the web. To help you achieve this, this module will cover general best practices (which are demonstrated throughout the HTML, CSS, and JavaScript topics), cross browser testing, and some tips on enforcing accessibility from the start. We'll cover accessibility in special detail.

+ +

Overview

+ +

When someone describes a site as "accessible," they mean that any user can use all its features and content, regardless of how the user accesses the web — even and especially users with physical or mental impairments.

+ + + +

By default, HTML is accessible, if used correctly. Web accessibility involves ensuring that content remains accessible, regardless of who and how the web is accessed.

+ +

The Firefox Accessibility Inspector is a very useful tool for checking out accessibility issues on web pages. The following video provides a nice introduction to it:

+ +

{{EmbedYouTube("7mqqgIxX_NU")}}

+ +
+

Looking to become a front-end web developer?

+ +

We have put together a course that includes all the essential information you need to work towards your goal.

+ +

Get started

+
+ +

Prerequisites

+ +

To get the most out of this module, it would be a good idea to either work through at least the first two modules of the HTML, CSS, and JavaScript topics, or perhaps even better, work through the relevant parts of the accessibility module as you work through the related technology topics.

+ +
+

Note: If you are working on a computer/tablet/other devices where you don't have the ability to create your own files, you can try out most of the code examples in an online coding program such as JSBin or Glitch.

+
+ +

Guides

+ +
+
What is accessibility?
+
This article starts off the module with a good look at what accessibility is — this includes what groups of people we need to consider and why, what tools different people use to interact with the web, and how we can make accessibility part of our web development workflow.
+
HTML: A good basis for accessibility
+
A great deal of web content can be made accessible just by making sure the correct HTML elements are always used for the correct purpose. This article looks in detail at how HTML can be used to ensure maximum accessibility.
+
CSS and JavaScript accessibility best practices
+
CSS and JavaScript, when used properly, also have the potential to allow for accessible web experiences, but if misused they can significantly harm accessibility. This article outlines some CSS and JavaScript best practices that should be considered to ensure that even complex content is as accessible as possible.
+
WAI-ARIA basics
+
Following on from the previous article, sometimes making complex UI controls that involve unsemantic HTML and dynamic JavaScript-updated content can be difficult. WAI-ARIA is a technology that can help with such problems by adding in further semantics that browsers and assistive technologies can recognize and use to let users know what is going on. Here we'll show how to use it at a basic level to improve accessibility.
+
Accessible multimedia
+
Another category of content that can create accessibility problems is multimedia — video, audio, and image content need to be given proper textual alternatives, so they can be understood by assistive technologies and their users. This article shows how.
+
Mobile accessibility
+
With web access on mobile devices being so popular, and popular platforms such as iOS and Android having fully-fledged accessibility tools, it is important to consider the accessibility of your web content on these platforms. This article looks at mobile-specific accessibility considerations.
+
+ +

Assessments

+ +
+
Accessibility troubleshooting
+
+

In the assessment for this module, we present to you a simple site with several accessibility issues that you need to diagnose and fix.

+
+
+ +

See also

+ + diff --git a/files/ms/learn/html/forms/index.html b/files/ms/learn/html/forms/index.html new file mode 100644 index 0000000000..10e84875de --- /dev/null +++ b/files/ms/learn/html/forms/index.html @@ -0,0 +1,340 @@ +--- +title: Panduan Borang HTML +slug: Learn/HTML/Forms +translation_of: Learn/Forms +--- +

Welcome to the Guide to HTML Forms. This guide is a series of articles that will help you master HTML Forms. HTML Forms are a very powerful tool to interact with a user; however, due to historical and technical reasons, it's not always obvious how you use them to their full potential. In this guide, we'll cover all aspects of HTML Forms, from structure to styling, from data handling to custom widgets. You'll learn to enjoy the great power they offer!

+

Articles

+
    +
  1. My first HTML form
  2. +
  3. How to structure an HTML form
  4. +
  5. The native form widgets
  6. +
  7. CSS with HTML forms +
      +
    1. Styling HTML forms
    2. +
    3. Advanced styling for HTML forms
    4. +
    5. Property compatibility table for form widgets
    6. +
    +
  8. +
  9. Sending and retrieving form data
  10. +
  11. Data form validation
  12. +
  13. How to build custom form widgets
  14. +
  15. Sending forms through JavaScript +
      +
    1. Using the FormData object
    2. +
    +
  16. +
  17. HTML forms in legacy browsers
  18. +
+

HTML Documentation

+

HTML Elements

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ElementRelated DOM interfaceDescription
{{HTMLElement("button")}}{{domxref("HTMLButtonElement")}}The button element represents a clickable button.
{{HTMLElement("datalist")}}{{domxref("HTMLDataListElement")}}The datalist element contains a set of {{ HTMLElement("option") }} elements that represent the possible options for the value of other forms elements.
{{HTMLElement("fieldset")}}{{domxref("HTMLFieldSetElement")}}The fieldset is used to group several form elements within a form.
{{HTMLElement("form")}}{{domxref("HTMLFormElement")}}The form element represents a section of document that contains interactive element that enable a user to submit information to a web server.
{{HTMLElement("input")}}{{domxref("HTMLInputElement")}}The  input element is used to create interactive controls for forms.
{{HTMLElement("keygen")}}{{domxref("HTMLKeygenElement")}}The keygen element exists to facilitate generation of key material, and submission of the public key as part of an HTML form
{{HTMLElement("label")}}{{domxref("HTMLLabelElement")}}The label element represents a caption for an item in a user interface
{{HTMLElement("legend")}}{{domxref("HTMLLegendElement")}}The legend element represents a caption for the content of its parent {{ HTMLElement("fieldset") }}.
{{HTMLElement("meter")}}{{domxref("HTMLMeterElement")}}The meter element  represents either a scalar value within a known range or a fractional value.
{{HTMLElement("optgroup")}}{{domxref("HTMLOptGroupElement")}}the optgroup element creates a group of options within a {{ HTMLElement("select") }} element.
{{HTMLElement("option")}}{{domxref("HTMLOptionElement")}}the HTML option element is used to create a control representing an item within a {{ HTMLElement("select") }}, an {{ HTMLElement("optgroup") }} or a {{ HTMLElement("datalist") }} element.
{{HTMLElement("output")}}{{domxref("HTMLOutputElement")}}The output element represents the result of a calculation.
{{HTMLElement("progress")}}{{domxref("HTMLProgressElement")}}The progress element is used to view the completion progress of a task.
{{HTMLElement("select")}}{{domxref("HTMLSelectElement")}}The select element represents a control that presents a menu of options.
{{HTMLElement("textarea")}}{{domxref("HTMLTextAreaElement")}}The textarea element represents a multi-line plain-text editing control.
+
+

Note: All form elements, as all HTML elements, support the {{domxref("HTMLElement")}} DOM interface.

+
+

HTML Attributes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Attribute NameElementsDescription
accept{{ HTMLElement("form") }}, {{ HTMLElement("input") }}List of types the server accepts, typically a file type.
accept-charset{{ HTMLElement("form") }}List of supported charsets.
action{{ HTMLElement("form") }}The URI of a program that processes the information submitted via the form.
autocomplete{{ HTMLElement("form") }}, {{ HTMLElement("input") }}Indicates whether controls in this form can by default have their values automatically completed by the browser.
autofocus{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}The element should be automatically focused after the page loaded.
challenge{{ HTMLElement("keygen") }}A challenge string that is submitted along with the public key.
checked{{ HTMLElement("input") }}Indicates whether the element should be checked on page load.
cols{{ HTMLElement("textarea") }}Defines the number of columns in a textarea.
data{{ HTMLElement("object") }}Specifies the URL of the resource.
dirname{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} 
disabled{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}Indicates whether the user can interact with the element.
enctype{{ HTMLElement("form") }}Defines the content type of the form date when the method is POST.
for{{ HTMLElement("label") }}, {{ HTMLElement("output") }}Describes elements which belongs to this one.
form{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}Indicates the form that is the owner of the element.
high{{ HTMLElement("meter") }}Indicates the lower bound of the upper range.
keytype{{ HTMLElement("keygen") }}Specifies the type of key generated.
list{{ HTMLElement("input") }}Identifies a list of pre-defined options to suggest to the user.
low{{ HTMLElement("meter") }}Indicates the upper bound of the lower range.
max{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}Indicates the maximum value allowed.
maxlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}Defines the maximum number of characters allowed in the element.
method{{ HTMLElement("form") }}Defines which HTTP method to use when submitting the form. Can be GET (default) or POST.
min{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}Indicates the minimum value allowed.
multiple{{ HTMLElement("input") }}, {{ HTMLElement("select") }}Indicates whether multiple values can be entered in an input of the type email or file.
name{{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}Name of the element. For example used by the server to identify the fields in form submits.
novalidate{{ HTMLElement("form") }}This attribute indicates that the form shouldn't be validated when submitted.
optimum{{ HTMLElement("meter") }}Indicates the optimal numeric value.
pattern{{ HTMLElement("input") }}Defines a regular expression which the element's value will be validated against.
placeholder{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}Provides a hint to the user of what can be entered in the field.
readonly{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}Indicates whether the element can be edited.
required{{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}Indicates whether this element is required to fill out or not.
rows{{ HTMLElement("textarea") }}Defines the number of rows in a textarea.
selected{{ HTMLElement("option") }}Defines a value which will be selected on page load.
size{{ HTMLElement("input") }}, {{ HTMLElement("select") }}Defines the width of the element (in pixels). If the element's type attribute is text or password then it's the number of characters.
src{{ HTMLElement("input") }}The URL of the embeddable content.
step{{ HTMLElement("input") }} 
target{{ HTMLElement("form") }} 
type{{ HTMLElement("button") }}, {{ HTMLElement("input") }}Defines the type of the element.
usemap{{ HTMLElement("input") }} 
value{{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}Defines a default value which will be displayed in the element on page load.
wrap{{ HTMLElement("textarea") }}Indicates whether the text should be wrapped.
+

Normative reference

+ diff --git a/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html b/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html new file mode 100644 index 0000000000..0589cda2d8 --- /dev/null +++ b/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html @@ -0,0 +1,170 @@ +--- +title: Add responsive images to a webpage +slug: Learn/HTML/Howto/Add_responsive_image_to_a_webpage +translation_of: Learn/HTML/Multimedia_and_embedding/Responsive_images +--- +
+

Learn about HTML features you can use to adapt your site's images to various screen sizes and display resolutions.

+
+ + + + + + + + + + + + +
Prerequisites:You should already know how to create a basic HTML document and how to add static images to a webpage.
Objective:Learn how to feed multiple source files to your {{htmlelement("img")}} element, so the browser can pull the right image for the occasion.
+ +
+

Note: Vector images are the ultimate responsive images because the files are small while the images are scalable to any size without loss of definition. Use vector images whenever you can; they're even more effective than the techniques described here. This article demonstrates how to use multiple versions of a bitmap image, in different sizes, to provide the best possible output given the current screen size and resolution.

+ +

Note also that while this article discusses how to implement responsive images in HTML, sometimes it makes more sense to use CSS.

+
+ +

Why responsive images?

+ +

Here's the problem we're solving:

+ +

On a webpage, you have a box that must be filled by an image. More precisely, the box must be filled by pixels, so many wide by so many tall. Just how many pixels wide and tall depends on your visitor's device.

+ +

You also have an image file, a set number of pixels wide and a set number of pixels tall. The image naturally should display in a box the same number of pixels wide and tall as the image. If the box is significantly too big, the image doesn't have enough pixels and it's going to look grainy. If the box is significantly too small, you're wasting bandwidth and slowing down your page by loading a larger image than you need.

+ +

Responsive images solves this problem by letting you offer the browser several image files, all showing the same thing but containing different numbers of pixels. That way the browser can load an image that will look sharp enough but won't needlessly slow down the page.

+ +

So how do you do it?

+ +

In this section, we'll solve what is, by far, the most common problem: displaying identical image content, just larger or smaller depending on the device. In the next section, we'll look at some less common scenarios.

+ +

Remember the {{htmlelement("img")}} element? It lets you point the browser to a single source file:

+ +
<img src="chalet.jpg" alt="Quaint wooden cottage in the Alps">
+ +

We can use two new attributes, {{htmlattrxref("srcset", "img")}} and {{htmlattrxref("sizes", "img")}} sizes (in addition to {{htmlattrxref("alt", "img")}} and {{htmlattrxref("src", "img")}}), to provide several additional source images and enough information to help the browser pick the right one. It looks like this when you're done:

+ +
<img
+    src="chalet.jpg"
+    alt="Quaint wooden cottage in the Alps"
+    srcset="
+        chalet-256.jpg 256w,
+        chalet-512.jpg 512w,
+        chalet-1024.jpg 1024w"
+    sizes="
+        (max-width: 500px) 100vw,
+        (max-width: 900px) 40vw,
+        400px">
+
+ +

srcset and sizes each contain comma-separated lists.

+ +

For srcset: Between the commas, write

+ +
    +
  1. an image filename (chalet-256.jpg)
  2. +
  3. a space
  4. +
  5. the image's inherent width in pixels (256w)
  6. +
+ +

For sizes: Between the commas, write

+ +
    +
  1. a media condition ((max-width:500px))
  2. +
  3. a space
  4. +
  5. the width of the slot the image will fill when the media condition is true (100vw)
  6. +
+ +
+ +
+ +
+

Why can't the browser just look at the CSS to find out the width of the image slot?

+ +

Because the browser's preloader starts downloading images before the main parser has a chance to interpret CSS and JavaScript. You want that, because images are heavy and circumventing the preloader may add another 20% on to your page load time.

+
+ +

Advanced scenarios

+ +

Images at different resolutions but one real-world size

+ +

If you're supporting multiple display densities, but everyone sees your image at the same real-world size, you should use srcset with x-descriptors and without sizes:

+ +
<img
+    src="chalet.jpg"
+    alt="Quaint wooden cottage in the Alps"
+    srcset="chalet.jpg,
+        chalet-1-5x.jpg 1.5x,
+        chalet-2x.jpg 2x,
+        chalet-3x.jpg 3x">
+
+ +
+ +
+ +

Art direction

+ +

Art direction means cropping an image either 1) to make the main subject easier to see when the image is small or 2) to make a landscape image suitable for a portrait slot (and vice versa). (However, it must be the same image content in all cases. To, say, show phone users a jet and desktop users a ladybug is a misuse of the responsive image mechanism.)
+ Art direction is a more complex problem, and needs a more complex solution: the {{htmlelement("picture")}} element. <picture> is a wrapper containing several {{htmlelement("source")}} elements, followed by the all-important {{htmlelement("img")}} element:

+ +
<picture>
+    <source
+        media="(min-width: 1000px)"
+        srcset="chalet-desktop.jpg">
+    <source
+        media="(min-width: 700px)"
+        srcset="chalet-tablet.jpg">
+    <img src="chalet-phone.jpg" alt="Quaint wooden cottage in the Alps">
+</picture>
+
+ + + +

Use modern image formats boldly

+ +

There are several exciting new image formats (think WebP and JPEG-2000) that can maintain a low file size and high quality at the same time. However, browser support is spotty.

+ +

<picture> lets us continue catering to older browsers. Supply MIME types inside type attributes so the browser can immediately reject unsupported file types:

+ +
<picture>
+  <source type="image/svg+xml" srcset="pyramid.svg">
+  <source type="image/webp" srcset="pyramid.webp">
+  <img src="pyramid.png" alt="regular pyramid built from four equilateral triangles">
+</picture>
+
+ + + +

Learn more

+ + diff --git a/files/ms/learn/html/howto/index.html b/files/ms/learn/html/howto/index.html new file mode 100644 index 0000000000..7ce5cf622f --- /dev/null +++ b/files/ms/learn/html/howto/index.html @@ -0,0 +1,153 @@ +--- +title: Learn HTML to solve problems +slug: Learn/HTML/Howto +tags: + - CodingScripting + - HTML + - NeedsTranslation + - TopicStub +translation_of: Learn/HTML/Howto +--- +

Once you've covered the basics, there isn't one right path to learn {{Glossary("HTML")}}. You can pick up whatever you like at your own pace. HTML is simply a set of {{glossary("tag","tags")}} you can use to set up your document structure and add extra functionality to your document. The following articles explain thoroughly, with full working examples, how to use HTML for the most common, frequent Web development tasks. If you need a quick explanation of a tag, please head over to our HTML reference.

+ +

Common use cases

+ +

HTML covers a lot of very common use cases in Web design. It's highly likely you'll come across these scenarios:

+ +
+
+

Basic structure

+ +

The most basic application of HTML is document structure. If you're new to HTML you should start with this.

+ + + +

Basic text-level semantics

+ +

HTML specializes in providing semantic information for a document, so HTML answers many questions you might have about how to get your message across best in your document.

+ + +
+ +
+ + +

One of the main reasons for HTML is make navigation easy with {{Glossary("hyperlink", "hyperlinks")}}, which can be used in many different ways:

+ + + +

Images & multimedia

+ + + +

Scripting & styling

+ +

HTML only sets up document structure. To solve presentation issues, use {{glossary("CSS")}}, or use scripting to make your page interactive.

+ + + +

Embedded content

+ + +
+
+ +

Uncommon or advanced problems

+ +

Beyond the basics, HTML is very rich and offers advanced features for solving complex problems. These articles help you tackle the less common use cases you may face:

+ +
+
+

Forms

+ +

Forms are a complex HTML structure made to send data from a webpage to a web server. We encourage you to go over our full dedicated guide. Here is where you should start:

+ + + +

Tabular information

+ +

Some information, called tabular data, needs to be organized into tables with columns and rows. It's one of the most complex HTML structures, and mastering it is not easy:

+ + + +

Data representation

+ + + +

Interactivity

+ + +
+ + +
+ +

     

diff --git a/files/ms/learn/html/index.html b/files/ms/learn/html/index.html new file mode 100644 index 0000000000..826dc8c29c --- /dev/null +++ b/files/ms/learn/html/index.html @@ -0,0 +1,48 @@ +--- +title: HTML +slug: Learn/HTML +tags: + - Beginner + - CodingScripting + - HTML + - NeedsContent + - NeedsTranslation + - TopicStub +translation_of: Learn/HTML +--- +
{{IncludeSubnav("/en-US/Learn")}}
+

{{Glossary('HTML')}} is a major Web technology that defines the structure of a webpage. If you're looking to build websites, you should know about HTML.

+ +

It's not hard to pick up the basics, but HTML is also a broad technology with many complex features, so there isn't one correct learning pathway. We suggest you start with the following pages to pick up some skills and knowledge. Move from the first basic skill to the last advanced skill, or just pick a page that looks interesting to you!

+ +
+
+

The basics

+ +

Start here if you aren't familiar with HTML:

+ +
+
Introduction to HTML
+
If you've ever wondered what goes on behind the scenes in your Web browser, here's where you can start learning.
+
Solve common problems with HTML
+
This series of articles is here to help use HTML to solve very common problems when creating a webpage: Dealing with titles, adding images or videos, emphazing content, starting using form, etc.
+
Write a simple page in HTML
+
In this article you will learn how to create a simple webpage.
+
What are HTML tags and how to use them
+
This article covers the very basics of HTML. Find out what tags are and how to use them.
+
+
+ +
+

In depth

+ +

Once you're a bit more used to HTML, here's some more detailed stuff to explore:

+ +
+
HTML reference
+
In our extensive reference guide, you'll find details about each HTML element and attribute.
+
+
+
+ +

 

diff --git a/files/ms/learn/index.html b/files/ms/learn/index.html new file mode 100644 index 0000000000..4140d61ab2 --- /dev/null +++ b/files/ms/learn/index.html @@ -0,0 +1,94 @@ +--- +title: Learning the Web +slug: Learn +tags: + - Beginner + - Index + - Landing + - Learn + - NeedsTranslation + - TopicStub + - Web +translation_of: Learn +--- +
+

anda mahu mencipta laman web dan aplikasi web anda sendiri? Anda telah datang ke tempat yang betul!

+
+ +

Terdapat banyak perkara yang boleh dipelajari tentang rekabentuk dan pembangunan web, tapi jangan risau. Kami di sini untuk untuk membantu anda, sama ada anda hanya mahu mempelajari sedikit kod atau untuk menjadi pembangun web profesional sepenuhnya.

+ +

Ke mana dahulu

+ +

Penerangan yang mana terbaik melambangkan anda?

+ + + +
+

Nota: Pada masa hadapan kami merancang untuk menerbitkan lebih banyak laluan pembelajaran, sebagai contoh untuk programmer berpengalaman mempelajari teknik-teknik lanjutan yang spesifik, pembangun asli yang baru dengan Web, atau orang yang hendak belajar teknik-teknik rekabentuk.

+
+ +

{{LearnBox({"title":"Quick learning: Vocabulary"})}}

+ +

Pembelajaran dengan orang lain

+ +

Jika anda ada soalan atau masih tertanya-tanya ke mana hendak dituju, Mozilla adalah komuniti global merangkumi peminat-peminat Web, termasuk mentor-mentor dan guru-guru yang sedia untuk membantu anda. Berhubunglah dengan mereka melalui WebMaker:

+ + + +

Berkongsi pengetahuan

+ +

Seluruh bahagian pembelajaran ini dibina oleh penyumbang-penyumbang kami. Kami perlukan anda dalam pasukan kami sama ada anda baru bermula, seorang guru, atau seorang pembangun web berkemahiran. Jika anda berminat, cuba lihat di bagaimana anda boleh membantu, dan kami menggalakkan anda untuk bersembang dengan kami di senarai mel atau saluran IRC. :)

+ + + +
    +
  1. Mula Mempelajari Web
  2. +
  3. Belajar Web +
      +
    1. Web Literacy Map
    2. +
    3. Web mechanics
    4. +
    5. Infrastructure
    6. +
    7. Coding & Scripting
    8. +
    9. Design & Accessibility
    10. +
    11. Writing & planning
    12. +
    +
  4. +
  5. Belajar teknologi-teknologi +
      +
    1. HTML
    2. +
    3. CSS
    4. +
    5. JavaScript
    6. +
    7. Python
    8. +
    +
  6. +
  7. Tutorial pembelajaran +
      +
    1. Bagaimana mencipta sebuah laman web?
    2. +
    3. Asas keselamatan maklumat
    4. +
    +
  8. +
  9. Rujukan pembelajaran
  10. +
  11. Dapatkan bantuan +
      +
    1. FAQ
    2. +
    3. Glosari
    4. +
    5. Tanyakan soalan-soalan anda
    6. +
    7. Bertemu dengan guru dan mentor
    8. +
    +
  12. +
  13. Bagaimana untuk menyumbang
  14. +
diff --git a/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html b/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html new file mode 100644 index 0000000000..41e06b9599 --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html @@ -0,0 +1,103 @@ +--- +title: Berurusan dengan fail +slug: Learn/Memulakan_pembelajaran_web/Berurusan_dengan_fail +tags: + - Beginner + - CodingScripting + - Files + - Guide + - HTML + - theory + - website +translation_of: Learn/Getting_started_with_the_web/Dealing_with_files +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}
+ +
+

Sebuah laman web merangkumi banyak fail: kandungan teks, kod, stylesheet, kandungan media, dan sebagainya. Apabila anda membangunkan sebuah laman web, anda perlu menghimpunkan fail-fail ini dalam struktur yang wajar di komputer anda, pastikan fail-fail ini dapat berhubung antara satu sama lain, dan menjadikan kandungan anda nampak betul, sebelum anda akhirnya memuat naik ke pelayan. Berurusan dengan fail membincangkan beberapa isu yang anda patut peka supaya anda boleh menetapkan struktur fail yang wajar untuk laman web anda.

+
+ +

Di manakah laman web anda patut berada di dalam komputer anda?

+ +

Apabila anda mengerjakan laman web anda di  komputer anda sendiri, anda perlu menyimpan fail-fail yang berkaitan di dalam folder tunggal yang mirip dengan struktur fail untuk laman web yang diterbitkan di pelayan. Folder ini boleh berada di mana sahaja anda suka, tetapi anda patut letaknya di tempat yang anda mudah untuk menjumpainya, mungkin di Desktop anda, dalam folder Home, atau di root pemacu keras anda.

+ +
    +
  1. Pilih tempat untuk menyimpan projek-projek laman web anda. Di sini, cipta sebuah folder baru yang dinamakan  web-projects (atau serupa). Di sinilah kesemua projek-projek laman web anda akan berada.
  2. +
  3. Di dalam folder pertama ini, cipta folder lain untuk menyimpan laman web pertama anda. Namakannya test-site (atau sesuatu yang lebih imaginatif).
  4. +
+ +

Catatan tentang casing dan spacing

+ +

Anda akan perasan bahawa sepanjang artikel ini, kami meminta anda untuk menamakan folder-folder dan fail-fail sepenuhnya dalam huruf kecil tanpa jarak, Ini kerana:

+ +
    +
  1. Kebanyakan komputer, terutamanya pelayan web, adalah case-sensitive. Sebagai contoh, jika anda meletakkan sebuah imej di laman web anda di test-site/MyImage.jpg, dan dalam fail yang lain anda cuba untuk memanggil imej tersebut sebagai test-site/myimage.jpg, ia mungkin tidak berfungsi.
  2. +
  3. Pelayar-pelayar web, pelayan-pelayan web, dan bahasa-bahasa pengaturcaraan tidak mengendalikan ruang dengan konsisten. Sebagai contoh, jika anda menggunakan ruang di dalam nama fail, sesetengah sistem mungkin akan menganggap nama fail tersebut sebagai dua nama. Sesetengah pelayan akan menggantikan ruang tersebut di dalam nama fail anda dengan "%20"(kod karakter untuk ruang dalam URI), merosakkan kesemua pautan anda. Lebih baik untuk mengasingkan perkataan dengan tanda sempang atau garis bawah: my-file.html atau my_file.html.
  4. +
+ +

Untuk sebab-sebab ini, ia adalah sangat baik untuk menjadikan tabiat menulis nama-nama folder dan fail dalam huruf kecil tanpa ruang, sekurang-kurangnya sehingga anda tahu apa yang anda buat. Dengan cara tersebut anda akan kurang terlibat dengan masalah.

+ +

Apakah struktur yang patut dimiliki laman web anda?

+ +

Seterusnya, mari lihat struktur apa yang laman web kita patut ada. Benda asas utama yang kita akan ada dalam apa-apa projek laman web yang kita cipta adalah fail index HTML dan folder-folder untuk menyimpan imej-imej, fail-fail style, dan fail-fail script. Mari kita cipta ini sekarang:

+ +
    +
  1. index.html: Secara umumnya fail ini mengandungi kandungan halaman utama, iaitu teks dan imej-imej yang dilihat orang apabila mereka mula-mula pergi ke laman anda. Dengan menggunakan editor teks anda, cipta fail baru dinamakan index.html dan simpan ia di dalam folder test-site anda.
  2. +
  3. folder images: Folder ini akan mengandungi kesemua imej yang anda gunakan di laman anda. Cipta sebuah folder dinamakan images, di dalam folder test-site anda.
  4. +
  5. folder styles: Folder ini akan mengandungi kod CSS yang digunakan untuk mengayakan kandungan anda (sebagai contoh, menetapkan teks dan warna-warna latar belakang). Cipta sebuah folder dinamakan styles, di dalam folder test-site anda.
  6. +
  7. folder scripts: Folder ini akan mengandungi kesemua kod JavaScript yang digunakan untuk menambah fungsi interaktif ke dalam laman anda (cth. button yang memuatkan data apabila diklik). Cipta sebuah folder dinamakan scripts, di dalam folder test-site anda.
  8. +
+ +
+

Nota: Dalam komputer Windows, anda mungkin menghadapi masalah melihat nama-nama fail kerana Windows mempunyai satu pilihan yang menjengkelkan dinamakan Hide extensions for known file types yang dihidupkan secara default. Secara umumnya, anda boleh mematikannya dengan pergi ke Windows Explorer, memilih pilihan Folder options..., menyahtik pada kotak pilihan Hide extensions for known file types, kemudian klik OK. Untuk maklumat spesifik merangkumi versi Windows anda, lakukan carian Yahoo!

+
+ +

Path fail

+ +

Untuk membuat fail-fail berhubung antara satu sama lain, anda perlu menyediakan path antara mereka — secara asasnya sebuah route supaya satu fail tahu di mana fail yang satu lagi. Untuk mendemonstrasikan ini, kita akan memasukkan sedikit HTML ke dalam fail index.html, dan membuatkan ia memaparkan imej yang anda pilih di dalam artikel "Bagaimanakah laman web anda akan kelihatan?"

+ +
    +
  1. Salin imej yang anda pilih sebelum ini ke dalam folder images anda.
  2. +
  3. Buka fail index.html anda, dan masukkan kod di bawah ke dalam fail yang ditunjukkan. Jangan risau tentang apa semua maksud ini buat masa sekarang — kita akan lihat dengan lebih terperinci pada strukturnya nanti dalam siri tersebut. +
    <!DOCTYPE html>
    +<html>
    +  <head>
    +    <meta charset="utf-8">
    +    <title>My test page</title>
    +  </head>
    +  <body>
    +    <img src="" alt="My test image">
    +  </body>
    +</html> 
    +
  4. +
  5. Baris <img src="" alt="My test image"> adalah kod HTML yang memasukkan sebuah gambar ke dalam laman tersebut. Kita perlu beritahu HTML di mana gambar tersebut. Imej tersebut berada dalam direktori images , yang mana dalam direktori sama seperti index.html. Untuk menelusuri struktur fail daripada index.html kepada imej kita, path fail yang kita perlukan adalah images/nama-failimej-anda. Sebagai contoh, imej kita dinamakan firefox-icon.png, jadi path fail adalah images/firefox-icon.png.
  6. +
  7. Masukkan path fail ke dalam kod HTML di antara tanda petikan berganda kod src="".
  8. +
  9. Save fail HTML anda, kemudian muatkannya di pelayar web anda (klik dua kali fail tersebut). Anda patut boleh lihat halaman web baru anda memaparkan imej anda!
  10. +
+ +

A screenshot of our basic website showing just the firefox logo - a flaming fox wrapping the world

+ +

Beberapa peraturan umum untuk path fail:

+ + + +

Buat masa ini, ini adalah antara kesemua yang anda perlu tahu.

+ +
+

Nota: Sistem fail Windows cenderung untuk menggunakan garis palang terbalik, bukannya garis palang ke hadapan, cth. C:\windows. Ini tidak penting  — walaupun anda membangunkan laman web anda dengan Windows, anda masih perlu menggunakan garis palang ke hadapan di dalam kod anda.

+
+ +

Apakah lagi yang perlu diselesaikan?

+ +

Cukup lah buat masa ini. Struktur folder anda patut kelihatan seperti ini:

+ +

A file structure in mac os x finder, showing an images folder with an image in, empty scripts and styles folders, and an index.html file

+ +

{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}

diff --git a/files/ms/learn/memulakan_pembelajaran_web/index.html b/files/ms/learn/memulakan_pembelajaran_web/index.html new file mode 100644 index 0000000000..fd07a2d78a --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/index.html @@ -0,0 +1,57 @@ +--- +title: Memulakan pembelajaran Web +slug: Learn/Memulakan_pembelajaran_web +tags: + - Beginner + - CSS + - Design + - Guide + - HTML + - Index + - publishing + - theory +translation_of: Learn/Getting_started_with_the_web +--- +
{{LearnSidebar}}
+ +
+

Memulakan pembelajaran Web adalah siri ringkas dan padat memperkenalkan anda kepada praktikaliti pembangunan Web. Anda akan menetapkan alatan yang anda perlukan untuk membina halaman web dan menerbitkan kod ringkas anda sendiri.

+
+ +

Kisah laman web pertama anda

+ +

Ia adalah banyak kerja untuk mencipta laman web yang profesional, jadi jika anda masih baru dalam pembangunan web kami menggalakkan anda supaya bermula daripada bawah. Anda tidak akan mendirikan sebuah lagi Facebook dengan serta merta, namun ianya bukan susah untuk menerbitkan laman web ringkas anda sendiri ke dalam talian, jadi kita akan bermula daripada situ.

+ +

Dengan berusaha menerusi artikel-artikel yang disenaraikan mengikut urutan di bawah, anda akan bermula daripada tiada kepada menerbitkan halaman web pertama anda ke dalam talian. Jadi mari kita bermula!

+ +

Memasang perisian asas

+ +

Apabila datang kepada soal alatan untuk membina laman web, terdapat banyak pilihan yang boleh dipilih. Jika anda baru sahaja bermula, anda mungkin akan keliru dengan pelbagai jenis editor kod, kerangka kerja, dan alatan pengujian di luar sana. Dalam artikel Memasang perisian asas kami menunjukkan anda langkah demi langkah bagaimana untuk memasang hanya perisian yang anda perlukan untuk memulakan sedikit pembangunan asas web.

+ +

Bagaimana laman web anda akan kelihatan?

+ +

Sebelum anda mula menulis kod untuk laman web anda, anda patut rancang ia dahulu. Apakah maklumat yang anda hendak tunjuk? Apa font dan warna yang anda gunakan? Bagaimana laman web anda akan kelihatan? Kami akan mengariskan cara mudah yang anda boleh ikut untuk merancang kandungan dan rekabentuk laman web anda.

+ +

Berurusan dengan fail-fail

+ +

Sebuah laman web merangkumi banyak fail: kandungan teks, kod, lembaran gaya, kandungan media, dan seterusnya. Apabila anda membina sebuah laman web, anda perlu menghimpunkan fail-fail ini ke dalam struktur yang wajar dan memastikan fail-fail ini dapat berhubung antara satu sama lain. Berurusan dengan fail-fail menerangkan bagaimana untuk menetapkan struktur fail yang wajar untuk laman web anda dan isu-isu yang anda perlu sedar.

+ +

Asas-asas HTML

+ +

Hypertext Markup Language (HTML) adalah kod yang anda guna untuk mengstrukturkan kandungan web anda, dan memberinya makna dan tujuan. Sebagai contoh, adakah kandungan saya adalah satu set perenggan, atau satu senarai titik bullet? Adakah saya ada gambar-gambar di dalam halaman saya? Adakah saya ada jadual data? Tanpa membebankan anda, Asas-asas HTML menyediakan maklumat yang cukup untuk membiasakan diri anda dengan HTML.

+ +

Asas-asas CSS

+ +

Cascading Stylesheet (CSS) adalah kod yang anda guna untuk menggayakan laman web anda. Sebagai contoh, adakah anda mahu teks hitam atau merah? Di manakah kandungan patut dilukis di atas skrin? Apakah gambar dan warna latar belakang yang patut digunakan untuk menghias laman web anda? Asas-asas CSS akan membawa anda menelusuri apa yang anda perlukan untuk bermula.

+ +

Asas-asas JavaScript

+ +

JavaScript adalah bahasa pengaturcaraan yang anda guna untuk menambah ciri-ciri interaktif kepada laman web anda, sebagai contoh, permainan, perkara yang berlaku apabila butang ditekan atau data dihantar dalam borang, kesan penggayaan dinamik, animasi, dan banyak lagi. Asas-asas JavaScript memberi anda idea apa yang boleh dibuat dengan bahasa yang menarik ini, dan bagaimana untuk bermula.

+ +

Menerbitkan laman web anda

+ +

Sebaik sahaja anda siap menulis kod dan menyusun fail-fail yang menjadikan laman web anda, anda perlu meletakkan semuanya di atas talian supaya orang boleh menjumpainya. Menerbitkan kod sampel anda menerangkan bagaimana untuk meletakkan kod sampel ringkas anda di atas talian dengan usaha yang sedikit.

+ +

Bagaimana web berfungsi

+ +

Apabila anda mengakses laman web kegemaran anda, banyak perkara yang merumitkan berlaku di belakang yang anda mungkin tidak tahu. Bagaimana web berfungsi menggariskan apa yang berlaku apabila anda melihat paparan halaman web di komputer anda.

diff --git a/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html b/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html new file mode 100644 index 0000000000..2363f77c32 --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html @@ -0,0 +1,58 @@ +--- +title: Memasang Perisian Asas +slug: Learn/Memulakan_pembelajaran_web/Memasang_Perisian_Asas +tags: + - Beginner + - Browser + - Learn + - Setup + - Tools + - WebMechanics + - text editor +translation_of: Learn/Getting_started_with_the_web/Installing_basic_software +--- +
{{LearnSidebar}}
+ +
{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}
+ +
+

Dalam artikel Memasang Perisian Asas, kami akan tunjuk anda alatan yang anda perlukan untuk melakukan pembangunan web yang mudah.

+
+ +

Apakah alatan yang digunakan profesional?

+ + + +

Apakah alatan yang saya perlukan sekarang?

+ +

Itu kelihatan seperti senarai yang menakutkan, tetapi nasib baik anda boleh memulakan pembangunan web tanpa mengetahui apa-apa tentang kebanyakan alatan di atas. Dalam artikel ini kami akan menetapkan anda dengan seminimun alatan — editor teks dan beberapa pelayar web moden.

+ +

Memasang editor teks

+ +

Anda mungkin sudah ada editor teks asas dalam komputer anda. Secara lalai Windows merangkumi Notepad dan OS X datang dengan TextEdit. Distro Linx bergantung, Ubuntu dalam dengan gedit secara lalai.

+ +

Untuk pembangunan Web, anda mungkin boleh buat lebih baik daripada Notepad atau TextEdit. Kami menyarankan anda bermula dengan Notepad++ untuk Windows atau Text Wrangler untuk Mac. Kedua-duanya percuma dan lebih berciri penuh berbanding Notepad dan TextEdit.

+ +

Memasang pelayar-pelayar web moden

+ +

Buat masa ini, kita hanya pasang beberapa pelayar web desktop untuk menguji kod kita di dalamnya. Pilih sistem operasi anda di bawah dan klik pautan yang relevan untuk memuat turun pemasang-pemasang pelayar kegemaran anda:

+ + + +

Sebelum meneruskan, anda patut pasang sekurang-kurangnya dua daripada pelayar-pelayar ini dan sediakannya untuk pengujian.

+ +

{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}

diff --git a/files/ms/learn/server-side/express_nodejs/forms/index.html b/files/ms/learn/server-side/express_nodejs/forms/index.html new file mode 100644 index 0000000000..6e50f7b27a --- /dev/null +++ b/files/ms/learn/server-side/express_nodejs/forms/index.html @@ -0,0 +1,276 @@ +--- +title: 'Express Tutorial Part 6: Working with forms' +slug: Learn/Server-side/Express_Nodejs/forms +tags: + - Beginner + - CodingScripting + - Express + - Forms + - HTML forms + - Learn + - NeedsTranslation + - Node + - TopicStub + - server-side +translation_of: Learn/Server-side/Express_Nodejs/forms +--- +
{{LearnSidebar}}
+ +
{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs/deployment", "Learn/Server-side/Express_Nodejs")}}
+ +

In this tutorial we'll show you how to work with HTML Forms in Express, using Pug, and in particular how to write forms to create, update, and delete documents from the database.

+ + + + + + + + + + + + +
Prerequisites:Complete all previous tutorial topics, including Express Tutorial Part 5: Displaying library data
Objective:To understand how write forms to get data from users, and update the database with this data.
+ +

Overview

+ +

An HTML Form is a group of one or more fields/widgets on a web page that can be used to collect information from users for submission to a server. Forms are a flexible mechanism for collecting user input because there are suitable form inputs available for entering many different types of data—text boxes, checkboxes, radio buttons, date pickers, etc. Forms are also a relatively secure way of sharing data with the server, as they allow us to send data in POST requests with cross-site request forgery protection.

+ +

Working with forms can be complicated! Developers need to write HTML for the form, validate and properly sanitize entered data on the server (and possibly also in the browser), repost the form with error messages to inform users of any invalid fields, handle the data when it has successfully been submitted, and finally respond to the user in some way to indicate success.

+ +

In this tutorial we're going to show you how the above operations may be performed in Express. Along the way we'll extend the LocalLibrary website to allow users to create, edit and delete items from the library.

+ +
+

Note: We haven't looked at how to restrict particular routes to authenticated or authorised users, so at this point any user will be able to make changes to the database.

+
+ +

HTML Forms

+ +

First a brief overview of HTML Forms. Consider a simple HTML form, with a single text field for entering the name of some "team", and its associated label:

+ +

Simple name field example in HTML form

+ +

The form is defined in HTML as a collection of elements inside <form>...</form> tags, containing at least one input element of type="submit".

+ +
<form action="/team_name_url/" method="post">
+    <label for="team_name">Enter name: </label>
+    <input id="team_name" type="text" name="name_field" value="Default name for team.">
+    <input type="submit" value="OK">
+</form>
+ +

While here we have included just one (text) field for entering the team name, a form may contain any number of other input elements and their associated labels. The field's type attribute defines what sort of widget will be displayed. The name and id of the field are used to identify the field in JavaScript/CSS/HTML, while value defines the initial value for the field when it is first displayed. The matching team label is specified using the label tag (see "Enter name" above), with a for field containing the id value of the associated input.

+ +

The submit input will be displayed as a button (by default)—this can be pressed by the user to upload the data contained by the other input elements to the server (in this case, just the team_name). The form attributes define the HTTP method used to send the data and the destination of the data on the server (action):

+ + + +

Form handling process

+ +

Form handling uses all of the same techniques that we learned for displaying information about our models: the route sends our request to a controller function which performs any database actions required, including reading data from the models, then generates and returns an HTML page. What makes things more complicated is that the server also needs to be able to process data provided by the user, and redisplay the form with error information if there are any problems.

+ +

A process flowchart for processing form requests is shown below, starting with a request for a page containing a form (shown in green):

+ +

As shown in the diagram above, the main things that form handling code needs to do are are:

+ +
    +
  1. Display the default form the first time it is requested by the user. +
      +
    • The form may contain blank fields (e.g. if you're creating a new record), or it may be pre-populated with initial values (e.g. if you are changing a record, or have useful default initial values).
    • +
    +
  2. +
  3. Receive data submitted by the user, usually in an HTTP POST request.
  4. +
  5. Validate and sanitize the data.
  6. +
  7. If any data is invalid, re-display the form—this time with any user populated values and error messages for the problem fields.
  8. +
  9. If all data is valid, perform required actions (e.g. save the data in the database, send a notification email, return the result of a search, upload a file, etc.)
  10. +
  11. Once all actions are complete, redirect the user to another page.
  12. +
+ +

Often form handling code is implemented using a GET route for the initial display of the form and a POST route to the same path for handling validation and processing of form data. This is the approach that will be used in this tutorial!

+ +

Express itself doesn't provide any specific support for form handling operations, but it can use middleware to process POST and GET parameters from the form, and to validate/sanitize their values.

+ +

Validation and sanitization

+ +

Before the data from a form is stored it must be validated and sanitized:

+ + + +

For this tutorial we'll be using the popular express-validator module to perform both validation and sanitization of our form data.

+ +

Installation

+ +

Install the module by running the following command in the root of the project.

+ +
npm install express-validator --save
+
+ +

Using express-validator

+ +
+

Note: The express-validator guide on  Github provides a good overview of API. We recommend you read that to get an idea of all its capabilities (including creating custom validators). Below we cover just a subset that is useful for the LocalLibrary.

+
+ +

To use the validator in our controllers we have to require the functions we want to use from the 'express-validator/check' and 'express-validator/filter' modules, as shown below:

+ +
const { body,validationResult } = require('express-validator/check');
+const { sanitizeBody } = require('express-validator/filter');
+
+ +

There are many functions available, allowing you to check and sanitize data from request parameters, body, headers, cookies, etc., or all of them at once. For this tutorial, we'll primarily be using bodysanitizeBody, and validationResult (as "required" above).

+ +

The functions are defined as below:

+ + + +

The validation and sanitization chains are middleware that should be passed to the Express route handler (we do this indirectly, via the controller). When the middleware runs, each validator/sanitizer is run in the order specified.

+ +

We'll cover some real examples when we implement the LocalLibrary forms below.

+ +

Form design

+ +

Many of the models in the library are related/dependent—for example, a Book requires an Author, and may also have one or more Genres. This raises the question of how we should handle the case where a user wishes to:

+ + + +

For this project we will simplify the implementation by stating that a form can only:

+ + + +
+

Note: A more "robust" implementation might allow you to create the dependent objects when creating a new object, and delete any object at any time (for example, by deleting dependent objects, or by removing references to the deleted object from the database).

+
+ +

Routes

+ +

In order to implement our form handling code we will need two routes that have the same URL pattern. The first (GET) route is used to display a new empty form for creating the object. The second route (POST) is used for validating data entered by the user, and then saving the information and redirecting to the detail page (if the data is valid) or redisplaying the form with errors (if the data is invalid).

+ +

We have already created the routes for all our model's create pages in /routes/catalog.js (in a previous tutorial). For example, the genre routes are shown below:

+ +
// GET request for creating a Genre. NOTE This must come before route that displays Genre (uses id).
+router.get('/genre/create', genre_controller.genre_create_get);
+
+// POST request for creating Genre.
+router.post('/genre/create', genre_controller.genre_create_post);
+
+ +

Express forms subarticles

+ +

The following subarticles will take us through the process of adding the required forms to out example application. You need to read and work through each one in turn, before moving on to the next one.

+ +
    +
  1. Create Genre form — Defining our page to create Genre objects.
  2. +
  3. Create Author form — Defining a page for creating Author objects.
  4. +
  5. Create Book form — Defining a page/form to create Book objects.
  6. +
  7. Create BookInstance form — Defining a page/form to create BookInstance objects.
  8. +
  9. Delete Author form — Defining a page to delete Author objects.
  10. +
  11. Update Book form — Defining  page to update Book objects.
  12. +
+ +

Challenge yourself

+ +

Implement the delete pages for the Book, BookInstance, and Genre models, linking them from the associated detail pages in the same way as our Author delete page. The pages should follow the same design approach:

+ + + +

A few tips:

+ + + +

Implement the update pages for the BookInstance, Author, and Genre models, linking them from the associated detail pages in the same way as our Book update page.

+ +

A few tips:

+ + + +

Summary

+ +

Express, node, and third party packages on NPM provide everything you need to add forms to your website. In this article you've learned how to create forms using Pug, validate and sanitize input using express-validator, and add, delete, and modify records in the database.

+ +

You should now understand how to add basic forms and form-handling code to your own node websites!

+ +

See also

+ + + +

{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs/deployment", "Learn/Server-side/Express_Nodejs")}}

+ +

In this module

+ + + +

 

diff --git a/files/ms/learn/server-side/express_nodejs/index.html b/files/ms/learn/server-side/express_nodejs/index.html new file mode 100644 index 0000000000..968f3e40e2 --- /dev/null +++ b/files/ms/learn/server-side/express_nodejs/index.html @@ -0,0 +1,77 @@ +--- +title: Express web framework (Node.js/JavaScript) +slug: Learn/Server-side/Express_Nodejs +tags: + - Beginner + - CodingScripting + - Express + - Express.js + - Intro + - JavaScript + - Learn + - NeedsTranslation + - Node + - Server-side programming + - TopicStub + - node.js +translation_of: Learn/Server-side/Express_Nodejs +--- +
{{LearnSidebar}}
+ +

Express is a popular unopinionated web framework, written in JavaScript and hosted within the node.js runtime environment. The module explains some of the key benefits of this framework, how to set up your development environment and how to perform common web development and deployment tasks.

+ +

Prerequisites

+ +

Before starting this module you will need to understand what server-side web programming and web frameworks are, ideally by reading the topics in our Server-side website programming first steps module. A general knowledge of programming concepts and JavaScript is highly recommended, but not essential to understanding the core concepts.

+ +
+

Note: This website has many useful resources for learning JavaScript in the context of client-side development: JavaScriptJavaScript Guide, JavaScript BasicsJavaScript (learning). The core JavaScript language and concepts are the same for server-side development on Node.js and this material will be relevant. Node.js offers additional APIs for supporting functionality that is useful in browserless environments, e.g. to create HTTP servers and access the file system, but does not support JavaScript APIs for working with the browser and DOM.

+ +

This guide will provide some information about working with Node.js and Express, and there are numerous other excellent resources on the Internet and in books — some of these linked from How do I get started with Node.js (StackOverflow) and What are the best resources for learning Node.js? (Quora).

+
+ +

Guides

+ +
+
Express/Node introduction
+
In this first Express article we answer the questions "What is Node?" and "What is Express?" and give you an overview of what makes the Express web framework special. We'll outline the main features, and show you some of the main building blocks of an Express application (although at this point you won't yet have a development environment in which to test it).
+
Setting up a Node (Express) development environment
+
Now that you know what Express is for, we'll show you how to set up and test a Node/Express development environment on Windows, Linux (Ubuntu), and Mac OS X. Whatever common operating system you are using, this article should give you what you need to be able to start developing Express apps.
+
Express Tutorial: The Local Library website
+
The first article in our practical tutorial series explains what you'll learn, and provides an overview of the "local library" example website we'll be working through and evolving in subsequent articles.
+
Express Tutorial Part 2: Creating a skeleton website
+
This article shows how you can create a "skeleton" website project, which you can then go on to populate with site-specific routes, templates/views, and databases.
+
Express Tutorial Part 3: Using a Database (with Mongoose)
+
This article briefly introduces databases for Node/Express. It then goes on to show how we can use Mongoose to provide database access for the LocalLibrary website. It explains how object schema and models are declared, the main field types, and basic validation. It also briefly shows a few of the main ways you can access model data.
+
Express Tutorial Part 4: Routes and controllers
+
In this tutorial we'll set up routes (URL handling code) with "dummy" handler functions for all the resource endpoints that we'll eventually need in the LocalLibrary website. On completion, we'll have a modular structure for our route handling code, that we can extend with real handler functions in the following articles. We'll also have a really good understanding of how to create modular routes using Express.
+
Express Tutorial Part 5: Displaying library data
+
We're now ready to add the pages that display the LocalLibrary website books and other data. The pages will include a home page that shows how many records we have of each model type, and list and detail pages for all of our models. Along the way we'll gain practical experience in getting records from the database, and using templates.
+
Express Tutorial Part 6: Working with forms
+
In this tutorial we'll show you how to work with HTML Forms in Express, using Pug, and in particular how to write forms to create, update, and delete documents from the database.
+
Express Tutorial Part 7: Deploying to production
+
Now you've created an awesome LocalLibrary website, you're going to want to install it on a public web server so that it can be accessed by library staff and members over the Internet. This article provides an overview of how you might go about finding a host to deploy your website, and what you need to do in order to get your site ready for production.
+
+ +

See also

+ +
+
Installing LocalLibrary on PWS/Cloud Foundry
+
This article provides a practical demonstration of how to install LocalLibrary on the Pivotal Web Services PaaS cloud — this is a full-featured, open source alternative to Heroku, the PaaS cloud service used in Part 7 of the tutorial, listed above. PWS/Cloud Foundry is definitely worth checking out if you are looking for an alternative to Heroku (or another PaaS cloud service), or simply feel like trying something different.
+
+ +

Adding more tutorials

+ +
+

That's the end of the tutorial articles (for now). If you would like to extend it, other interesting topics to cover are:

+ + + +

And of course it would be excellent to have an assessment task!

+
diff --git a/files/ms/learn/server-side/index.html b/files/ms/learn/server-side/index.html new file mode 100644 index 0000000000..b497257371 --- /dev/null +++ b/files/ms/learn/server-side/index.html @@ -0,0 +1,59 @@ +--- +title: Server-side website programming +slug: Learn/Server-side +tags: + - Beginner + - CodingScripting + - Intro + - Landing + - Learn + - NeedsTranslation + - Server + - Server-side programming + - Topic + - TopicStub +translation_of: Learn/Server-side +--- +
{{LearnSidebar}}
+ +

The Dynamic Websites  Server-side programming topic is a series of modules that show how to create dynamic websites; websites that deliver customised information in response to HTTP requests. The modules provide a generic introduction to server-side programming, along with specific beginner-level guides on how to use the Django (Python) and Express (Node.js/JavaScript) web frameworks to create basic applications.

+ +

Most major websites use some kind of server-side technology to dynamically display different data as required. For example, imagine how many products are available on Amazon, and imagine how many posts have been written on Facebook? Displaying all of these using completely different static pages would be completely inefficient, so instead such sites display static templates (built using HTML, CSS, and JavaScript), and then dynamically update the data displayed inside those templates when needed, e.g. when you want to view a different product on Amazon.

+ +

In the modern world of web development, learning about server-side development is highly recommended.

+ +

Learning pathway

+ +

Getting started with server-side programming is usually easier than with client-side development, because dynamic websites tend to perform a lot of very similar operations (retrieving data from a database and displaying it in a page, validating user-entered data and saving it in a database, checking user permissions and logging users in, etc.), and are constructed using web frameworks that make these and other common web server operations easy.

+ +

A basic knowledge of programming concepts (or of a particular programming language) is useful, but not essential. Similarly, expertise in client-side coding is not required, but a basic knowledge will help you work better with the developers creating your client-side web "front end".

+ +

You will need to understand "how the web works". We recommend that you first read the following topics:

+ + + +

With that basic understanding you'll be ready to work your way through the modules in this section. 

+ +

Modules

+ +

This topic contains the following modules. You should start with the first module, then go on to one of the following modules, which show how to work with two very popular server-side languages using appropriate web frameworks . 

+ +
+
Server-side website programming first steps
+
This module provides server-technology-agnostic information about server-side website programming, including answers to fundamental questions about server-side programming — "what it is", "how it differs from client-side programming", and "why it is so useful" — and an overview of some of the more popular server-side web frameworks and guidance on how to select the most suitable for your site. Lastly we provide an introductory section on web server security.
+
Django Web Framework (Python)
+
Django is an extremely popular and fully featured server-side web framework, written in Python. The module explains why Django is such a good web server framework, how to set up a development environment and how to perform common tasks with it.
+
Express Web Framework (Node.js/JavaScript)
+
Express is a popular web framework, written in JavaScript and hosted within the node.js runtime environment. The module explains some of the key benefits of this framework, how to set up your development environment and how to perform common web development and deployment tasks.
+
+ +

See also

+ +
+
Node server without framework
+
This article provides a simple static file server built with pure Node.js, for those of you not wanting to use a framework.
+
diff --git a/files/ms/learn/soalan_lazim/index.html b/files/ms/learn/soalan_lazim/index.html new file mode 100644 index 0000000000..b7fbc07a0f --- /dev/null +++ b/files/ms/learn/soalan_lazim/index.html @@ -0,0 +1,119 @@ +--- +title: Soalan-soalan lazim +slug: Learn/Soalan_lazim +translation_of: Learn/Common_questions +--- +
{{LearnSidebar}}
+ +

This section of the Learning Area is designed to provide answers to common questions that may come up, which are not necessarily part of the structured core learning pathways (e.g. the HTML or CSS learning articles.) These articles are designed to work on their own.

+ +
+

Soalan-soalan tentang HTML dan CSS

+ +

Anda boleh cuba halaman Guna HTML untuk menyelesaikan masalah-masalah lazim dan halaman Guna CSS untuk menyelesaikan masalah-masalah lazim bagi penyelesaian-penyelesaian biasa kepada masalah-masalah HTML/CSS.

+
+ +

Bagaimana Web berfungsi

+ +

Bahagian ini merangkumkan mekanikal web — soalan-soalan yang berkaitan pengetahuan umum tentang ekosistem Web dan bagaimana ia berfungsi.

+ +
+
+

Bagaimanakah Internet berfungsi?

+
+
Internet adalah tulang belakang Web, infrastruktur teknikal yang membolehkan Web berfungsi. Pada asasnya, Internet adalah sebuah rangkaian besar yang merangkumi komputer-komputer yang berkomunikasi semuanya sekali. Artikel ini membincangkan bagaimana ia berfungsi, pada peringkat asasnya.
+
+

Apakah perbezaan antara halaman web, laman web, pelayan web, dan engin carian?

+
+
Dalam artikel ini kami menerangkan pelbagai konsep yang berkaitan dengan web: halaman web, laman web, pelayan web, dan engin carian. Istilah-istilah ini sering mengelirukan pendatang baru Web, atau digunakan secara tidak tepat. Mari kita belajar apa makna setiap istilah ini!
+
+

Apakah itu URL?

+
+
Dengan {{Glossary("Hypertext")}} dan {{Glossary("HTTP")}}, URL adalah salah satu konsep penting Web. Ia adalah mekanisme yang digunakan {{Glossary("Browser","browsers")}} untuk mendapatkan sumber yang telah diterbitkan di web.
+
+

Apakah itu nama domain?

+
+
Nama-nama domain adalah bahagian penting daripada infrastruktur Internet. Mereka menyediakan alamat yang difahami manusia untuk mana-mana pelayan web yang ada di Internet.
+
+

Apakah itu pelayan web?

+
+
Istilah "Pelayan Web" boleh merujuk kepada perkakasan atau perisian yang menyediakan laman web kepada klien-klien di seluruh Web  — atau kedua-duanya berfungsi bersama-sama. Dalam artikel ini kami akan pergi ke bagaimana pelayan-pelayan web berfungsi, and kenapa ianya penting.
+
+ +
+
Dalam artikel ini, kita akan pergi ke apa itu hyperlink dan kenapa ianya penting.
+
+ +

Alatan dan tetapan

+ +

Soalan-soalan yang berkaitan dengan alatan/perisian yang anda boleh gunakan untuk membina laman web.

+ +
+
+

Berapakah kos yang diperlukan untuk membina sesuatu di Web?

+
+
Anda mungkin tidak perlu membelanjakan apa-apa atau kos anda mungkin melambung tinggi. Dalam artikel ini kami membincangkan berapa banyak kos yang diperlukan untuk semua dan apa yang anda dapat hasil daripada apa yang anda bayar(atau anda tidak bayar).
+
+

Apakah perisian yang saya perlukan untuk membina laman web?

+
+
Dalam artikel ini kami menerangkan komponen-komponen perisian yang mana anda perlukan apabila anda mengedit, memuat naik, atau memaparkan laman web.
+
+

Apakah editor teks yang ada?

+
+
Dalam artikel ini kami menekankan beberapa perkara apabila memilih dan memasang editor teks untuk pembangunan web. 
+
+

Bagaimanakah untuk saya menetapkan persekitaran kerja?

+
+
Apabila anda mengerjakan sebuah projek web, anda akan ingin untuk mengujinya di dalam persekitaran komputer anda sebelum anda tunjuknya ke dunia. Sesetengah jenis kod memerlukan sebuah pelayan untuk ujian, dan di dalam artikel ini kami akan menunjukkan anda bagaimana untuk menetapkan satu. Kami juga akan membahas bagaimana untuk menempatkan struktur berskala supaya fail-fail anda tetap tersusun walaupun projek anda berkembang besar.
+
+

Apakah alatan pembangun pelayar web?

+
+
Setiap pelayar web mempunyai satu set alat pembangun untuk menyahpepijat HTML,CSS dan kod web lain. Artikel ini menerangkan bagaimana untuk menggunakan fungsi-fungsi asas alat pembangun yang disediakan pelayar web anda.
+
+

How do you make sure your website works properly?

+
+
So you've published your website online — very good! But are you sure it works properly? This article provides some basic troubleshooting steps.
+
+

How do you upload files to a web server?

+
+
This article shows how to publish your site online with FTP tools — one fo the most common ways to get a website online so others can access it from their computers.
+
+

How do I use GitHub Pages?

+
+
This article provides a basic guide to publishing content using GitHub's gh-pages feature.
+
+

How do you host your website on Google App Engine?

+
+
Looking for a place to host your website? Here's a step-by-step guide to hosting your website on Google App Engine.
+
+

What tools are available to debug and improve website performance?

+
+
This set of articles shows you how to use the Developer Tools in Firefox to debug and improve performance of your website, using the tools to check the memory usage, the JavaScript call tree, the amount of DOM nodes being rendered, and more.
+
+ +

Design and accessibility

+ +

This section lists questions related to aesthetics, page structure, accessibility techniques, etc.

+ +
+
+

How do I start to design my website?

+
+
This article covers the all-important first step of every project: define what you want to accomplish with it.
+
+

What do common web layouts contain?

+
+
When designing pages for your website, it's good to have an idea of the most common layouts. This article runs thorugh some typical web layouts, looking at the parts that make up each one.
+
+

What is accessibility?

+
+
This article introduces the basic concepts behind web accessibility.
+
+

How can we design for all types of users?

+
+
This article provides basic techniques to help you design websites for any kind of user — quick accessibility wins, and other such things.
+
+

What HTML features promote accessibility?

+
+
This article describes specific features of HTML that can be used to make a web page more accessible to people with different disabilities.
+
-- cgit v1.2.3-54-g00ecf