Retriving previous version of a content using API in Ektron - ektron

I am working on Ektron 8.6.
How can i retrive the previous version of a Content by passing the Content Id using API?
Previous version in the sense the content data before editing(there may be multiple edits for a content).Is it able to retrieve these different versions through API?
Whether any utility is there in ektron to directly convert Content to a doc?

Here's a sample:
var contentManager = new ContentManager();
var historyList = contentManager.GetHistoryList(contentId);
foreach(var historyData in historyList)
{
var contentData = contentManager.GetContentByHistoryId(historyData.Id);
}
The relevant namespace you'll want to take can be found here: Ektron.Cms.Framework.Content.ContentManager.

Related

How do you add a "general info" section to an NSwag generated API document website?

Our current method uses a manually maintained and formatted YML document. At the beginning is a lengthy introduction/instruction section that I would like to include in generated documentation. The swagger docs suggest that I can add a markdown compatible, multi-line description but that's not really something I want to do in my Startup.cs file. How can I add this sort of extended introduction?
An example of the what I'm looking to do is shown on docs.discourse.org which is generated using Redoc.
I would suggest placing your API introduction to a static file that is copied to build output, then configure open api document to read it.
The file can contain HTML markup or markdown. I tend to use markdown to get heading links appear in the sidebar in redoc, it is completely up to you.
services.AddOpenApiDocument(document =>
{
document.Description = File.ReadAllText("Docs/Description.html");
// other properties
document.AddSecurity("Bearer", Enumerable.Empty<string>(), new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.ApiKey,
Name = "Authorization",
In = OpenApiSecurityApiKeyLocation.Header,
Description = File.ReadAllText("Docs/Authentication.html")
});
document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("Bearer"));
});

Get BlogPost based on Taxonomy

I'm trying to create a custom Blog post rotator for a homepage. It shows the 5 newest posts (Title, summary, date, and link) this works with the following code
var posts = App.WorkWith().BlogPosts().Publihed().Get().OrderByDescending(p => p.PublicationDate).Take(5)ToList();
But I only want to get posts with specific Tags. I'm able to get the Guid associated with a specific tag
TaxonomyManager taxmanager = TaxonomyManager.GetManager();
var taxonGuidId = taxmanager.GetTaxa<FlatTaxon>().Where(t => t.Name == "SpecificTag").Single().Id;
I can foreach through every post and see lots of information but cannot figure out how to determine if the specific Guid is attached to that post. Or take the post and get a list of Taxon; something like
var postTaxon = GetTaxon(BlogPost)
Is there a reason you need to use a custom widget? I would recommend using the standard list widget for blogs select the tag you want to show and then limit it to 5. Once you do that you can then us your JavaScript to create the rotator from the default classes or modify the template to have custom classes.

Filter explicit images in google api

Hi i want to filter the explicit images when i run my application(in local and server).
how to i restrict the images which are containing adult images what should i do for restrict images using google custom search engine please anyone help me.
i am using below code but its not working.
<script type="text/javascript">
google.load('search', '1');
function initialize() {
var searchControl = new google.search.SearchControl();
searchControl.addSearcher(new google.search.ImageSearch());
searchControl.draw(document.getElementById("searchcontrol"));
searchControl.execute("sunset");
}
google.setOnLoadCallback(initialize);
</script>
You can use following code from this guide
var searcher = new google.search.ImageSearch();
searcher.setRestriction(
google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_STRICT);
imageSearch.setSearchCompleteCallback ...
imageSearch.execute....
Also notice:
Adult filtering works only for few languages (please see it here)
This API marked as deprecated. Probably in future you should use some sort of this API. I am still using deprecated API, but in any time Google can disable this one.

Ektron Workarea

I need to develop an application that extracts all the contents in Content Tab of the Ektron Workarea and I have to keep tree structure of folders (taxonomies,collections,forms,etc.) also.When I click the content I need to get the Content ID in the code behind also.I need to do all these in a single function.
I tried this requirement with the concept of content block widget in workarea.When we drag that widget and edit it a pop up will come and it displays the folders of work area in tree structure.But when I created an aspx page, put the same code and I browse that page I didn't get the tree structure of all contents.Only the main tabs(Folders,Taxonomies and search ) are visible.Then I drag the user control in the aspx page .But it also doest work.
So how will I solve the above problem.
Can I pull all the contents in tree structure from work area from the root using API codes?.Then can anyone please give the API code to solve?
Please anyone reply!
Assuming you are using 8.6 look here to start with:
http://reference.ektron.com/developer/framework/content/contentmanager/getlist.aspx
Update:
I think I misread your question the first time around. Allow me to expand on my answer a bit. My original answer with the web services assumes that you are rendering the content tree from some sort of "presentation tier" -- a different web site, a console app, or a WPF/WinForms app, etc.
You can get the recursive folder structure with something like this:
private FolderData GetFolderWithChildren(long folderId)
{
var folderApi = new Ektron.Cms.API.Folder();
var folderData = folderApi.GetFolder(folderId);
// This next method is marked as obsolete in v9.0;
// a newer overload is available in v9.0, but I
// don't know if it's available in v8.0
folderData.ChildFolders = folderApi.GetChildFolders(folderId, true);
}
I'm a little confused as to what exactly you're trying to accomplish. If you want to show the entire tree structure graphically, have you tried taking the code and markup from the edit view of the content widget and using it on your non-edit view?
I must say, your requirement that "I need to do all these in a single function" worries me a bit. Workarea content trees can get really large very quickly. If you're trying to load all of the folders and all the taxonomies and all the collections, etc. Then the user will likely be waiting a long time for the page to load, and you risk running into timeout issues.
-- Original Answer --
Ektron v8.0 doesn't have the 3-tier option, which is too bad because that would really make your job a lot easier. In v8.0, there are ASMX web services that you can reference, including:
/workarea/webservices/content.asmx
/workarea/webservices/webserviceapi/user/user.asmx
There are lots more than this; browse through the folders within /workarea/ to see what's available.
It's been a while since I've worked with these services, so I'm a little rusty...
Suppose you add references to those two services I listed above and name them ContentService and UserService. The first thing you'll want to do is set the authentication headers. Then you can call the service methods in much the same way as the old legacy apis.
var contentApi = new ContentService.Content();
contentApi.AuthenticationHeaderValue = new ContentService.AuthenticationHeader();
contentApi.AuthenticationHeaderValue.Username = username;
contentApi.AuthenticationHeaderValue.Password = password;
contentApi.AuthenticationHeaderValue.Domain = domain;
var userApi = new UserService.User();
userApi.AuthenticationHeaderValue = new UserService.AuthenticationHeader();
userApi.AuthenticationHeaderValue.Username = username;
userApi.AuthenticationHeaderValue.Password = password;
userApi.AuthenticationHeaderValue.Domain = domain;
var ud = userApi.GetUserbyUsername("jimmy456");
long folderID = 85;
bool recursive = true;
ContentData[] folderContent = contentApi.GetChildContent(folderID, recursive, "content_id");

How to get the application name by code?

How can I get the application name by javascript code in a Windows 8 based app?
EDIT: Being more precise: I want the String in package.appxmanifest -> Application UI -> Display name
var package = Windows.ApplicationModel.Package.current;
var displayName = package.displayName;
Added in 8.1
Marco's answer was helpful, but converting to Javascript proved slightly difficult because of the poorly documented XML namespace requirement. LINQ-to-XML as with XDocument isn't available in WinJS but was used in Marco's referenced C# resource.
Here's how I got the app name. Note that it is asynchronous; AFAIK there is no synchronous way to get the application name.
var appname;
(function() {
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("AppxManifest.xml").then(function(file) {
Windows.Storage.FileIO.readTextAsync(file).done(function (text) {
var xdoc = new Windows.Data.Xml.Dom.XmlDocument();
xdoc.loadXml(text);
appname = xdoc.selectNodesNS("m:Package/m:Applications/m:Application/m:VisualElements",
"xmlns:m=\"http://schemas.microsoft.com/appx/2010/manifest\"")[0]
.attributes.getNamedItem("DisplayName").nodeValue;
});
});
})();
According to this reference, there is no way to get the display name. You can get the package name from Package.Id, but it sounds like you want the display name.
You can take a look to the AppManifestHelper class that is included in the Callisto Control Toolikit. The GetManifestVisualElementsAsync method returns a VisualElement object with the property DisplayName, that is what you're looking for.
Note that this code is in C#, so you need to convert it to Javascript.