Wiki source code of IRC Archive for channel #xwiki

Last modified by Vincent Massol on 2012/10/18 18:38

Show last authors
1 npm left at 01:31 ("Leaving."
2 CalebJamesDeLisl joined #xwiki at 03:19
3 SvenDowideit left at 03:50 (Read error: 60 (Operation timed out)
4 sunny_slls joined #xwiki at 04:36
5 CalebJamesDeLisl - (04:57): Hi sunny_slls, sorry I wasn't available earlier, had to catch some sleep.
6 sunny_slls - (05:08): hi CalebJamesDeLisl
7 sunny_slls - (05:08): CalebJamesDeLisl, sorry for responding late
8 CalebJamesDeLisl - (05:08): How is the scripting going?
9 sunny_slls - (05:08): CalebJamesDeLisl, come on don't embarrass me ..don't say sorry
10 sunny_slls - (05:08): CalebJamesDeLisl, working on it
11 sunny_slls - (05:09): i am on the verge of finishing it
12 CalebJamesDeLisl - (05:09): "don't embarrass me" haha, I was in bed until about 1/2 hour ago.
13 sunny_slls - (05:09): CalebJamesDeLisl, what time is it now there?
14 CalebJamesDeLisl - (05:10): 11PM, I have a weird sleep schedule.
15 sunny_slls - (05:10): CalebJamesDeLisl, so soon you must be going to sleep soon
16 CalebJamesDeLisl - (05:11): Not until tomorrow some time.
17 sunny_slls - (05:11): haha
18 sunny_slls - (05:11): CalebJamesDeLisl, ok give me sometime so that i finish the script
19 sunny_slls - (05:11): its very bad to extend it
20 CalebJamesDeLisl - (05:12): Have you done much with querying the database? $xwiki.searchDocuments( ?
21 sunny_slls - (05:12): nope
22 CalebJamesDeLisl - (05:12): Once you get the hang of velocity itself, you can have a lot of fun running searches and creating output.
23 sunny_slls - (05:13): ok
24 sunny_slls - (05:13): so hang on for half an hour till i finish it
25 CalebJamesDeLisl - (05:13): If you need any help, you can post your script on pastebin and I can look at it.
26 sunny_slls - (05:13): and then we will have scripting fun together
27 sunny_slls - (05:13): :)
28 sunny_slls - (05:13): thanks
29 sunny_slls - (05:14): CalebJamesDeLisl, that was very kind and supporting of you
30 sunny_slls - (05:14): :)
31 sunny_slls - (05:14): CalebJamesDeLisl, by the way you are studying in which semester?
32 CalebJamesDeLisl - (05:14): No problem.
33 CalebJamesDeLisl - (05:15): No college for me, I'm studying the XWiki core.
34 sunny_slls - (05:15): ok, so seaching for job which all people do after completing college stuffs?
35 CalebJamesDeLisl - (05:16): Something like that.
36 sunny_slls - (05:16): so do you get paid for working for xwiki core
37 sunny_slls - (05:16): ?
38 CalebJamesDeLisl - (05:17): There has been some talk about it, we will see.
39 sunny_slls - (05:17): ok
40 sunny_slls - (05:17): CalebJamesDeLisl, i too like to work with corejava :)
41 sunny_slls - (05:18): CalebJamesDeLisl, ok i will catch you later ..lets get back to velocity stuff
42 CalebJamesDeLisl - (05:18): Enjoy.
43 sunny_slls - (05:36): CalebJamesDeLisl, http://pastebin.com/m6cb9a89b
44 sunny_slls - (05:37): Key: $key -> Value: $allProducts.get($key) please explain this statement
45 sunny_slls - (05:38): ?
46 CalebJamesDeLisl - (05:39): Should I give you the equivalent java code?
47 CalebJamesDeLisl - (05:40): if $allProducts is a Map and $key is a key in that map, then it will output "Key: (the key) -> Value: (the corresponding value)
48 CalebJamesDeLisl - (05:40): "
49 CalebJamesDeLisl - (05:42): You understand that "#foreach( $key in $allProducts.keySet() )" will give you a loop and set $key to each key in the Map $allProducts right?
50 sunny_slls - (05:43): if i say that allproducts.get($key) method retrieves the key to all the products and the value is stored in the "Value" and $key points out to the value in "Value"
51 sunny_slls - (05:43): is that right ?
52 CalebJamesDeLisl - (05:43): Yes.
53 sunny_slls - (05:43): ok
54 CalebJamesDeLisl - (05:43): Are you familiar with the Map interface?
55 sunny_slls - (05:44): in java right?
56 CalebJamesDeLisl - (05:44): Yes.
57 sunny_slls - (05:45): yes i am familiar with it but never used it
58 sunny_slls - (05:45): little familiar with hashMap
59 CalebJamesDeLisl - (05:45): It will help to understand that all Velocity code is compiled into Java code. You are programming Java with different commands.
60 sunny_slls - (05:46): ok
61 CalebJamesDeLisl - (05:46): Yes, HashMap is a type of Map.
62 sunny_slls - (05:47): there are packages in java which contains these in-build methods, does velocity also have such kind of packages which are imported?
63 CalebJamesDeLisl - (05:48): In velocity you can't call "import java.lang.SomePackage" and that makes it more secure.
64 sunny_slls - (05:48): ok i will come on this later
65 CalebJamesDeLisl - (05:49): Have you tried running the code you showed me?
66 sunny_slls - (05:50): nope
67 sunny_slls - (05:50): wait
68 SvenDowideit joined #xwiki at 05:53
69 sunny_slls - (07:05): CalebJamesDeLisl, http://pastebin.com/m7fb68dab
70 sunny_slls - (07:05): #set($dynamicsource = "$source$select")
71 CalebJamesDeLisl - (07:06): In java that would be String dynamicsource = source + select;
72 sunny_slls - (07:07): but the variable which contains the value is $source1 not $source
73 sunny_slls - (07:07): and why the value on is not showing since it should be concatenated with "abc"
74 sunny_slls - (07:08): i mean value of the $select which is 1 here
75 CalebJamesDeLisl - (07:08): Looks like you found a mistake in the Velocity documentation :)
76 sunny_slls - (07:08): no its not a mistake
77 sunny_slls - (07:09): when i run the code it is running correctly withour any error or exception
78 sunny_slls - (07:09): *without
79 CalebJamesDeLisl - (07:09): if $source is not defined (and it isn't in the example) Velocity defaults to: "String dynamicsource = "$source" + select;
80 CalebJamesDeLisl - (07:09): "
81 sunny_slls - (07:10): source is defined
82 CalebJamesDeLisl - (07:10): Oh I though only $source1 was defined.
83 sunny_slls - (07:10): oh sorry
84 sunny_slls - (07:10): my mistake
85 sunny_slls - (07:11): but then how come its taking the value of $source1 in $source?
86 CalebJamesDeLisl - (07:11): It shouldn't be.
87 sunny_slls - (07:12): err
88 CalebJamesDeLisl - (07:12): or.
89 sunny_slls - (07:13): according to my logic the value of the $source1= "abc" and $select = 1 , so the output of the concatenated value should be $source$select = abc1
90 sunny_slls - (07:13): but its not coming like that
91 CalebJamesDeLisl - (07:14): Let me guess, it comes out to "abc"
92 sunny_slls - (07:15): yes
93 CalebJamesDeLisl - (07:16): Welcome to the land of metaprogramming :)
94 sunny_slls - (07:16): without quotes
95 sunny_slls - (07:16): gosh~!
96 CalebJamesDeLisl - (07:16): Here's what happens
97 sunny_slls - (07:16): haha
98 CalebJamesDeLisl - (07:17): $source$select converts to java: String sourceselect = "$source" + select;
99 sunny_slls - (07:18): ok
100 CalebJamesDeLisl - (07:18): that means that sourceselect = "$source1"
101 CalebJamesDeLisl - (07:18): then it parses it again and says Ah hah: $sourceselect = $source1
102 CalebJamesDeLisl - (07:18): thus $sourceselect = abc
103 CalebJamesDeLisl - (07:19): which is the value of $source1
104 CalebJamesDeLisl - (07:19): You have written a program which writes a program, congratulations.
105 sunny_slls - (07:22): well its not so clear to me
106 CalebJamesDeLisl - (07:22): $source$select converts to java: String sourceselect = "$source" + select;
107 sunny_slls - (07:22): ok
108 sunny_slls - (07:23): but how sourceselect = "$source1" ?
109 CalebJamesDeLisl - (07:23): which is interpreted as: String sourceselect = "$source" + "1";
110 CalebJamesDeLisl - (07:23): because $select = 1
111 CalebJamesDeLisl - (07:24): when java executes that line, it becomes: String sourceselect = "$source1";
112 sunny_slls - (07:24): got it
113 sunny_slls - (07:25): ya now its clear
114 sunny_slls - (07:25): thanks
115 CalebJamesDeLisl - (07:25): Funny when you actually see what's happening isn't it?
116 sunny_slls - (07:25): ya its a bit weird
117 CalebJamesDeLisl - (07:25): Now lets see if we can overflow the stack :)
118 sunny_slls - (07:26): ok
119 CalebJamesDeLisl - (07:26): With a recursive call which never solves.
120 CalebJamesDeLisl - (07:26): Not a security issue but it's fun.
121 sunny_slls - (07:27): ok
122 sunny_slls - (07:39): when i am declaring a macro then it is giving an error
123 sunny_slls - (07:39): #macro( d )
124 sunny_slls - (07:41): CalebJamesDeLisl, ?
125 CalebJamesDeLisl - (07:42): What kind of error is it?
126 sunny_slls - (07:42): http://pastebin.com/m4830d201
127 CalebJamesDeLisl - (07:43): Macros have to end with #end
128 CalebJamesDeLisl - (07:43): here are some examples of macros
129 CalebJamesDeLisl - (07:44): http://svn.xwiki.org/svnroot/xwiki/platform/web/trunk/standard/src/main/webapp/templates/macros.vm
130 CalebJamesDeLisl - (07:44): BTW: These macros are all available for you to use while coding.
131 sunny_slls - (07:44): ya
132 sunny_slls - (07:44): got it
133 CalebJamesDeLisl - (08:03): Hey sunny...
134 sunny_slls is now known as sunny_slls|away ([email protected]
135 sunny_slls|away is now known as sunny_slls ([email protected]
136 sunny_slls left at 09:34 ("Leaving"
137 A-Kaser joined #xwiki at 11:33
138 bougie joined #xwiki at 13:58
139 bougie left #xwiki at 13:58
140 sunny_slls joined #xwiki at 14:46
141 sunny_slls - (14:47): hello everybody
142 CalebJamesDeLisl - (14:57): Hi sunny
143 sunny_slls - (15:26): CalebJamesDeLisl, http://pastebin.com/mc74c2a0
144 sunny_slls - (15:26): please explain me this
145 CalebJamesDeLisl - (15:26): ?
146 sunny_slls - (15:27): CalebJamesDeLisl, http://pastebin.com/mc74c2a0
147 CalebJamesDeLisl - (15:27): It should output ${my:invalid:non:reference} I think
148 sunny_slls - (15:27): its giving an error
149 sunny_slls - (15:28): http://pastebin.com/m44263ddd
150 sunny_slls - (15:28): here is the error
151 CalebJamesDeLisl - (15:30): You could try #set($d = '${') then you would be able to say ${d}my:invalid...
152 sunny_slls - (15:31): i can't get the concept of what is it trying to do
153 sunny_slls - (15:31): please explain
154 CalebJamesDeLisl - (15:31): What they are teaching is how to say things on your web page which Velocity wants to parse as syntax.
155 sunny_slls - (15:31): ok
156 sunny_slls - (15:32): one question
157 sunny_slls - (15:32): $s = ${s} is the same thing?
158 CalebJamesDeLisl - (15:32): yes $s is the same as ${s}
159 CalebJamesDeLisl - (15:33): but $sammy is not the same as ${s}ammy
160 sunny_slls - (15:33): yes
161 CalebJamesDeLisl - (15:33): You use the {} to stop it from trying interpret a bigger block of text as a variable
162 sunny_slls - (15:34): so here when it is writing ${D}{my:invalid:non:reference} it should give {my:invalid:non:reference}{my:invalid:non:reference}
163 sunny_slls - (15:35): since $D = "$"
164 CalebJamesDeLisl - (15:37): No ${D} resolves to '$' so you get ${my:invalid:non:ref}
165 sunny_slls - (15:38): oh its in single quotes
166 sunny_slls - (15:38): for double quotes my answer is right
167 CalebJamesDeLisl - (15:39): I don't see how ${D} ever resolves to {my:invalid:non:reference}
168 CalebJamesDeLisl - (15:40): The main difference between ' and " is that things inside of ' are not allowed to be parsed.
169 sunny_slls - (15:40): yes
170 sunny_slls - (15:40): that is what i am saying
171 sunny_slls - (15:41): for "" the $D get parsed to {my:invalid:non:reference}
172 sunny_slls - (15:41): but for ' it is not parsed and gives $
173 sunny_slls - (15:41): thanks
174 sunny_slls - (15:42): can you give me some link of website that are made from velocity?
175 CalebJamesDeLisl - (15:43): I don't know, you'd have to for references on the Velocity website.
176 CalebJamesDeLisl - (15:43): BTW: I found the problem with your code.
177 CalebJamesDeLisl - (15:43): First line is an example.
178 CalebJamesDeLisl - (15:44): Remove it and it works fine :)
179 sunny_slls - (15:44): ok
180 sunny_slls - (15:45): yes it worls
181 sunny_slls - (15:45): *works
182 sunny_slls - (16:01): CalebJamesDeLisl, please tell me about the \\ character
183 sunny_slls - (16:02): getting little confused
184 CalebJamesDeLisl - (16:02): Where are you using it?
185 sunny_slls - (16:03): #set( $foo = "bar" )
186 sunny_slls - (16:03): $\!foo
187 sunny_slls - (16:03): $\!{foo}
188 sunny_slls - (16:03): $\\!foo
189 sunny_slls - (16:03): $\\\!foo
190 CalebJamesDeLisl - (16:04): if you say $x and $x = 'blah' then you will output 'blah'
191 CalebJamesDeLisl - (16:04): so you can say \$x and the output will be '$x'
192 sunny_slls - (16:04): ok
193 sunny_slls - (16:05): \\$!foo will be ?
194 CalebJamesDeLisl - (16:05): one backslash "escapes" the character in front of it making it not parsed.
195 sunny_slls - (16:05): ok
196 CalebJamesDeLisl - (16:06): But backslashes can also escape themselves so \\ will output '\'
197 sunny_slls - (16:06): ok
198 sunny_slls - (16:06): got it
199 CalebJamesDeLisl - (16:07): so if $x = 'blah' then \$x will output '$x' but \\$x will output '\blah'
200 sunny_slls - (16:07): what is the difference in between $\\x and \\$x
201 sunny_slls - (16:07): means $//x means?
202 CalebJamesDeLisl - (16:08): I think $\\x will output '$\x' because \ can't be used in a variable name so it assumes you literally mean to put the $ there.
203 sunny_slls - (16:09): got it
204 sunny_slls - (16:11): CalebJamesDeLisl, well now i am done with velocity ...
205 CalebJamesDeLisl - (16:11): Well now you get to use velocity to call functions in the core.
206 sunny_slls - (16:12): ok
207 sunny_slls - (16:12): so what i should do now?
208 CalebJamesDeLisl - (16:13): This page is a good read: http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting
209 CalebJamesDeLisl - (16:13): You have a lot of things available to you such as the core XWiki object which is bound to the variable $xwiki
210 CalebJamesDeLisl - (16:14): The current document is $doc
211 CalebJamesDeLisl - (16:14): you can get the name of the current document with $doc.getName()
212 sunny_slls - (16:14): ok
213 CalebJamesDeLisl - (16:15): If you are used to Java then the hard part is over, the rest is all calling Java methods.
214 sunny_slls - (16:15): yes i am used to java
215 sunny_slls - (16:16): except the collection framework part is incomplete
216 sunny_slls - (16:18): there are specifications for each language . do i have to know them all
217 CalebJamesDeLisl - (16:18): You follow tutorials very carefully.
218 sunny_slls - (16:18): since i don't have any idea about groovy
219 CalebJamesDeLisl - (16:18): I usually just scan over the headlines and then come back later if I have a problem.
220 sunny_slls - (16:18): ok
221 CalebJamesDeLisl - (16:19): Javadoc is very cool for looking stuff up.
222 sunny_slls - (16:19): well but i can see a lot of use of groovy
223 CalebJamesDeLisl - (16:19): Groovy is easy, it's just java but you don't need to define a class or main method, it runs like a script.
224 sunny_slls - (16:19): ok
225 CalebJamesDeLisl - (16:20): Groovy also has some serious security problems.
226 sunny_slls - (16:20): ok
227 CalebJamesDeLisl - (16:20): XWiki only allows groovy to be written by users who have programming rights.
228 sunny_slls - (16:21): ok
229 sunny_slls - (16:21): CalebJamesDeLisl, let me read this doc...then i would come to you later
230 CalebJamesDeLisl - (16:21): ok.
231 sunny_slls - (16:22): btw i have to go for dinner
232 sunny_slls - (16:22): its already 9:00pm
233 sunny_slls - (16:22): see ya later
234 sunny_slls is now known as sunny_slls|away ([email protected]
235 sunny_slls|away is now known as sunny_slls ([email protected]
236 sunny_slls left at 19:24 ("Leaving"
237 A-Kaser left at 19:25 (""Soyons réalistes, exigeons l'impossible." Ché Guevara"
238 CalebJamesDeLisl left at 19:32 ("Off to bed."
239 lucaa joined #xwiki at 22:02
240 SvenDowiu joined #xwiki at 22:36
241 SvenDowideit left at 22:50 (Read error: 110 (Connection timed out)
242 SvenDowiu is now known as SvenDowideit ([email protected]
243 lucaa left #xwiki at 23:08

Get Connected