-
Create the Shortable Aspect:
- Copy shortUrlModel.xml in the repository in /Data dictionary/Models
- edit document properties and activate the model
-
Make the aspect and the property visible:
- Add the content of share-config-custom.xml to /tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml
- restart Alfresco
-
Create the script to generate the short url:
- Copy createShortUrl.js in the repository in /Data dictionary/Scripts
-
Create a Rule in a folder (can be the root of the document library of your share site):
- When the content is added
- For all the content NOT having the aspect "Short url enabled"
- Execute two actions:
- Add "Short url enabled" aspect
- Execute Script createShortUrl.js
- Apply rule to subfolders
-
If you add a document to the folder you will see it will have a property (dw:shorturl) of 3 or 4 chars eg. xyz
- now you can find the document in the search page eg. http://localhost:8080/share/page/search?t=dw:shorturl:xyz
-
To have a really short url you can use, for example, a rewrite rule on Apache as in rewrite-rule.conf
Created
May 24, 2012 06:48
-
-
Save agea/2779867 to your computer and use it in GitHub Desktop.
Alfresco Short URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shortUrl = document.properties['dw:shorturl']; | |
while (!shortUrl){ | |
var newUrl = ""; | |
var length = 3; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < length; i++ ){ | |
newUrl += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
var nodes = search.luceneSearch("@dw\\:shorturl:"+newUrl); | |
if (nodes.length==0){ | |
shortUrl = newUrl; | |
document.properties['dw:shorturl']=shortUrl; | |
} | |
length++; | |
} | |
document.save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteRule ^/s/(.*)$ /share/page/search?t=dw:shorturl:$1 [R] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="dw:shortable"> | |
<description>Shortable Aspect</description> | |
<author>Andrea Agili</author> | |
<version>1.0</version> | |
<imports> | |
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/> | |
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/> | |
</imports> | |
<namespaces> | |
<namespace uri="http://drwolf.it/model/1.0" prefix="dw"/> | |
</namespaces> | |
<aspects> | |
<aspect name="dw:shortable"> | |
<title>Short url enabled</title> | |
<properties> | |
<property name="dw:shorturl"> | |
<type>d:text</type> | |
</property> | |
</properties> | |
</aspect> | |
</aspects> | |
</model> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment