Create a child page using ruby in confluence - ruby

I want to create a new page in the confluence wiki by using a ruby script. This script will run once a month and everytime create a new page. I know how to create a new page but I can't tell confluence that the created page should be a child page of another one. Here's what I tried:
server = Confluence::Server.new(url)
server.login(confluence['username'], confluence['password'])
template = load_file(template_filename)
erb = ERB.new(template)
page = {
"space" => "lxeng",
"title" => "Release 2015.08",
"ancestors" => [{"id" => 49776851 }],
"content" => erb.result,
}
server.storePage(page)
The code above works perfectly. It just doesn't create the page under the page with the ID 49776851.
I know that you can use the ancestors in other languages but i can't figure out how it works in ruby. How can I tell where the new page should be placed?
Any help would be much appreciated

Related

Middleman gem, Need to localize tag.html template for taging

I built a static application that has a blog configured. I have a languages dropdown from which users can switch the language.
Every article has some tags and when the user clicks on any tag it loads the tag detail page. On the detail page when switching the language the path got a page not found error.
activate :i18n, :mount_at_root => :en, :path => "/:locale", :lang_map => {:en => :""}
I18n.available_locales = [:en, :es, :fr, :jp, :ko, :pt, :ru, :th, :zh, :it]
activate :blog do |blog|
blog.prefix = "blog"
blog.permalink = "{lang}/{year}-{month}-{day}-{title}"
blog.sources = "{lang}/{year}-{month}-{day}-{title}"
blog.layout = "blog"
blog.tag_template = "tag.html"
blog.paginate = true
blog.per_page = 9
blog.page_link = "page/{num}"
end
My paths work like this
http://localhost:4567/fr/
http://localhost:4567/fr/blog
Tag detail page in default language is
http://localhost:4567/blog/tags/announcement/
when I change the language like this
http://localhost:4567/fr/blog/tags/announcement/
Got and error File not Found
/fr/blog/tags/announcement/

Yii2. Language picker widget not working properly

I use \lajax\languagepicker in Yii2.
Languagepicker dropdown located in header nav inside <li> element.
$menuItems [] = '<li>'.LanguagePicker::widget(['skin' => LanguagePicker::SKIN_DROPDOWN, 'size' => LanguagePicker::SIZE_LARGE,
'itemTemplate' => '<li><i class="{language}"></i></li>',
'activeItemTemplate' => '<i class="{language}"></i>',
]).'</li>';
Language of website is changing only when I add below code to the view being rendered:
use \lajax\languagepicker\widgets\LanguagePicker;
LanguagePicker::widget();
If above code is not added Language does not change.
I suspect it can be related to ajax loading.
What could be a problem?
Check your DB in user table column language
Add it if not exist.
After that LanguagePicker start working for me.

column template kendo ui grid mvc action link

The following code is working fine in development, as soon as i deploy in web server it said could find file directory. I need to change the .client template so its not hard coded like before. So if we deploy to the server where the Top folder name different or the hierarchy change, it still find the page.
I was thinking using #Url.Action but not sure how in this case to implement in .CLientTemplate
columns.Template(#<text>
#Html.ActionLink(#item.FirstName, "Index", "Summary", new { testId = #item.FirstName })
</text>)
.ClientTemplate("<a href='/Summary/Index/?testId =#= TestId #'>#=FirstName#</a>").Title("First Name");
Something like this should do:
.ClientTemplate("<a href='" + Url.Action("Index", "Summary", new { testId = "#=TestId#" }) + "'>#=FirstName#</a>")
I got this one working fine
columns.Bound(a => a.Id)
.Title("Action")
.Filterable(false)
.ClientTemplate(
"<a href='"
+ Url.Action("ActionName", "Controller")
+ "/#= Id #'"
+ ">View</a>"
);
I needed an extra column and a link button field for go to details page of a customer. I don't need filter option for this column and that is why I remove it using Filterable(false). Also you can give the link content and column header as above. This value "/#= Id #'" is the one I pass to the controller action method.
In case you're using server-binding (as opposed to ajax) and Razor as your view-engine, here is an example. I need a link such as /Controller/Action/Id where Id is obtained from a property of the model. Please note that #item denotes the model instance being currently processed by the grid.
columns.Template(#<text>#Html.ActionLink(AbaScore.Resources.App.Edit,"ACTION", "CONTROLLER", new { #item.Id }, null)</text>)
I've seen 87 different examples of this and none of them worked. This is what I finally did and it worked, and it's simple as heck.
columns.Bound(p => p.member_id)
.ClientTemplate("<a href='/members/details/#=member_id#'>Details</a>")
;

Rails 3 MarkItUp Preview

So I've implemented the Markitup bbcode editor in my Rails application and I'm currently attempting to get the preview functionality working. I followed a 4 year-old blog entry install markitup! in Ruby on Rails which got me pretty close to what I need to do. So far, when I press the preview button it renders an iframe that displays a blank template for me.
In my jquery.markitup.js I have this line as one of the options:
previewTemplatePath: '/templates/preview',
Which will make an ajax request to retrieve the page for the route:
resources :templates do
collection do
get :preview
end
end
Currently the preview action simply sets render :layout => false so I don't duplicate html. As for the preview.html.erb page itself I simply have:
<%= bb(params[:data]) %>
And the idea behind this is to send the markup entered in the editor into the params data hash and then pass that through my bb code helper which does the parsing and returns some html.
The Problem
I don't know how to fill that params[:data] with the bb code entered into the markitup editor. Does anybody know how I can send that off?
Extra details:
I thought I would include all the options I'm passing off to markItUp:
options = { id: '',
nameSpace: '',
root: '',
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
previewAutoRefresh: true,
previewPosition: 'after',
previewTemplatePath: '/templates/preview',
previewParser: false,
previewParserPath: '',
previewParserVar: 'data',
resizeHandle: true,
beforeInsert: '',
afterInsert: '',
onEnter: {},
onShiftEnter: {},
onCtrlEnter: {},
onTab: {},
markupSet: [ { /* set */ } ]
};
The previewTemplatePath and the previewParserPath options needed to be set when I make the call to markItUp!.
The previewTemplatePath points to the view that displays the rendered preview and the previewParserPath is meant to point to your controller action that handles the parsing and data parameter. Assuming you're following dry conventions both paths should be the same as it was in my case.
For a better look at how to integrate markItUp! with rails check out the source for branch14's markupitup gem.

The url from an image via custom field (wordpress)

Am not even sure if this can be done but...
Ive added a feed from my forums to wordpress it works great but I need it to auto add the url of the image in a custom field from the images in the post (feed) first image would be fine as its only ahve a slider
Is there any way to do this?
Details
Ok I think I did not explain this very well so made a few screen shots
This is my slider at the minute with my
This is an imported post one other feed I was using
On this image you can see the custom field (which I have to fill in after every import)
Adding the image url into the custom field
and finaly a view of the slider working
This is what am trying to do (auto) so my feed from my booru / forums / 2 other of my sites and (2 other peoples) sites make my home page on a new site
Hope this explain it alot more
This uses the external Simple Pie library built into WordPress to fetch the feed, get the image url and create a new post for each item and save the image url as a custom field.
To activate the process we have to hook into wp_cron. The code below does it daily but it would probably be better to do it weekly to prevent overlap. Some overlap will probably occur so this still needs a way to check if we have already imported the image
First we need a function to save the custom field after the post has been created. This section comes from another answer I found on WordPress Answers.
Edit:
This needs to be wrapped in a plugin to schedule the cron event and the cron event was missing the action to make it fire.
Edit:
Final version below tested and it works but the feed the OP is getting is using relative url's so the domain name needs to be added somewhere in the output code.
<?php
/*
Plugin Name: Fetch The Feed Image
Version: 0.1
Plugin URI: http://c3mdigital.com
Description: Sample plugin code to fetch feed image from rss and save it in a post
Author: Chris Olbekson
Author URI: http://c3mdigital.com
License: Unlicense For more information, please refer to <http://unlicense.org/>
*/
//Register the cron event on plugin activation and remove it on deactivation
register_activation_hook(__FILE__, 'c3m_activation_hook');
register_deactivation_hook(__FILE__, 'c3m_deactivation_hook');
add_action( 'c3m_scheduled_event', 'create_rss_feed_image_post');
function c3m_activation_hook() {
wp_schedule_event(time(), 'weekly', 'c3m_scheduled_event');
}
function c3m_deactivation_hook() {
wp_clear_scheduled_hook('c3m_scheduled_event');
}
function create_rss_feed_image_post() {
if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php'); // include the required file
$feed = fetch_feed('http://animelon.com/booru/rss/images'); // specify the source feed
}
foreach ($feed->get_items() as $item) :
// global $user_ID;
$new_post = array(
'post_title' => $item->get_title(),
'post_status' => 'published',
'post_date' => date('Y-m-d H:i:s'),
//'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
if ($enclosure = $item->get_enclosure() )
update_post_meta( $post_id, 'feed_image_url', $enclosure->get_link() );
endforeach;
}

Resources