4747
4848 < h1 > The Pad module</ h1 >
4949
50- < p >
51- On this page you'll find some examples from the Pad module. See < a
52- href ="https://solid.github.io/solid-ui/Documentation/api/modules/_pad_.html#pad "> API
53- documentation</ a > for more info about how to use the pad module.
54- </ p >
55-
5650 < article id ="notepad ">
5751 < h2 >
5852 < a href ='#notepad '>
59- < code > notepad</ code > : Working with the Notepad
53+ < code > notepad</ code > : Creates a notepad
6054 </ a >
6155 </ h2 >
6256 < p >
63- The Notepad provides functionality to both create a new Notepad or view/edit an existing one.
64- The code below shows an example of how to view an existing notepad.
65- < ul >
66- < li > Use the store and fetcher to fetch the notepad document.</ li >
67- < li > Provide the full path of the pad document you are fetching.</ li >
68- < li > Provide the URI of the author/editor of the document.</ li >
69- < li > Provide the full path of the subject for this pad. As you can see in the example below it is the same
70- as the pad, except you also need to include '#this'.
71- </ li >
72- < li > Optional: Provide a StatusArea property (HTMLDIVElement) to display error messages</ li >
73- </ ul >
57+ In this first example we'll see how you can create a notepad. This method creates input fields
58+ which allow you to provide a notepad component to your application.
7459 </ p >
75-
7660 < script id ='script-notepad '>
7761 window . addEventListener ( 'DOMContentLoaded' , async ( event ) => {
78- const kb = UI . store
79- const fetcher = UI . rdf . fetcher ( kb )
80- const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1585026584938/index.ttl' )
81- const me = new UI . rdf . NamedNode ( 'https://sharonstrats.inrupt.net/profile/card#me' )
82- const subject = UI . store . sym ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1585026584938/index.ttl#this' )
83- const options = { exists : true }
62+ const pad = UI . rdf . namedNode ( 'https://example-user.inrupt.net/public/example-notepad/index.ttl#this' )
63+ const me = new UI . rdf . NamedNode ( 'https://example-user.inrupt.net/profile/card#me' )
64+ const subject = UI . store . sym ( 'https://test.test#' )
65+ options = { }
8466
85- await fetcher . load ( pad . doc ( ) ) // if you don't have this you will get an inconsistency error
8667 const result = UI . pad . notepad ( document , pad . doc ( ) , subject , me , options )
8768 document . querySelector ( '#div-notepad' ) . appendChild ( result )
8869 } )
8970 </ script >
9071 < pre id ='viewSource-notepad '> </ pre >
9172 < div id ='div-notepad '> </ div >
73+ </ article >
9274
93- In order to create a new notepad you need to change three things:
94- < ul >
95- < li > Provide user authentication. You can do this by by including solid-auth-client as explained in
96- https://solidproject.org/for-developers/apps/first-app/1-authentication </ li >
97- < li > Change the exists flag on the options object to < code > false</ code > .</ li >
98- < li > Use the updater to create the document in the store, instead of using the < code > fetcher.load()</ code > function
99- above. The code below is a simple example (without error handling) to give you an idea of how this works.
100- < code > kb.updater.put(pad, [], 'text/turtle', function (pad, subject, me, options) {
101- const result = UI.pad.notepad(document, pad, subject, me, options)
102- document.querySelector('#div-notepad').appendChild(result)
103- }</ code > </ li >
104- </ ul >
75+ < article id ='manageParticipation '>
76+
77+ < h2 >
78+ < a href ='#manageParticipation '>
79+ < code > manageParticipation</ code > : Creates the table to display the participants
80+ </ a >
81+ </ h2 >
82+ < p > </ p >
83+ < script id ='script-manageParticipation '>
84+ window . addEventListener ( 'DOMContentLoaded' , ( event ) => {
85+ const me = new UI . rdf . NamedNode ( 'https://example-user.inrupt.net/profile/card#me' )
86+ const structure = document . createElement ( 'div' )
87+ const container = document . createElement ( 'div' )
88+ const subject = UI . store . sym ( 'https://test.test#' )
89+ const pad = UI . rdf . namedNode ( 'https://example-user.inrupt.net/public/example-notepad/index.ttl#this' )
90+ options = { statusArea : container }
91+ // const result = UI.pad.manageParticipation(document, structure, pad.doc(), subject, me, options)
92+ // document.querySelector('#div-manageParticipation').appendChild(result)
93+ } )
94+ </ script >
95+ < pre id ='viewSource-manageParticipation '> </ pre >
96+ < div id ='div-manageParticipation '> </ div >
10597 </ article >
98+
10699 < article id ="notepadToHTML ">
107100 < h2 >
108101 < a href ="#notepadToHTML ">
109102 < code > notepadToHTML</ code > : Converts a Turtle file to an HTML
110103 </ a >
111104 </ h2 >
112105 < p >
113- This method converts a pad document to HTML so that it can be exported .
106+ This method converts a pad.ttl document to HTML.
114107 </ p >
115108
116109 < script id ="script-notepadToHTML ">
117-
118110 window . addEventListener ( 'DOMContentLoaded' , async ( event ) => {
119111 const kb = UI . store
120112 const fetcher = UI . rdf . fetcher ( kb )
113+ // const pad = kb.sym(document.location.href.replace(/\/[^\/]*$/, "/pad.ttl#this"))
121114 const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1584238219755/index.ttl#this' )
122115 await fetcher . load ( pad . doc ( ) )
123116 const htmlStr = UI . pad . notepadToHTML ( pad , kb )
124- const doc = document . querySelector ( '#iframe-notepadToHTML' ) . contentWindow . document
125- doc . open ( )
126- doc . write ( htmlStr )
127- doc . close ( )
117+ document . querySelector ( '#div-notepadToHTML' ) . appendChild ( document . createTextNode ( htmlStr ) )
128118 } )
129119 </ script >
130120 < pre id ="viewSource-notepadToHTML "> </ pre >
131- < iframe id ="iframe-notepadToHTML " src ="about:blank "> </ iframe >
132121 < div id ="div-notepadToHTML "> </ div >
133122 </ article >
134123
135124 < article id ="lightColorHash ">
136125 < h2 >
137126 < a href ="#lightColorHash ">
138- < code > lightColorHash</ code > : Returns a color in hex format calculated by hashing a WebID
127+ < code > lightColorHash</ code > : Determines a color to be used for a participants notepad entry
139128 </ a >
140129 </ h2 >
141- < p > This method returns a hex value for setting a unique color on the input box of the notepad for a given
142- editor/user.
143- It does this by hashing the WebID passed in as an argument. Ideally this would be the WebID of the person
144- logged in. However, this function could be used in any situation where you need to have a unique color to style
145- a component based on WebIDs.
130+ < p > This method returns a hex value for setting the color of the input box of the notepad.
131+ It does this by hashing the uri passed in as an argument. Ideally this would be the uri of the person
132+ logged in.
146133 </ p >
147- < p > The example below shows how you can use the lightColorHash function.</ p >
148-
149134 < script id ="script-lightColorHash ">
150135 window . addEventListener ( 'DOMContentLoaded' , ( event ) => {
151136 const colorStr = UI . pad . lightColorHash ( new UI . rdf . NamedNode ( 'https://sharonstrats.inrupt.net/profile/card#me' ) )
@@ -160,43 +145,6 @@ <h2>
160145 < div id ="div-lightColorHash "> </ div >
161146 </ article >
162147
163-
164- < article id ='manageParticipation '>
165- < h2 >
166- < a href ='#manageParticipation '>
167- < code > manageParticipation</ code > : Creates the table to display the participants
168- </ a >
169- </ h2 >
170- < p > ManageParticpation manages the pad document editors. </ p >
171- < p > The example below shows how to use this function. </ p >
172- < ul >
173- < li > Provide the HTMLTableElement or HTMLDivElement on which to render the participants.</ li >
174- < li > Provide the full path to the pad document.</ li >
175- < li > Provide the full path to the subject, which is the pad document + '#this'.</ li >
176- < li > Optional: There are three properties that can be set on the options object.</ li >
177- < ul >
178- < li > statusArea - a place to show error messages from pad.</ li >
179- < li > draggable - set this to true in order to make the participant draggable.</ li >
180- < li > deleteFunction - provide a delete function to enable the delete functionality.</ li >
181- < li > link - this should create a link to the WebID.</ li >
182- </ ul >
183- </ ul >
184- < script id ='script-manageParticipation '>
185- window . addEventListener ( 'DOMContentLoaded' , ( event ) => {
186- const me = new UI . rdf . NamedNode ( 'https://example-user.inrupt.net/profile/card#me' )
187- const structure = document . createElement ( 'div' )
188- const padMessages = document . createElement ( 'div' )
189- const subject = UI . store . sym ( 'https://example-user.inrupt.net/public/example-notepad/index.ttl#this' )
190- const pad = UI . rdf . namedNode ( 'https://example-user.inrupt.net/public/example-notepad/index.ttl' )
191- options = { statusArea : padMessages }
192- // const result = UI.pad.manageParticipation(document, structure, pad.doc(), subject, me, options)
193- // document.querySelector('#div-manageParticipation').appendChild(result)
194- } )
195- </ script >
196- < pre id ='viewSource-manageParticipation '> </ pre >
197- < div id ='div-manageParticipation '> </ div >
198- </ article >
199-
200148 < article id ="renderPartipants ">
201149 < h2 >
202150 < a href ="#renderPartipants ">
@@ -205,32 +153,19 @@ <h2>
205153 </ a >
206154 </ h2 >
207155 < p > Creates the table with the list of participants that have contributed to
208- the given pad. This is used by manageParticipation, but can be used on it's own as well. </ p >
209-
210- < p > The example below shows how to use this function, however the function call
211- is commented out because it will add a triple each time this page is rendered just as the renderParticpants
212- function below. </ p >
213- < ul >
214- < li > Use the fetcher to load the pad document.</ li >
215- < li > Provide the HTMLTableElement on which to render the participants.</ li >
216- < li > Provide the full path to the pad document.</ li >
217- < li > Provide the full path to the subject, which is the pad document + '#this'.</ li >
218- < li > Optional: There are three properties that can be set on the options object.</ li >
219- < ul >
220- < li > draggable - set this to true in order to make the participant draggable.</ li >
221- < li > deleteFunction - provide a delete function to enable the delete functionality.</ li >
222- < li > link - this should create a link to the WebID.</ li >
223- </ ul >
224- </ ul >
156+ the given pad that is passed in. This gets called from manageParticipation,
157+ but can be used on it's own as well. </ p >
225158 < script id ="script-renderPartipants ">
226159 window . addEventListener ( 'DOMContentLoaded' , async ( event ) => {
160+ const table = document . createElement ( 'table' ) ;
227161 const kb = UI . store
228162 const fetcher = UI . rdf . fetcher ( kb )
229- const table = document . createElement ( 'table' ) ;
230- const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1585026584938/index.ttl' )
231- const subject = kb . sym ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1585026584938/index.ttl#this' )
232- const options = { draggable : true , link : true , deleteFunction : ( ) => alert ( "deleted" ) }
163+ const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1584238219755/index.ttl#this' )
233164 await fetcher . load ( pad . doc ( ) )
165+ // subject = new NamedNode('test') // this i think the page where a list.. ns.ws('participants') are stored
166+ subject = kb . sym ( 'https://test.test#' )
167+ options = { } // what to put in options
168+ //options are used in the button personTR there are the following properties can be defined deleteFunction, link, draggable
234169 const tableOfParticipants = UI . pad . renderPartipants ( document , table , pad , subject , new UI . rdf . NamedNode ( 'https://sharonstrats.inrupt.net/profile/card#me' ) , options )
235170 document . querySelector ( '#div-renderPartipants' ) . appendChild ( tableOfParticipants )
236171 } )
@@ -241,20 +176,20 @@ <h2>
241176
242177 < article id ="participationObject ">
243178 < h2 > < a href ="#participationObject ">
244- < code > participationObject</ code > : Contains the subject, pad and WebID for the participants
179+ < code > participationObject</ code > : Contains the subject, pad and URI for the participants
245180 </ a >
246181 </ h2 >
247182 < p > </ p >
248183 < script id ='script-participationObject '>
249184 window . addEventListener ( 'DOMContentLoaded' , async ( event ) => {
250185 const kb = UI . store
251- const subject = kb . sym ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1584238219755/index.ttl#this ' ) ;
186+ const subject = kb . sym ( 'https://test.test# ' ) ;
252187 const fetcher = UI . rdf . fetcher ( kb )
253- const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1584238219755/index.ttl' )
188+ const pad = UI . rdf . namedNode ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1584238219755/index.ttl#this ' )
254189
255190 await fetcher . load ( pad . doc ( ) )
256191 const me = new UI . rdf . NamedNode ( 'https://sharonstrats.inrupt.net/profile/card#me' )
257- const htmlStr = await UI . pad . participationObject ( subject , pad , me ) ;
192+ const htmlStr = UI . pad . participationObject ( subject , pad , me ) ;
258193 document . querySelector ( '#div-participationObject' ) . appendChild ( document . createTextNode ( htmlStr ) )
259194 } )
260195 </ script >
@@ -264,18 +199,17 @@ <h2> <a href="#participationObject">
264199
265200 < article id ="recordParticipation ">
266201 < h2 > < a href ="#recordParticipation ">
267- < code > recordParticipation</ code > : Adds the WebID of the user to the participant store
202+ < code > recordParticipation</ code > : Adds the URI of the user to the participant store
268203 </ a > </ h2 >
269- < p > Records the participants in the store for the given document and returns the participation object.
270- This is also used in manageParticipation, but could also be used on it's own to create a particpation triple. </ p >
271- < p > The code below provides an example of the code you need to write to use this function, however the function call
272- is commented out because it will add a triple each time this page is rendered. </ p >
204+ < p > Records the participants in the store for the given document and
205+ returns the participation object. This is also used in manageParticipation,
206+ but could also be used on it's own.</ p >
273207 < script id ="script-recordParticipation ">
274208 window . addEventListener ( 'DOMContentLoaded' , async ( event ) => {
275209 const kb = UI . store
276- const subject = kb . sym ( 'https://sharonstrats.inrupt.net/public/edu.mit.solid.pane.pad/id1585026584938/index.ttl#this ' ) ;
210+ const subject = kb . sym ( 'https://test.test# ' ) ;
277211 const fetcher = UI . rdf . fetcher ( kb )
278- const pad = UI . rdf . namedNode ( 'https://sharonstrats .inrupt.net/public/example-notepad/index.ttl#this' )
212+ const pad = UI . rdf . namedNode ( 'https://example-user .inrupt.net/public/example-notepad/index.ttl#this' )
279213 await fetcher . load ( pad . doc ( ) )
280214 // const htmlStr = UI.pad.recordParticipation(subject, pad, false);
281215 } )
0 commit comments