I'm using Bliki-core (version-3.1.0) to access a wikipedia page with the the title "Web service" for my test case. My code is below
String[] listOfTitleStrings = { "Web service" };
User user = new User("", "", "https://en.wikipedia.org/w/api.php");
user.login();
List<Page> listOfPages = user.queryContent(listOfTitleStrings);
for (Page page : listOfPages) {
WikiModel wikiModel = new WikiModel("${image}", "${title}");
String html = wikiModel.render(page.toString());
System.out.println(html);
}
When i access the URL:
http://en.wikipedia.org/w/api.php?
format=xml&action=query&titles=Web%20service&prop=revisions&rvprop=content
I can see the xml output.
But when I run my java code i get the following output
<p>Page{ns=0, title=Web service, id=93483, links=[], categories=[],
editToken='null', imageUrl='null', imageThumbUrl='null',
missing=false, invalid=false, revision=info.bliki.api.Revision#74e46064}</p>
What am I missing here?
Thanks
Changing version of bliki-core to an earlier version 3.0.19 fixed the issue.
Related
Backgroud:
Use Java + BIRT to generate report.
Generate report in viewer and allow user to choose to export it to different format (pdf, xls, word...).
All program are in "Layout", no program in "Master Page".
Have 1 "Data Set". The fields in "Layout" refer to this DS.
There is Group in "Layout", gropu by one field.
In "Group Header", I create one cell to use as page number. "Page : MyPageNumber".
"MyPageNumber" is a field I define which would +1 in Group Header.
Problem:
When I use 1st method to generate report, "MyPageNumber" could not show correctly. Because group header only load one time for each group. It would always show 1.
Question:
As I know there is "restart page number in group" in Crystal report. How to restart page in BIRT?
I want to show data of different group in 1 report file, and the page number start from 1 for each group.
You can do it with BIRT reports using page variables. For example:
Add 2 page variables... Group_page, Group_name.
Add 1 report variable... Group_total_page.
In the report beforeFactory add the script:
prevGroupKey = "";
groupPageNumber = 1;
reportContext.setGlobalVariable("gGROUP_NAME", "");
reportContext.setGlobalVariable("gGROUP_PAGE", 1);
In the report onPageEnd add the script:
var groupKey = currGroup;
var prevGroupKey = reportContext.getGlobalVariable("gGROUP_NAME");
var groupPageNumber = reportContext.getGlobalVariable("gGROUP_PAGE");
if( prevGroupKey == null ){
prevGroupKey = "";
}
if (prevGroupKey == groupKey)
{
if (groupPageNumber != null)
{
groupPageNumber = parseInt(groupPageNumber) + 1;
}
else {
groupPageNumber = 1;
}
}
else {
groupPageNumber = 1;
prevGroupKey = groupKey;
}
reportContext.setPageVariable("GROUP_NAME", groupKey);
reportContext.setPageVariable("GROUP_PAGE", groupPageNumber);
reportContext.setGlobalVariable("gGROUP_NAME", groupKey);
reportContext.setGlobalVariable("gGROUP_PAGE", groupPageNumber);
var groupTotalPage = reportContext.getPageVariable("GROUP_TOTAL_PAGE");
if (groupTotalPage == null)
{
groupTotalPage = new java.util.HashMap();
reportContext.setPageVariable("GROUP_TOTAL_PAGE", groupTotalPage);
}
groupTotalPage.put(groupKey, groupPageNumber);
In a master page onRender script add the following script:
var totalPage = reportContext.getPageVariable("GROUP_TOTAL_PAGE");
var groupName = reportContext.getPageVariable("GROUP_NAME");
if (totalPage != null)
{
this.text = java.lang.Integer.toString(totalPage.get(groupName));
}
In the table group header onCreate event, add the following script, replacing 'COUNTRY' with the name of the column that you are grouping on:
currGroup = this.getRowData().getColumnValue("COUNTRY");
In the master page add a grid to the header or footer and add an autotext variable for Group_page and Group_total_page. Optionally add the page variable for the Group_name as well.
Check out these links for more information about BIRT page variables:
https://books.google.ch/books?id=aIjZ4FYJOQkC&pg=PA85&lpg=PA85&dq=birt+change+autotext&source=bl&ots=K0nCmF2hrD&sig=CBOr_otRW0B72sZoFS7LC_1Mrz4&hl=en&sa=X&ei=ZKNAVcnuLYLHsAXRmIHoCw&ved=0CEoQ6AEwBQ#v=onepage&q=birt%20change%20autotext&f=false
https://www.youtube.com/watch?v=lw_k1qHY_gU
http://www.eclipse.org/birt/phoenix/project/notable2.5.php#jump_4
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316173
http://www.eclipse.org/forums/index.php/t/575172/
Alas, this is not supported with BIRT.
That's probably not the answer you've hoped for, but it's the truth.
This is one of the very few aspects where BIRT is way behind other report generator tools.
However, depending on how you have BIRT integrated into your environment, a workaround approach is possible for PDF export that we use in our solution with great success.
The idea is to let BIRT generate a PDF outline based on the grouping.
And the BIRT report creates information in the ReportContext about where and how it wants the page numbers to be displayed.
After BIRT generated the PDF, a custom PDFPostProcessor uses the PDF outline and the information from the ReportContext to add the page numbers with iText.
If this work-around is viable for you, feel free to contact me.
I want to make a tampermonkey script that basically changes the url of the page. What I want to do is to look if the url has "youtube.com" in it and if it doesn't then it should add /youtube.com to the url.
An example of this is:
The starting website: www.website.com/watch8dzjad8
The changed website: www.website.com/youtube.com/watch8dzjad8
If it helps then the script is meant to be finished in tampermonkey, so that on a specific website it is going to scan for the link and add the /youtube.com if it can't find it since it won't work otherwise and it would really help me to not to copy and paste /youtube.com 10 times a day, as well as to learn how to work with URL's in JavaScript. Thanks in advance
if( !location.host.match(/youtube.com/) )
location= "/youtube.com"+ location.pathname
But instead of that you should restrict this behaviour to a specific site, not just all domains that are not youtube, for example:
if( location.href.match(/website.com\/watch/) )
location= "/youtube.com"+ location.pathname
Explanations
location.href.match(/website.com/watch/)
location.host is the domain of the page (www.website.com)
location.href is the complete URL of the page (http://www.website.com/watch8dzjad8)
match tests if the string follow the given pattern
location= "/youtube.com"+ location.pathname
setting location implies opening the given URL
location.pathname gives the path of the URL (/watch8dzjad8)
So if the URL (http://www.website.com/watch8dzjad8) of the visited page contains the string "website.com/watch", then open "/youtube.com" + "/watch8dzjad8".
As the domain is the same, a relative URL is enough, the browser knows that is the same domain as the current page.
https://developer.mozilla.org/en-US/docs/Web/API/Window/location
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
try this
function getQueryValue( myUrl ){
myUrl = newUrl.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]" + myUrl + "=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( location.href);
if( results == null )
return "";
else
return results;
}
//current url
var curUrl = location.href;
//new url
var newUrl = getQueryValue( "curUrl" );
//redirect to new page
location.href = newUrl;
}
How to use facebook api taggable_friends by Open Graph tag friend.
my app use taggable_friends api i want to tag my friend in friends wall.
to use Mentioning friends or Tagging friends
https://developers.facebook.com/docs/opengraph/using-actions/v2.0#capabilities
And I use Open Graph doc Step by Step to try
but give me "You, or this app's Open Graph Test User, must have published this action at least once" how to setting?
https://developers.facebook.com/docs/apps/review/opengraph
On FB javascript sdk,
-* fb dashboard -> Open Graph
Create a story
List item make sure you enable the 'capabilities' features such as -tags, -user messages, -place, etc. in your action type.
-* in your js
1. call the js sdk
window.fbAsyncInit = function() {
FB.init({
appId : {YOUR_APP_ID} , // App ID
version: 'v2.0',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/sdk.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
}
3. Login into FB asking with these scopes
function Login()
{
FB.login(function(response) {
if (response.authResponse)
{
console.log(response.authResponse); // Get User Information.
} else
{
console.log('Authorization failed.');
}
},{scope: 'user_friends, publish_actions, status_update, read_stream, manage_friendlists'});// ' user_interests, user_likes, etc.. '
}
4. Get the logged user taggable_friends with a function such as:
var var friendsIDarray = [];
var user_friend_list;
function meTaggableFriends(){
FB.api(
"/me/taggable_friends",
function (response) {
if (response && !response.error) {
/* handle the result */
console.log(response)
for(var i=0; i<response.data.length; i++){
var data = response.data;
friendsIDarray.push(data[i].id);
}
user_friend_list = friendsIDarray.join();
}
}
);
5. Now, we have stored the token ids in user_friend_list for those friends we want to tag in our post
and we can use an Open Graph action like this in order to tag friends:
FB.api(
'me/{namespace}:{action}',
'post',
{
{object-type}:'http://example.com/object/', // make sure to have the apropiate og:type meta set
place:'https://example.com/place/', // open graph page with metas for location, id for a location page etc
tags: user_friend_list, // the tokens ids for those friens you wanna tag and you got on previous step
title: 'whatever',
message: 'like this, you tag friends #['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] , #['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] etc'
},
function(response) {
console.log(response)
}
);
you can find more information about it on:
https://developers.facebook.com/docs/opengraph/using-actions/v2.1
Hope you find it useful.
the error message "You, or this app's Open Graph Test User, must have published this action at least once" means: before you require this permission, you must call the api at least once.
I have occur this kind error before. when I require publish_actions permission, the facebook tell me this:
then I used my app call /me/feed api post a feed, then the error disappeared.
if you are the owner, developers or test users of the app, you can use these api before review approval. you can add roles for app in dashboard.
I have a problem about jsoup because of lazyload scrollLoader.js
I reach site with java code, i have listed only 50 image name by jsoup.But when scroll down on site ,lots of image loads continously. My question is that, is it possible to post image amount into url that uses with Jsoup.connect() to get all image from the site?
here is site : http://www.logowik.com
And this is the usege of script in the site :
<script type="text/javascript">
$(document).ready(function(e) {
CalculateColumns();
recordCount = 50;
groupID = "0";
catID = "0";
query = "";
userEntry = "";
groupInterval = "0";
AddEvent(window, "resize", CalculateColumns);
document["scrollLoader"] = new scrollLoader({evn : getGrids, seize : 1});
document["scrollLoader"].DoScroll();
addLogoClickEvent();
});
</script>
I post this parameters with url like :
http://www.logowik.com/index.php?g=1&groupID=1&catID=0
with this url I get 50 image,because of recordCount = 50 in script. but i cannot post this parameter to url.
For getting 100 images, I try this url: http://www.logowik.com/index.php?recordCount=100&g=1&groupID=1&catID=0
but it doesn't effect.
Thanks
Use firebug or chrome dev tools network panel to see all the requests generated when loading the images, then just recreate them in jsoup.
Document doc = Jsoup.connect("http://reviews.opentable.com/0938/9/reviews.htm").get();
Element part = doc.body();
Elements parts = part.getElementsByTag("span");
String attValue;
String html;
for(Element ent : parts)
{
if(ent.hasAttr("class"))
{
attValue = ent.attr("class");
if(attValue=="BVRRReviewText description")
{
System.out.println("\n");
html=ent.text();
System.out.println(html);
}
}
}
Am using Jsoup.jar for the above program.
I am accessing the webpage and my aim is to the print the text that is found within the tag <span class="BVRRReviewText description">text</span>.
But nothing is getting printed as output. There is no contents added to the String html in the program. But attValue is getting all the attribute values of the span tag.
Where must I have went wrong? Please advise.
if(attValue=="BVRRReviewText description")
should be
if(attValue.equals("...")) surely?
This is Java, not Javascript.
Change
attValue=="BVRRReviewText description"
for
attValue.matches("...")