Enrich Plone with Svelte Interactions
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 38 | |
Author | ||
License | CC Attribution 3.0 Germany: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/55560 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | |
Genre |
World Plone Day, 202114 / 38
4
5
16
24
27
28
31
34
37
38
00:00
Plane (geometry)Expert systemTemplate (C++)Element (mathematics)Line (geometry)Client (computing)Installation artComponent-based software engineeringInteractive televisionCodeEmailWeb browserOpen setText editorMathematicsInformationTable (information)Content (media)Execution unitGroup actionEvent horizonoutputFree variables and bound variablesEuclidean vectorSource codeInformationMonster groupBookmark (World Wide Web)Home pageOrder (biology)Universe (mathematics)Multiplication signBitForestKeyboard shortcutContent management systemLevel (video gaming)Open setClient (computing)Mobile appBuildingExpert systemClassical physicsBit rateConnectivity (graph theory)PlanningCodeWeb pageState of matterSinc functionExpressionScripting languageFilter <Stochastik>Group actionMusical ensembleElectronic visual displayField (computer science)ResultantWebsiteMereologySheaf (mathematics)Markup languageString (computer science)Directory serviceVariable (mathematics)Point (geometry)Form (programming)outputFunctional (mathematics)Type theoryDefault (computer science)Computer fileCloningCASE <Informatik>Computer animation
05:37
Expert systemPlane (geometry)InformationTable (information)Content (media)Interactive televisionSocial classComponent-based software engineeringGroup actionEvent horizonFree variables and bound variablesoutputString (computer science)Euclidean vectorVariable (mathematics)EmailScripting languageNormed vector spaceLoop (music)User interfaceMembrane keyboardCloud computingSelf-organizationDisintegrationGamma functionSoftware testingProcess (computing)Default (computer science)Uniform resource locatorFunction (mathematics)Dependent and independent variablesFingerprintMilitary operationError messageData typeComputer networkSheaf (mathematics)LogicVideo game consoleConfiguration spaceInstallation artSoftware developerInterface (computing)MereologyInternational Date LineCloningInstance (computer science)Patch (Unix)Computer virusMobile appParameter (computer programming)Expert systemConnectivity (graph theory)Water vaporElectronic visual displayInformationUniverse (mathematics)Electronic mailing listWorkstation <Musikinstrument>Dependent and independent variablesNeuroinformatikINTEGRALSystem callMotherboardForm (programming)Mobile appState of matterSingle-precision floating-point formatMusical ensembleMultiplication signForestSkeleton (computer programming)Variable (mathematics)Loop (music)PlastikkarteScripting languageSheaf (mathematics)String (computer science)Revision controlPhase transitionRepresentational state transferComputer fileFunctional (mathematics)Line (geometry)MereologyDeclarative programmingDefault (computer science)Field (computer science)Type theoryoutputResultantAddress spaceXML
11:14
Sheaf (mathematics)InformationVideo game consoleError messageConfiguration spaceComputer networkPlastikkarteExpert systemInstance (computer science)Table (information)Plane (geometry)Component-based software engineeringInteractive televisionWeb browserInstallation artWebsiteText editorOpen setMathematicsInvariant (mathematics)Graphic designMobile appComputer virusBuildingMaizeDefault (computer science)Markup languageScale (map)Mobile appExpert systemCodeBuildingCloningWebsiteSocial classInteractive televisionWeb pageAsynchronous Transfer ModeSoftware developerCASE <Informatik>Product (business)BitComplex (psychology)Online chatINTEGRALComputer-assisted translationMedical imagingInformationXML
13:01
Expert systemComputer virusMobile appBuildingPlastikkarteDefault (computer science)Markup languageInformationWebsiteMaizeScale (map)Table (information)Content (media)Interactive televisionComponent-based software engineeringDiscrete element methodWebsiteInternetworkingWave packetOnline helpFigurate numberFlagSuite (music)Software development kitDefault (computer science)Constructor (object-oriented programming)Multiplication signField (computer science)MereologyGoodness of fitExpert systemScripting languageSource code
Transcript: English(auto-generated)
00:03
Hi, I'm Katja from Zurich and some weeks ago I realized a little expert search integrated in a Plone Classic site and I would like to show you how you can achieve this. I've already opened my Plone site with a welcome page and I integrated a little
00:31
experts, Lisa Meyer, John Sommer. You see two examples and I want to have a search field and I want to filter per region. So how can we do this? Everything we do now, we
00:56
can do in one Plone add-on. So we start creating one. You have the Plone command line client
01:05
installed and you create a new Plone add-on, greenthumb expert search. You change to the directory and you add the Svelte code skeleton. This is a good point to start and then you
01:26
answer the questions, you name your Svelte app expert search plus and you change to this created directory named expert search plus in the Svelte source code directory.
01:44
You install the Svelte app and you start it with npm run dev. And then the Svelte is already running on port 10,001 and looks like this path here under the information
02:09
where you can find some more information about Svelte. And then we will build step by step this form with displaying the search results. And we start with the form. And
02:34
for this form, we create one file expert search Svelte. The file name already says
02:43
that the component we are now building has the name expert search, which we will later on integrate in our Svelte app. And this Svelte app we integrate in the home page of the Plone site. So we will build a simple Svelte component here. We have in Svelte
03:06
always three parts. First some JavaScript code, then the markup. And later on we will theme a little bit, then we will have a third section style. Okay, and this what's now
03:26
highlighted is our form. We have an input field here. And we have the region buttons for filtering per region. And what you see here is that we bind the input value to
03:51
a variable search string. And this binding means that our variable here, that search
04:01
string defaults to an empty string is updated as soon as the user types in a search string. So if you're familiar with React, this is a little bit like a component state. So
04:20
we have our search string and we have, we define another variable region. And this should be set by clicking of the user to a region button. He wants to filter per region, wants to see experts only from one region. So we have here our button and we have a click
04:44
handler here. And the click handler handle click region is defined above in the script part here. And the click handler does not explicitly call a fetch of data, but it only sets the
05:07
component state region. Same as the what happens when a user types in a search string. So we have our component state and this we use to fetch the data. So I add
05:28
in the next step a function which can fetch data from the backend, in this case our clone site we are in. Before I want to show how you can integrate this simple
05:47
form of a component. The main part, I cannot find the right word,
06:02
is the Svelte app. You can find it in the file app Svelte. And this is if you start with Svelte's skeleton code, you have a short script section and you have the main part where you can include your components that you build. And now we will only include our expert
06:25
search component. And when you now start Svelte, you will see additional to the welcome text that you will see the form for the input field and the buttons.
06:46
And then the next step would be, so this would look like this. And before I start with the fetching asynchronous function, here's one thing that is also
07:04
interesting and very essential, typical for Svelte. These are simple variable declarations but they act as a component state. So you can display them and they are automatically updated.
07:29
So if I want to show under the form information what the user typed in, which filter you selected, I can write something like this that we are showing later on results for the search string
07:50
and a region. And this is our variable search string, our variable region.
08:00
And this is automatically re-rendered as soon as the component state changes. So if the user types in here, this info line will be updated instantaneously. So okay, next step.
08:26
The function that will fetch data from Plone, it will fetch by addressing the REST API endpoint search. So if you install the REST API add-on on Plone
08:48
and you have these default endpoints available, you can address the endpoint search. So I scroll down to the asynchronous function here. I call it get experts
09:05
and it takes two arguments, search string and region. And then I use the the fetch API which takes an address where it wants to fetch
09:21
request method. And the response, I take the JSON part and I save the fetch data in my component state variable experts. And then I can work with this.
09:41
I can add some more mark. I fill these cards and I make a loop over the list of experts here. And this is one single card where I display the expert data, last name, first name and so on.
10:12
And then if you have REST API add-on installed, you will see the
10:20
you are ready to search. And then you can see something like this. Here we can search for, for example, John or we can
10:44
filter by only winter tour or only parcel. And this is the standalone version from Svelte. If I say npm run dev, Svelte is started and I
11:06
can address the Svelte app by this address. And we have seen already the integration here, our clone site by, I recall it by integrating just the snippet and the
11:37
as we have our Svelte code in our clone add-on, the JavaScript gets loaded and Svelte
11:48
sees the snippet with the class expert search plus, which indicates our Svelte app and integrates the app. So we have a welcome page like this.
12:06
That we can also search like before. Yeah, this is the expert search and
12:21
and this is now running in development mode. For deploying, I will do a production build and just for information, the size of the production build is just 88 kilobytes in this case. If you make a little bit more complex Svelte a little bit more, but I think it's interesting
12:49
that it's in fact really a small code that you're loading in your clone site. And just one more thing, micro interaction. What I really like about Svelte that you
13:08
that it brings per default really useful help us to create this behavior here. What you see
13:20
flipping the card, they are scaled, they are popping up. So I skipped the part where I define a behavior with fields for the expert. If you're interested, you can find the script online
13:43
and read the parts. It's just left to mention that there is very good information, very good tutorials about Svelte. You can find the official website svelte.dev. There's an excellent training from Maximilian Schwarzmuller.
14:03
And there are also Mozilla tutorials about Svelte. So thank you for listening. See you. Thank you.