Re: [xwiki-users] How to programmatically create pages from html files?

2016-05-17 Thread Paul Libbrecht


Sebastian Schafer wrote:
> I think right now I'm mostly battling the linked images in the original html 
> files. Xwiki uses relative paths and those are not valid anymore after 
> converting to a wiki page. I think I need to handle this when I create the 
> html files and embed the images as text - ugly but the only option I see 
> right now.
Here would be a continuation, before the document.save of course.
The imports should be put first.

paul

import java.util.regexp.*;
import org.apache.commons.io.FileUtils;
import java.io.File;
import com.xpn.xwiki.api.*;

java.util.regexp.Pattern pattern = Pattern.compile("")
while(m.find()) {
URL u = new URL(pageURL, m.group(1));
String imageName = u.getPath().replaceAll(".*/","");
println("${imageName }");
File tmp = new File("/tmp/xxx.png");
FileUtils.copyURLToFile(u, tmp);

// now fetch and store
byte[] content = FileUtils.readFileToByteArray(tmp);
//println("Attachment is of size ${content.length} and is named
${name}");
Attachment attachment = doc.addAttachment(imageName , content);
println(" has become ${imageName } (rev ${attachment.getVersion()}).");
}
println("");

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Users disappearing on mywiki?

2016-05-17 Thread Regan Gill
Did any one else have users disappear on their wiki on mywiki.org?A number of 
ours no longer exist. I just discovered this today on scservicesub.mywiki.org. 
The User Directory is not working either.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] How to programmatically create pages from html files?

2016-05-17 Thread Sebastian Schafer
Thank you both, this helped me a lot.
I think right now I'm mostly battling the linked images in the original html 
files. Xwiki uses relative paths and those are not valid anymore after 
converting to a wiki page. I think I need to handle this when I create the html 
files and embed the images as text - ugly but the only option I see right now.

Cheers

  Sebastian

-Original Message-
From: users [mailto:users-boun...@xwiki.org] On Behalf Of Eduard Moraru
Sent: Tuesday, May 17, 2016 3:54 PM
To: XWiki Users
Subject: Re: [xwiki-users] How to programmatically create pages from html files?

I`m not much of a Python fan, but if you say you`re into it, you could always 
try the http://extensions.xwiki.org/xwiki/bin/view/Extension/Python+Macro and 
script your way using your favorite language :)

If you try it, let me know how it went ;)

For scripting API see http://platform.xwiki.org/xwiki/bin/view/DevGuide/API
and the available bindings at
http://extensions.xwiki.org/xwiki/bin/view/Extension/Script+Macro

Now, for your particular use case, you could either create a new wiki page
and:
1) use the HTML syntax directly for that wiki page and just dump your HTML 
content in it or
2) use the rendering script service ($services.rendering, i.e.
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/script/RenderingScriptService.java)
to parse the HTML content into XDOM and then render it to xwiki/2.1 syntax that 
you can then save inside the newly created page

Depends where you want to go with it.

Hope this helps,
Eduard

On Tue, May 17, 2016 at 10:52 PM, Paul Libbrecht  wrote:

>
>
> s.schafer wrote:
> > Does that mean I create a ‘control’ page with a script that’ll grab 
> > data
> and
> > creates new pages?
> Correct. And you can invoke that from a command-line or cron world if 
> you want with a curl (and some hard-coded passwords).
> > I f so, it would be great if someone can point me to an example.
> Using groovy is a good idea. It's a tick less limited than using Velocity.
>
> file = new java.io.File("filename.txt");
> name = "Space." + file.getName();
> doc = xwiki.getDocument(name);
> println("Saving to document [[${doc}]].")
>
> doc.setContent(org.apache.commons.io.FileUtils.readFileToString(file,
> "utf-8"));
>
> doc.setTitle("My beautiful page");
> doc.setSyntaxId("xhtml/1.0");
> doc.save("Fetching from ${file.getPath()}.");
>
> Hope it helps.
>
> Paul
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Immediate Child Document Query

2016-05-17 Thread Eduard Moraru
Hi,

Note that doc.parent is deprecated and could be removed at some point in
the future.

Your query should be the translation of "Get all the documents inside a
space which has a parent space with the given reference ", i.e. "select
doc.fullName from XWikiDocument doc, XWikiSpace space where
doc.space=space.reference and space.parent='Some.Space.Reference'". This
will give you all the documents inside the immediate child spaces of a
given space.

Hope this helps (even if it`s a late reply),
Eduard

On Mon, Apr 11, 2016 at 5:36 PM, Personal  wrote:

> Figured it out over the weekend:
>
> where doc.parent = ‘Parent Full Name’
>
> Guess I was trying to make it more complicated than it actually was.
>
> Regards,
>
> Jesse
>
>
> > On Apr 8, 2016, at 7:51 AM, Personal  wrote:
> >
> > Per the Query Module documentation:
> >
> > List of child spaces: select
> space.name from XWikiSpace as space where space.parent = 'Parent Space’
> > List of all nested documents in a space:  where doc.space like
> 'Space' or doc.space like 'Space.%’
> >
> > The first gives me the correct spaces but I want the documents (WebHome)
> and the second gives me every single document in every space below ‘Space’.
> How do you query for just the documents in the immediate child spaces?
> Anything I do to narrow the results seems to give me no results and no
> error. Thanks for any help.
> >
> > Regards,
> >
> > Jesse
> > ___
> > users mailing list
> > users@xwiki.org
> > http://lists.xwiki.org/mailman/listinfo/users
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Compare Strings

2016-05-17 Thread Eduard Moraru
On Fri, Apr 29, 2016 at 10:50 AM, Vincent Massol  wrote:

> Hi,
>
> > On 29 Apr 2016, at 09:48, Rochlin Oleg 
> wrote:
> >
> > I am currently trying to Filter my userlist
> >
> > #set($users = $xwiki.rightsmanager.usersApi.allUsers)
> >
> > #foreach($user in $users)
>
> This is not going to be performant. You should instead use:
>
> http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/ReleaseNotesXWiki70M2#HGroupMemberIterator


We need a solution for this in Velocity as well.

Thanks,
Eduard

>
>
> Thanks
> -Vincent
>
> >  #if(($xwiki.getUser($user).isUserInGroup("XWiki.GroupName"))&&
> $xwiki.getUser($user).position !="StringExample")
> >
> >  {{section justify="true"}}
> >
> > It should show me all users except of those with String I defined in if
> within position section.
> > sadly the second part of IF is being ignored. Users with String are
> still shown.
> >
> >
> > Thanks  =)
> >
> > Oli
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] How to programmatically create pages from html files?

2016-05-17 Thread Eduard Moraru
I`m not much of a Python fan, but if you say you`re into it, you could
always try the
http://extensions.xwiki.org/xwiki/bin/view/Extension/Python+Macro and
script your way using your favorite language :)

If you try it, let me know how it went ;)

For scripting API see http://platform.xwiki.org/xwiki/bin/view/DevGuide/API
and the available bindings at
http://extensions.xwiki.org/xwiki/bin/view/Extension/Script+Macro

Now, for your particular use case, you could either create a new wiki page
and:
1) use the HTML syntax directly for that wiki page and just dump your HTML
content in it or
2) use the rendering script service ($services.rendering, i.e.
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/script/RenderingScriptService.java)
to parse the HTML content into XDOM and then render it to xwiki/2.1 syntax
that you can then save inside the newly created page

Depends where you want to go with it.

Hope this helps,
Eduard

On Tue, May 17, 2016 at 10:52 PM, Paul Libbrecht  wrote:

>
>
> s.schafer wrote:
> > Does that mean I create a ‘control’ page with a script that’ll grab data
> and
> > creates new pages?
> Correct. And you can invoke that from a command-line or cron world if
> you want with a curl (and some hard-coded passwords).
> > I f so, it would be great if someone can point me to an example.
> Using groovy is a good idea. It's a tick less limited than using Velocity.
>
> file = new java.io.File("filename.txt");
> name = "Space." + file.getName();
> doc = xwiki.getDocument(name);
> println("Saving to document [[${doc}]].")
>
> doc.setContent(org.apache.commons.io.FileUtils.readFileToString(file,
> "utf-8"));
>
> doc.setTitle("My beautiful page");
> doc.setSyntaxId("xhtml/1.0");
> doc.save("Fetching from ${file.getPath()}.");
>
> Hope it helps.
>
> Paul
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] [Proposal] Comparing XWiki to MediaWiki and Confluence on xwiki.org

2016-05-17 Thread Bryn Jeffries
Denis Gervalle said:
> > Yes, we only maintain documentation for the latest version of XWiki on
> > xwiki.org (not enough manpower to have decent doc for several versions
> > ATM).
> >
> 
> However, for version 6.2.5 and later, you have a way to mitigate this
> limitation. You can install the Scripting Documentation Application on your
> own wiki (see
> http://extensions.xwiki.org/xwiki/bin/view/Extension/Scripting+Documenta
> tion+Application).

Thanks, I did not know about this tool, which sounds excellent.

> Unless you are using XWiki prior to 4.2 , using Wiki Component is definitely
> the recommended way to writes Groovy components. Registering
> components "by hand" from a groovy script has many drawbacks not only
> the restart one, and you should avoid doing that. The best is of course to
> write the components in Java, and install them as an extension.

I've found the ability to write small Groovy scripts as components has been 
very handy and simpler than writing full extensions in Java. For utilities that 
I don't wish to make into public extensions the burden of a small Groovy script 
into a proper extension seems prohibitive (although that may just be that I 
haven't written one yet, and I'm just a walker at the bottom of a hill 
complaining about how high it looks...). Last time I asked there is was no 
simple way to install private extensions. Also, I didn't have much luck writing 
a proper component in Groovy, which I sometimes prefer to Java.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] How to programmatically create pages from html files?

2016-05-17 Thread Paul Libbrecht


s.schafer wrote:
> Does that mean I create a ‘control’ page with a script that’ll grab data and
> creates new pages? 
Correct. And you can invoke that from a command-line or cron world if
you want with a curl (and some hard-coded passwords).
> I f so, it would be great if someone can point me to an example.
Using groovy is a good idea. It's a tick less limited than using Velocity.

file = new java.io.File("filename.txt");
name = "Space." + file.getName();
doc = xwiki.getDocument(name);
println("Saving to document [[${doc}]].")
   
doc.setContent(org.apache.commons.io.FileUtils.readFileToString(file,
"utf-8"));

doc.setTitle("My beautiful page");
doc.setSyntaxId("xhtml/1.0");
doc.save("Fetching from ${file.getPath()}.");

Hope it helps.

Paul
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] How to programmatically create pages from html files?

2016-05-17 Thread s.schafer
Hi all,
could someone please help me to find a way to script the creation of new
wiki pages from data/text saved in html files?
I’m trying to (semi)automatically organize and upload data to new wiki
pages, i.e. analyze and plot data with an external program, sve the
information (including page name, etc.) in a html file, and then have some
sort of script take the html file – or objects from it – and create a wiki
page. It doesn’t have to be fully automatic and include a scheduled service
or similar, a script  that I can run every day would be fine.
I did look for hints but I guess I’m too much of a beginner to piece
everything together. I found
http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+Page+With+Object
which tells me that I can script a page creation.
Now my naïve question is: Where do I script this? I am not familiar with
Velocity (Python is my only scripting language), but willing to learn. From
what I could see in tutorials like
http://platform.xwiki.org/xwiki/bin/view/DevGuide/XWikiVelocityTraining I
put the velocity text in a wiki page (as opposed to run it in a terminal or
via some application outside of the wiki pages?
Does that mean I create a ‘control’ page with a script that’ll grab data and
creates new pages? I f so, it would be great if someone can point me to an
example.

Thank you

  Sebastian 




--
View this message in context: 
http://xwiki.475771.n2.nabble.com/How-to-programmatically-create-pages-from-html-files-tp7599476.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Send Page via Outlook

2016-05-17 Thread Vincent Massol
Hi Joshua,

> On 17 May 2016, at 19:27, Joshua Spiva  wrote:
> 
> I have been looking everywhere for an article or an addon for this function. 
> Has anyone managed to find a way to add a simple button or menu options to 
> email the page via Outlook? My users really want to have the articles they 
> are sending out in their own mailboxes as a sent item.

This feature is built in:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Send+Page+By+Email+Application

Thanks
-Vincent

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Send Page via Outlook

2016-05-17 Thread Joshua Spiva
I have been looking everywhere for an article or an addon for this function. 
Has anyone managed to find a way to add a simple button or menu options to 
email the page via Outlook? My users really want to have the articles they are 
sending out in their own mailboxes as a sent item.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Getting the translated country name

2016-05-17 Thread Thomas Mortagne
The API you are actually manipulating when you do this is
https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html which
is about languages and language variants.

getDisplayName return the display name for the whole Locale but you
can get the language pretty name using getDisplayLanguage and the
country pretty name with getDisplayCountry. So the trick would be to
create a Locale with the country part in it and then call
getDisplayCountry.

Here is a few experiments for you:

$services.localization.toLocale('it').getDisplayName('fr')
$services.localization.toLocale('it_IT').getDisplayName('fr')
$services.localization.toLocale('it_IT').getDisplayLanguage('fr')
$services.localization.toLocale('it_IT').getDisplayCountry('fr')

On Tue, May 17, 2016 at 5:10 PM, Gerritjan Koekkoek
 wrote:
> I found a nice way to translate $language into pretty language name in the 
> translation desired.
>
>
> {{velocity}}
>
> #displayLanguagePrettyName("it")
>
> #macro(displayLanguagePrettyName $language)#set($languageLocale = 
> $services.localization.toLocale("it"))$stringtool.capitalize($languageLocale.getDisplayName("nl"))#end
>
> {{/velocity}}
>
>
> So changing the 'nl' to 'pt' (portugese) it will do
>
> Italiaans (dutch) -> Italiano (portugese)
>
>
> Ca the same be done for country?
>
> Italië (dutch) -> Itália (Portuguse)
>
>
>
>
> Gerritjan Koekkoek
> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
> Visit our website
> Facebook
> email
>
>
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Getting the translated country name

2016-05-17 Thread Gerritjan Koekkoek
I found a nice way to translate $language into pretty language name in the 
translation desired.


{{velocity}}

#displayLanguagePrettyName("it")

#macro(displayLanguagePrettyName $language)#set($languageLocale = 
$services.localization.toLocale("it"))$stringtool.capitalize($languageLocale.getDisplayName("nl"))#end

{{/velocity}}


So changing the 'nl' to 'pt' (portugese) it will do

Italiaans (dutch) -> Italiano (portugese)


Ca the same be done for country?

Italië (dutch) -> Itália (Portuguse)




Gerritjan Koekkoek
Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
Visit our website
Facebook
email



___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] [ANN] How to post articles on the xwiki.org Blog

2016-05-17 Thread Eduard Moraru
Hi,

Here are some of the latest blog posts in case you`ve missed them (latest
first):

* XWiki Big Data with Elastic Search (by Ludovic Dubost):
http://www.xwiki.org/xwiki/bin/view/Blog/XWiki+Big+Data+with+Elastic+Search
...or how the Active Installs feature works and how Elastic Search was
integrated in order to scale the incoming data.

* XWiki Development Practices seen by XWiki SAS (by Vincent Massol):
http://www.xwiki.org/xwiki/bin/view/Blog/DevPracticesByXWikiSAS
...with more details on the practices involved in developing the XWiki
project.

* XWiki at Open Source Camp Iasi 2016 (by Eduard Moraru):
http://www.xwiki.org/xwiki/bin/view/Blog/XWiki+at+Open+Source+Camp+Iasi+2016
...with impressions of the event, presented slides featuring a high-level
view over the XWiki project, its community and its development including,
of course, photos of the event :)

If you have any interesting experience related to XWiki, don`t hesitate to
share!

P.S.: Future posts will be announced on the lists through separate emails.

Thanks,
Eduard


On Wed, May 4, 2016 at 5:43 PM, Eduard Moraru  wrote:

> And we have our first blog post by Yann Flory who is talking about the
> XWebIDE extension which he has worked on:
> http://www.xwiki.org/xwiki/bin/view/Blog/Create+applications+with+XWebIDE
>
> Thanks for sharing, Yann!
>
> Hope to see many more to come!
>
> -Eduard
>
>
> On Tue, May 3, 2016 at 3:30 PM, Eduard Moraru 
> wrote:
>
>> Hello XWiki users and devs,
>>
>> The current xwiki.org blog [1] contains mostly release notes
>> announcements, Bug Fixing Days results and some occasional events that
>> XWiki has taken part of.
>>
>> We would like to pump some life into it by encouraging community members
>> to post articles and news related to the XWiki ecosystem so that everybody
>> can have a better view of what`s going on.
>>
>> It can be anything XWiki-related:
>> * a tutorial / how-to,
>> * a feature presentation,
>> * an event where XWiki was presented,
>> * an extension that you have worked on and published on
>> extensions.xwiki.org,
>> * tips and tricks on how to boost productivity with XWIki,
>> * a real-life problem that was fixed with XWiki,
>> * news about some public/government agency or even high-profile private
>> company adopting XWiki,
>> * etc.
>>
>> Also, you don`t necessarily have to be a technical person to show your
>> love for XWiki :)
>>
>> Anyone interested would have to do it as an individual, member of the
>> community, using their xwiki.org account. We do not care what company
>> you are from, as long as your article has content that is
>> interesting/valuable for the XWiki community.
>>
>> You should obviously avoid writing SPAM articles, promoting irrelevant
>> products and generally off-topic stuff.
>>
>> Here is how to do it in a few easy steps:
>> 1. Log in with your xwiki.org account and go to the Blog Drafts [2]
>> section
>> 2. Create a new sub-page there (use the + button) and write your article.
>> Don`t forget to save!
>> 3. Contact an XWiki committer either by mail (users or devs list) or by
>> IRC [3], give them the link to your draft and ask them for a review it.
>> 4. If the review is successful, the article gets moved to the main Blog
>> [1] and published.
>>
>> You could view it as a sort of "Pull Request", but for blog articles :)
>>
>> Note: We also accept cross-posting! You can also share an article on
>> XWiki that you have written on some other blogging platform. You can post
>> it entirely or just do a quick summary about it and link to its original
>> location.
>>
>> We hope to see some interesting articles and to increase visibility on
>> what people are achieving with XWiki!
>>
>> Thanks,
>> Eduard
>>
>> --
>> [1] http://www.xwiki.org/xwiki/bin/view/Blog/
>> [2] http://www.xwiki.org/xwiki/bin/view/Blog/Drafts
>> [2] http://dev.xwiki.org/xwiki/bin/view/Community/IRC
>>
>
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users