Modify live search in Alfresco Commmunity 5.0.d - alfresco

I am using Alfresco Community 5.0.d and trying to find the files related to live search.
I would like to remove or modify the people finder in live search. Please let me know the files or way to achieve it.
Share-header.get.js info is below:
if (!user.isAdmin)
{
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_MY_FILES");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SHARED_FILES");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SITES_MENU");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_PEOPLE");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_REPOSITORY");
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_BECPG");
}
//Disable people search
var headerSearch = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCH");
if (headerSearch)
{
headerSearch.config.showPeopleResults = false;
headerSearch.config.placeholder="Search files, sites";
}
Below is extensions.xml
<extension>
<modules>
<module>
<id>Update Site Header</id>
<version>1.0</version>
true
org.alfresco.share.header
com.site-header
share-header
As I added below lines, now I could see that my file, shared file and other menu items being removed for user(non admin) but no changes in search box.
Credit : Muralidharan
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
Screenshot of html structure for search box.
Below is screenshot of modules/deploy:
Screenshot of debug mode :
Thanks in advance

We excluded people search using below script.
//Disable people search
var headerSearch = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCH");
if (headerSearch)
{
headerSearch.config.showPeopleResults = false;
headerSearch.config.placeholder="Search files, sites";
}
And we placed this file, in the following path.
C:\Alfresco5\tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension\site-webscripts\com\quanticate\header\share-header.get.js
Use the module extension to apply your customisation in Share and store this file into alfresco\web-extension\site-data\extensions\extensions.xml
<extension>
<modules>
<module>
<id>Menu customisation</id>
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
<!-- default.extensibility.evaluator is applied to determine if the module should be executed -->
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>com.quanticate.header</sourcePackageRoot> <!-- Your package path should go here -->
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
</customizations>
</module>
</modules>
</extension>

I followed below link and it worked like a charm.
https://community.alfresco.com/message/806438-re-not-able-to-disable-suggestion-in-alfresco?commentID=806438&et=watches.email.thread#comment-806438
Summary:
Override the live-search-people.get.json.ftl file to produce no result for live search.
Steps:
Extract alfresco-remote-api-5.0.d (/Applications/alfresco-5.0.d/tomcat/webapps/alfresco/WEB-INF/lib)
Goto /Applications/alfresco-5.0.d/tomcat/webapps/alfresco/WEB-INF/lib/alfresco-remote-api-5.0.d/alfresco/templates/webscripts/org/alfresco/slingshot/search and copy live-search-people.get.json.ftl
Then goto Applications/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search (create new directory if not exist) and paste the file copied earlier
Open that file in editor like sublime text and replace with following code.
<#import "../../repository/person/person.lib.ftl" as personLib/>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"totalRecords": 0,
"startIndex": 0,
"items":
[
]
}
Restart the tomcat and test live search.
Thanks to Angel and Alex for answer followed with clarification.
Interesting finding that I was using Aikau 1.0.8 Because of that the changes recommended by Muralidharan was not working (older version) so now as I move to newer version of Aikau (1.0.101) then those changes are good to go.
Thank you Muralidharan!
/****NOTE****/
If your using older version of Aikau (like 1.0.8) than you have to override the extension
Or
If your using newer version of Aikau (like 1.0.101) than you can directly make changes.

You have to override the files containing the webscript response. Search for the Freemarker template files which have the rendered output and over-ride it .

Related

Qt Installer Framework - Prevent installation in non-empty folder

I use Qt Installer Framework.
I want to know how to prevent installation in a non-empty folder?
In addition, how can I make the uninstaller remove only the files and folders it has installed, and not all the contents of its folder?
Thank you in advance
Due to the Qt Documentation you have access to the QDesktopServices inside the Scripting API, which contains the function findFiles(string path,string pattern), which should return none in your case, where path is your target directory for installation.
In the TargetDirectory Installer Installer Page you have access to the set TargetDirectory via Installer Page, which can be connected to if there is some edit.
It took me some hard time to figure out the following solution, which I have to admit is not the way I wanted to have it beforehand.
First of all you need a control script, that needs to be set inside your config.xml. It is called controlScript.js and resides in the same directory as your config.xml.
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>Your application</Name>
<Version>1.0.0</Version>
<Title>Your application Installer</Title>
<Publisher>Your vendor</Publisher>
<StartMenuDir>Super App</StartMenuDir>
<TargetDir>#HomeDir#/InstallationDirectory</TargetDir>
<ControlScript>controlScript.js</ControlScript>
</Installer>
Now, the only solution that I brought to work is the following:
controlScript.js
function Controller()
{
console.log("Control script");
}
Controller.prototype.ComponentSelectionPageCallback = function() {
var widget = gui.currentPageWidget();
widget.title="Select empty directory!";
var targetDirWidget = gui.pageById(QInstaller.TargetDirectory);
var targetDir=targetDirWidget.TargetDirectoryLineEdit.text;
var files=QDesktopServices.findFiles(targetDir, "*.*");
if (files.length!=0) {
var result = QMessageBox.warning("quit.question", "You selected a non-empty directory!", targetDir,QMessageBox.Ok);
gui.clickButton(buttons.BackButton);
}
}
Basically, the user enters a target directory and presses the BackButton. In case the target directory is non-empty a message box is displayed and the BackButton in the Component Selection is pressed.
My desired solution was beforehand to deactivate the NextButton in the TargetDirectory Page, but all my attempts were futile. Even though the following disabling of the NextButton should work, as shown in this answer.

How to translate Next, Cancel, Quit Buttons ? (Qt Installer Framework based)

I would like to translate my installer wizard (Qt Installer Framework based) in English or French (OS language depends).
I added those lines in the "installscript.qs" file :
Component.prototype.retranslateUi = function()
{
component.languageChanged();
}
and I added those in "config.xml" file :
<Installer>
...
<Translations>
<Translation>fr.qm</Translation>
</Translations>
</Installer>
But everything is ok (all long texts are translated) (in French) but the buttons like "Next", "Cancel", "Quit" are not translated (see the screenshot) :
ps: I don't want to use C++ code. (only Script or Xml)
You need to load the Qt translation file in addition to your own .qm file(s). The file is located in the translation sub-folder of your Qt installation folder (e.g. ./usr/share/qt5/translations/). For some languages it seems sufficient to load qt_xx (where XX should be replaced with your locale), but for German I had to load "qtbase_XX" to translate the Next and Cancel buttons. In example for the fr locale they are named qt_fr.qm and qtbase_fr.qm.
EDIT:
Because of the comment of John Smith I checked the Installer framework source and the framework is not capable loading more than one translation file:
See installer-framework/src/libs/installer/component.cpp
/*!
Loads the translations matching the name filters \a qms inside \a directory. Only translations
with a base name matching the current locale's name are loaded. For more information, see
\l{Translating Pages}.
*/
void Component::loadTranslations(const QDir &directory, const QStringList &qms)
So my original answer above (which would lead to a translated QWizard::CancelButton) is not working.
I got the Quit button of the Installer Frameworks translation example translated to German by correcting the de.ts file provided within the framworks source in installer-framework/src/sdk/translations
The original translation coming with the feramework is missing an &:
So, changing:
<context>
<name>QInstaller::IntroductionPage</name>
...
<message>
<source>Quit</source>
<translation>Beenden</translation>
</message>
to
<context>
<name>QInstaller::IntroductionPage</name>
...
<message>
<source>&Quit</source>
<translation>Beenden</translation>
</message>
and recompiling the Framework leads to a translated Quit button (Beenden) within the framework.
I did not tried, but studying /installer-framework/src/libs/installer/packagemanagergui.cpp should enable you to translate the Next button, too.
Adding a context may help:
function Component()
{
qsTranslate("QInstaller::IntroductionPage", "&Quit");
}
It woked after Next and Back, but could not find where to write the qsTranslate().

How to Remove Configlet from "Site Setup - Add-on Configuration"

I'm deprecating a Site Setup add-on configlet. The procedure I'm following is add the remove="true" property to controlpanel.xml
<!-- profiles/default/controlpanel.xml -->
<configlet
title="MyConfiglet" ...
remove="true">
<permission>Manage portal</permission>
</configlet>
and then execute an upgradeStep. I tried with
<!-- upgrades/configure.zcml -->
<genericsetup:upgradeSteps ...>
<genericsetup:upgradeDepends
title="Remove Configlet"
import_steps="plone.app.registry controlpanel"
/>
</genericsetup:upgradeSteps>
But after executing the upgrade step, I still can see the configlet in /##overview-controlpanel.
What am I missing? What do I need to remove the configlet from the control panel?
Thanks.
The process of removing something from Plone involves more or less the same steps you used to add it; in this specific case you have two ways of doing it: programmatically or using Generic Setup.
programmatically
I think this is easier as involves no more than a few lines of code and you can debug in case of problems.
just use the following code on your upgrade step:
def remove_configlet(self):
from plone import api
config_tool = api.portal.get_tool('portal_controlpanel')
configlet_id = 'MyConfigletId'
config_tool.unregisterConfiglet(configlet_id)
using Generic Setup
create a controlpanel.xml file inside the profile you're registering for your upgrade step; this file should contain exactly the same stuff used to add the configlet plus the remove="True" attribute.
you can find a working example of this on the upgrade_10_to_11 profile of Products.TinyMCE:
controlpanel.xml
upgrades.py
<?xml version="1.0"?>
<object name="portal_controlpanel" meta_type="Plone Control Panel Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n" i18n:domain="plone.tinymce">
<configlet title="TinyMCE"
action_id="tinymce" appId="TinyMCE"
category="Products"
condition_expr=""
url_expr="string:${portal_url}/portal_tinymce/##tinymce-controlpanel"
visible="True"
i18n:attributes="title"
remove="True">
<permission>Manage portal</permission>
</configlet>
...
</object>
def upgrade_10_to_11(setuptool):
"""Upgrade TinyMCE from 1.0 to 1.1"""
...
# Unregister old js and register new js
setuptool.runAllImportStepsFromProfile('profile-Products.TinyMCE:upgrade_10_to_11')
in case of doubts take a look at Luca Fabbri's excelent blog post on How to make your Plone add-on products uninstall cleanly.

Qt Installer framework component installation location

I've created an installer package based on the Qt installer framework with multiple components.
I needed to install each component in the appropriate directory.
Is it possible to specify the target directory for the individual component? I am referring to something like this:
var appData = installer.environmentVariable("AppData");
if (appData != "")
component.setValue("TargetDir", appData+ "/MyComponent");
Thank you in advance.
This question has already been answered, but I thought I would add a more detailed answer.
The documentation states that "for each component, you can specify one script that prepares the operations to be performed by the installer."
The Qt installer framework QtIFW comes with a set of examples, one of which is called modifyextract. Using this, I modified my package.xml file to include the line
<Script>installscript.qs</Script>
I then added a file installscript.qs to my package meta directory with the following content
function Component()
{
}
Component.prototype.createOperationsForArchive = function(archive)
{
// don't use the default operation
// component.createOperationsForArchive(archive);
// add an extract operation with a modified path
component.addOperation("Extract", archive, "#TargetDir#/SubDirectoryName");
}
The files in the package data folder were then installed in the subfolder SubDirectoryName
You need this based on the documentation:
Extract "Extract" archive target directory Extracts archive to target directory.
In my case, the component.addOperation("Extract", ... line resulted in extracting to #TargetDir#.
Instead, use one of the 'Operations> options in the Package.xml file.

Multi Project Template folder structure incorrect

So i am trying to build a Multi Project template and when i set it up the folder structure is coming out incorrectly (Not how microsoft does it when creating projects) and it's messing things up like the Packages folder and References folder.
This is current Structure:
Solution Folder
-Solution File
-Folder (Solution Name)
--Packages
--References
--Project1 Folder
--Project2 Folder
I am wanting it to have the same structure that .NET does automatically:
Solution Folder
-Solution File
-References Folder
-Packages Folder
-Project1 Folder
-Project2 Folder
Here is my vstemplate:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup">
<TemplateData>
<Name>ASP Solution Template</Name>
<Description>This is the Solution Template for ASP Applications</Description>
<Icon>__TemplateIcon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent BuildOnLoad="true">
<ProjectCollection>
<SolutionFolder Name="References">
</SolutionFolder>
<SolutionFolder Name="packages">
</SolutionFolder>
<ProjectTemplateLink ProjectName="$safeprojectname$">
ASPTemplate\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.ClassLibrary">
ClassLibrary\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Take a look at dotnet new custom templates. I had the same problem and this was a nice easy solution.
https://learn.microsoft.com/en-us/dotnet/core/tutorials/create-custom-template
Create your solution and put your files and/or projects where you like, I'll call the solution MySolution
Add folders, projects, whatever you like
Create a folder at the top level by the solution called .template.config
Create a json file in that .template.config called template.json
The template.json attributes can be found here https://learn.microsoft.com/en-us/dotnet/core/tools/custom-templates
Example template.json:
{
"$schema": "http://json.schemastore.org/template",
"author": "Your goodself",
"classifications": [ "C#", "Awesome", "etc" ],
"identity": "MySolution",
"name": "Empty MySolution",
"shortName": "mysolution",
"sourceName": "MySolution",
"tags": {
"language": "C#"
},
}
sourceName is important, that is used to name your project new project and rename everything.
To see what templates you already have do:
dotnet new -l
To add your new template the above do:
dotnet new -i <fully qualified solution folder>
eg. dotnet new -i c:\dev\MySolution
You should then see your name in a:
dotnet new -l
That's it, ready to use!
Go to a fresh folder and type:
dotnet new mysolution -n MySolutionFromTemplate
You will then see all the folders, files and everything named as expected
Finally if you want to delete the template do:
dotnet new -u c:\dev\MySolution
NOTE: You will probably need this in your nuget repo. There are instructions how to do this here https://learn.microsoft.com/en-us/dotnet/core/tutorials/create-custom-template
I don't think it's possible to add solution folders in the parent solution folder with vstemplates.
However, you could try adding a wizard to your template that enables you to run custom code when a user creates a project from a template.
Follow the instructions here and here, but basically you do something like this:
Implement the IWizard interface in a ClassLibrary-project and use EnvDTE80 to create the folders:
public class MyWizard : IWizard
{
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
// Pseudo-code
var dte = (DTE2)automationObject;
var solution = (Solution2)dte.Solution;
solution.AddSolutionFolder("References");
}
// Default implementations of IWizard here (return true's and do nothing's)
}
Modify your vstemplate to use the wizard:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="ProjectGroup">
<TemplateData />
<TemplateContent BuildOnLoad="true" /> <!-- Remove the SolutionFolder elements -->
<WizardExtension>
<Assembly>CustomWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=fa3902f409bb6a3b</Assembly>
<FullClassName>CustomWizard.MyWizard</FullClassName>
</WizardExtension>
</VSTemplate>
Then the code should be running when you create a project with your new template.
Hope this helps you somehow.

Resources