Module:Layout

Uit Wikibooks
 Deze module is nog in ontwikkeling (versie 0.0) en wordt getest.

De Module:Layout is bedoeld om snel, consistent en uitgebreid een pagina op te maken.
Er is een op de module afgestemde handleiding over deze onderwijswiki beschikbaar.

De module wordt geïnitialiseerd met de configuratie in Module:Layout/Production/Configuration.

Controleer op scriptfouten of opmaak notificaties.

De module Layout werkt nauw samen met het sjabloon Opmaak. Directe benadering door gebruikers van deze module wordt dan ook ontraden en ook tegengehouden waar mogelijk. Voor het gebruik van de module verwijzen we daarom naar de sjabloonbeschrijving van het sjabloon Opmaak.

Subpagina's[bewerken]

Omgevingen[bewerken]

Module Migratie
Sandbox Development Stage Production
  • Module A
  • Module B

test
  • Module A
  • Module B

test
  • Module A
  • Module B

test
  • Module A
  • Module B

Opbouw[bewerken]

MVC Pattern
Model View Controller

Model
Content
Configuration
Language
Style

View

Layout
Interface
Library

Test

Deze module is gebouwd om via een interface de aanroeper door te sturen naar specifieke functionaliteit behorende bij het type Opmaak gegroepeerd onder Module:Layout/Production/View. Onder Module:Layout/Production/Test zijn alle testfuncties gebundeld. De library Module:Layout/Production/Library heeft verzameld alle functies die door meerdere modules worden gebruikt en geen andere modules aanroepen. Alle instellingen zoals de berichten en de structuur van deze module zijn ondergebracht bij Module:Layout/Production/Configuration. Ook is er een ontwikkelomgeving ingericht onder Module:Layout/Sandbox. Samengevat:

Hoofdmodules onder Layout
Hoofdmodule Activiteit Omschrijving
Module:Layout inrichten module die juiste omgeving voor het systeem inricht.
Module:Layout/Production/View weergeven modules die nieuwe wikibooks-objecten weergeven.
Module:Layout/Production/Interface communiceren modules die de communicatie tussen de aanroepende wikipagina en de module Layout afhandelen.
Module:Layout/Production/Library opbouwen modules die bouwstenen vormen voor andere modules.
Module:Layout/Production/Content creëren modules die de speciale inhoud van bepaalde wikibooks-objecten creëren.
Module:Layout/Production/Model verrijken modules die de bestaande gegevens verrijken zodat ze geschikt zijn voor wikibooks-objecten.
Module:Layout/Production/Configuration configureren modules die de werking van andere modules configureren.
Module:Layout/Production/Language vertalen modules die in de taal van de gebruiker communiceren.
Module:Layout/Production/Style stijlen modules die in de stijl van de weergave instellen.
Module:Layout/Production/Test testen modules die testen.

Hooks[bewerken]

Objecten[bewerken]

Om functionaliteit toe te voegen of aan te passen haken we de nieuwe of aan te passen module in met exact de naam (in Engels) van het wikiobject dat we toevoegen. Dat dient in ieder geval te gebeuren onder de view (we moeten toch iets laten zien). We moeten ook berichten in de geldende taal wat de naam van het wikiobject is door deze toe te voegen door de een module te zetten met dezelfde naam onder de language modules. Afgestemde inhoud zullen we meestal creëren door wederom met exact dezelfde naam (in het Engels) te plaatsen onder de topmodule content. Daarna kunnen we bij een nieuwe module in het configuratiebestand Configuratie/Hook een haakje zetten (een extra element toevoegen aan de tabel HOOK.OBJECT) zodat het systeem onze nieuwe module opneemt. Ook passen we de bijbehorende test aan of maken een nieuwe. Hetzelfde doen we voor de documentatie. Het aangepast of nieuwe object is zoveel mogelijk afgezonderd van andere objecten om onderlinge impact bij fouten te voorkomen.

Wiki-objecten toevoegen of Wijzigen
Configuratie/Hook (Vereist) View (Vereist) Language (Vereist) Content (Optioneel) Test (Vereist) Sjabloon (Vereist)
  • Haak een nieuwe module of de gewijzigde module in de tabel HOOK.OBJECT
  • Koppel een nieuwe module of de gewijzigde module onder de bovenste module genaamd Weergave
  • Gebruik de WikiObjectNaam
  • Voeg berichten toe in de juiste talen onder de bovenste module Taal
  • Gebruik de WikiObjectNaam
  • Beheers de inhoud van het WikiObject door een module toe te voegen onder de bovenste module Inhoud
  • Voeg tests voor de nieuwe functionaliteit toe.
  • Beschrijf het gebruik van de nieuwe functionaliteit.

Parameters[bewerken]

Op dezelfde manier als bij de objecten kan men ook nieuwe parameters aanmaken of aanpassen. Indien mogelijk is het advies dat niet toe doen omdat dit wel meer impact heeft dan objecten en een te lange lijst van mogelijke parameters het overzichtelijk gebruik zal afremmen. Probeer zoveel mogelijk de bestaande parameters te gebruiken of de unnamed parameters. Als men toch een parameter nodig heeft dan haakt men die in eveneens in de configuratie module Module:Layout/Production/Configuration/Hook onder HOOK.PARAMETER. Zorg dat hij ook op de juiste plek in de language module komt (Module:Layout/Production/Language/Nl) in de naam van de geïnstalleerde taal. Daarna kan men door een functie aan te maken of aan te passen in Module:Layout/Production/Interface/Frisk de inhoud van deze parameter checken en de foutmelding met eventuele parameters teruggeven als return waarde. Bij een fout zal het programma vanzelf verder uitvoering voorkomen en op grond van ingestelde support een foutmelding weergeven. Daarna kan men de inhoud converteren en/of aanvullen zodat het voor verder gebruik veilig en volledig is als inventaris (Module:Layout/Production/Model/Inventory). Het streven is dat de gegevens uit het model zonder verdere modificatie zijn te gebruiken bij de weergave (view). Test de parameter zeer grondig als bouwsteen ook voor andere objecten en voeg de juiste documentatie toe aan het sjabloon.

Wiki-objecten toevoegen of Wijzigen
Configuratie/Hook (Vereist) Frisk (Vereist) Language (Vereist) Inventory (Optioneel) Test (Vereist) Sjabloon (Vereist)
  • Haak een nieuwe parameter of de gewijzigde parameter in de tabel HOOK.PARAMETER
  • Koppel een nieuwe functie of de gewijzigde functie onder de veiligheidsmodule voor het fouilleren
  • Gebruik de WikiObjectNaam
  • Voeg berichten toe in de juiste talen onder de bovenste module Taal
  • Gebruik de WikiObjectNaam
  • Beheers de inhoud van de parameter door een functie toe te voegen onder de modelmodule voor de inventaris
  • Voeg tests voor de nieuwe functionaliteit toe.
  • Beschrijf het gebruik van de nieuwe functionaliteit.

Aanroep[bewerken]

De interface van de module vindt men onderin de code en gebeurt via de aanroep {{#Invoke:Layout|main|...}} en dan kiest of de gebruiker of het systeem zelf op grond van pagina-eigenschappen welke type pagina het is.

Tests[bewerken]

OOjs_UI_icon_chem In Module:Layout/Production/Test worden de tests gespecificeerd die zijn uitgevoerd.

Zie ook[bewerken]

Code[bewerken]



-- All Scribunto libraries are located in the global table mw.
-- All variables of this module should be explicitly scoped as a local variable.
-- However this is not as STRICT as we think.
-- When you have a table in Lua and you create a reference to that table, you're essentially creating a "shared" access to the same table.
-- It may not be a global variable in the strictest sense, but it can have similar behavior.
require( "strict" );

-- A call to a module uses the parserfunction {{#invoke:...}} where ... is the modulename. In this case Layout.
-- The return value stores the functions which are given as a first argument ... when using {{#invoke:Layout|...}}
-- The variable layout collects these functions.
local layout = {};

-- Functions called by {{#invoke:}} will be passed a frame object as single parameter.
-- This Frame-object contains the parameters passed to {{#invoke:}}, and can be used to access context-specific features of the wikitext parser.
-- In this module the main function directs to the interface through four functions specifying the environment
-- (production, stage, development, sandbox) called by {{{{#invoke:Layout|<environment>|...}}.
-- The {{#invoke:Layout|main|...}} call is checked on errors and if so the errors are returned to inform the user if the user has not turned off showing errors.
-- When no errors are found or the user has set to ignore errors, the corresponding environment en submodules are invoked.
function layout.main( frame, environment )
    -- In the Scribunto extension for MediaWiki, 
    -- when you invoke a function from a module in a template, 
    -- the function is called with a single argument, the frame object. 
    -- If your function definition has additional parameters, 
    -- these additional arguments will not receive values when the function is called 
    -- through the template.
    -- The configuration data depends on the environment
    -- So if the user has call this main function directly 
    -- the environment variable will always be nil
    -- We then default the environment to the production environment
    -- to prevent accidental calling untested functionality.
	if environment == nil then environment = "production"; end

    -- The default configuration data is stored in the CFG variable of the production environment.
    -- The path is the only hardcoded data outside the configuration data.
    -- Now load the CFG from the correct environment
    local CFG = require( 'Module:Layout/' .. environment:gsub( "^%l", string.upper ) .. '/Configuration' );

    -- The interface of the Module:Layout validates the call and redirects it to the correct system for further actions.
    local interface = CFG.INCLUDE( environment, "interface" );

    -- The interface recieves the frame, the configuration data and the environment as input and returns always a valid response
	return interface.main( frame, CFG, environment );
end

-- Loads the production environment. This environment is the actual used and tested functionality of the Module:Layout.
function layout.production( frame )
    return layout.main( frame, "production" );
end

-- Loads the stage environment. This environment is reserved for putting new of changed functionality waiting to be updated to the production environment.
function layout.stage( frame )
    return layout.main( frame, "stage" );
end

-- Loads the development environment. This environment is reserved for developing new of changed functionality. If finished it is moved to the stage environment.
function layout.development( frame )
    return layout.main( frame, "development" );
end

-- Loads the sandbox environment. This environment is for playing or trying out without concrete developing new of changed functionality.
function layout.sandbox( frame )
    return layout.main( frame, "sandbox" );
end

-- The module returns a Lua table containing the functions that may be called by {{#invoke:}} stored in the variable layout.
return layout;
Informatie afkomstig van https://nl.wikibooks.org Wikibooks NL.
Wikibooks NL is onderdeel van de wikimediafoundation.