I am creating a static site using grunt.js and assemble. I have a data.json file used for building pages using assemble:
{
"articles": [
{
"author": "Brian",
"headline": "A Generation on the Hook 1",
"body": "cars, and start businesses by means of debt",
"slug" : "n-hook1",
"publish_on": "2014-10-10T04:00:00+00:00",
"url": "http://example.com/2014/oct/08/n-hook1/",
},
{
"author": "Brian",
"headline": "A Generation on the Hook 2",
"body": "As millions go to college, buy homes,",
"slug" : "n-hook2",
"publish_on": "2014-10-12T04:00:00+00:00",
"url": "http://example.com/2014/oct/08/n-hook2/",
},
],
}
I would like the output to be created in the following directories like this: 2014/oct/08/n-hook1/index.html. How can I create the directories in assemble?
Is this even possible with assemble.io? If there is something better, let me know. I am new to the js world and would like some direction. I did see this question but this seems to involve placing the files in different directories. Maybe I have to write a helper? If so, I am not sure where to start.
I like assemble because pages that are generated a completely upt o the client side rendering, and I just present the json data. Not sure if there is something better.
The grunt-assemble-permalinks plugin was the solution, it does what I need.
Related
I have an app where I can search for Books and Movies. These 2 entities have different properties, so their JSON structures are different.
I also have a GET /favorites endpoint which should return both Books and Movies.
GET /favorites
{
"favorites": [
{
"type": "book",
"title": "Foo",
"author": "John"
},
{
"type": "movie",
"name": "Bar",
"producers": [
{
"firstName": "Mary"
}
]
}
]
}
I searched for for docs on this case but I can't find anything. How can I write a Pact contract for this use case?
I would write two separate test cases for this, and use Provider States to differentiate the two payloads.
For example:
When there are books
When there are movies
Or something to that effect. See [1] for related background on this.
[1] https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes
In Qt app example, they use single *.ui.qml form files. I understand everything but I was used to creating 2 files, for example, Contact.qml and ContactForm.ui.qml, instead of one ContactForm.ui.qml. Now if I want to create such a single form file, I have/see two options:
While creating standard QML file (Qt Quick 2), I give name and whole .ui.qml extension.
I create QtQuick Ui File (which creates 2 files) and delete one (business logic) file.
For me, both options seem to be workarounds, not the Qt way. Could you show me the Qt way?
(Casually, you can open not only .ui.qml but any qml file in design mode if you follow the roles see this post).
The list of wizards seen when adding new in Creator, are the standard wizards that Qt probably thinks are sufficient and suitable with a general perspective.
Qt offers a solution though ... you can add your own custom wizard to the list of standard wizards in Qt Creator, following Qt documentation Adding New Custom Wizards creation procedure, so you can add more to existing wizards.
Specifically for .ui.qml only (without the qml file) creation, the section Adding JSON-Based Wizards in the above documentation works just fine, for example:
Start Creator from command line with verbose option:
Qt_base\Tools\QtCreator\bin>qtcreator.exe -customwizard-verbose
In Tools, Options, Keyboard ... filter by Factory.Reset and fill up a new short cut, if one does not exist, for example Ctrl+Alt+F10
In folder C:\Qt\Tools\QtCreator\share\qtcreator\templates\wizards\classes ... copy the wizard folder used to create .ui.qml qtquickui and rename it to any name.
Now and most important, inside the new folder, edit the wizard json file to customize your new wizard ..
(1) Give new id following roles described in the link
(2) under options remove the option for adding qml file along with the form.
(3) under pages, remove the field that prompts for qml file name.
(4) in section "name": "FormClass", modify "trText": "%{Class}Form" to "trText": "Form"
(5) under generators , remove the qml file generator and keep the .ui.qml file generator.
After editing is completed, you can now activate the new wizard, to do that press the short cut created above (Ctrl+Alt+F10) and that's all! you should now see your new wizard when you go Add new under Qt section ...
Here is modified version of wizard.json
{
"version": 1,
"supportedProjectTypes": [ ],
"id": "S.QtQuickUi",
"category": "R.Qt",
"trDescription": "Creates a Qt Quick Designer UI form along with a matching QML file for implementation purposes. You can add the form and file to an existing Qt Quick Project.",
"trDisplayName": "QtQuick UI File Only",
"trDisplayCategory": "Qt",
"iconText": "ui.qml",
"featuresRequired": [ "QtSupport.Wizards.FeatureQtQuick.UiFiles" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmlJSEditor') >= 0}",
"options" : [
{ "key": "UiFile", "value": "%{FormClass}.%{JS: Util.preferredSuffix('application/x-qt.ui+qml')}" }
],
"pages" :
[
{
"trDisplayName": "Define Class",
"trShortTitle": "Details",
"typeId": "Fields",
"data" :
[
{
"name": "FormClass",
"trDisplayName": "Component form name:",
"mandatory": true,
"type": "LineEdit",
"data": {
"validator": "(?:[A-Z_][a-zA-Z_0-9]*|)",
"fixup": "%{JS: '%{INPUT}'.charAt(0).toUpperCase() + '%{INPUT}'.slice(1) }",
"trText": "Form"
}
},
{
"name": "TargetPath",
"type": "PathChooser",
"trDisplayName": "Path:",
"mandatory": true,
"data":
{
"kind": "existingDirectory",
"basePath": "%{InitialPath}",
"path": "%{InitialPath}"
}
}
]
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators" :
[
{
"typeId": "File",
"data": [
{
"source": "fileForm.ui.qml.tpl",
"target": "%{TargetPath}/%{UiFile}",
"openInEditor": true
}
]
}
]
}
This just seems like a missing feature in Creator. Go with option #1 since it's less work, and report a suggestion/bug that there should be a way to create standalone .ui.qml files.
Is there a way to retrieve versioned content of document? Possibly by native Alfresco's REST API.
The answer given by Matteo Calò is technically correct. That API does exist and it does what he says. However, that endpoint is marked with "limited support" which means you should be cautious when using it. Instead, you should prefer API's marked "PUBLIC" or use standards-based API's like CMIS, which Alfresco supports.
The CMIS browser binding can be used to get an object's content like this:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt
Its properties like this:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt?cmisselector=object
And its versions like this:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt?cmisselector=versions
In this example I'm retrieving the object by path. My test object is in a folder called test and my object's name is test.txt. If, on the other hand, you know the object's ID, you could get its versions like this:
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?cmisselector=versions&objectId=54f47f6f-ee88-4612-8206-ebca8f5b7e6b;3.0
Any time you can use a CMIS URL to give you what you need, you should use it, especially if the alternative is a web script that may not be fully public.
There is follow API:
http://HOST:PORT/share/proxy/alfresco/api/version?nodeRef=NODEREF
it returns a list of versions with metadata of NODEREF like this:
[{
"nodeRef": "versionStore://version2Store/60d3d217-e80b-4066-9e43-6361bb573462",
"name": "prova1.json",
"label": "1.11",
"description": "",
"createdDate": "08 lug 2016 12:21:49 GMT+0200 (CEST)",
"createdDateISO": "2016-07-08T12:21:49.843+02:00",
"creator": {
"userName": "admin",
"firstName": "Administrator",
"lastName": ""
}
},
{
"nodeRef": "versionStore://version2Store/a1b38d5e-2556-416a-908e-180687d3ff8c",
"name": "prova1.json",
"label": "1.10",
"description": "",
"createdDate": "07 lug 2016 13:20:44 GMT+0200 (CEST)",
"createdDateISO": "2016-07-07T13:20:44.804+02:00",
"creator": {
"userName": "admin",
"firstName": "Administrator",
"lastName": ""
}
}]
Using google-scholar and R, I'd like to find out who is citing a particular paper.
The existing packages (like scholar) are oriented towards H-index analyses: statistics on a researcher.
I want to give a target-paper as input. An example url would be:
https://scholar.google.co.uk/scholar?oi=bibs&hl=en&cites=12939847369066114508
Then R should scrape these citations pages (google scholar paginates these) for the paper, returning an array of papers which cite the target (up to 500 or more citations). Then we'd search for keywords in the titles, tabulate journals and citing authors etc.
Any clues as to how to do that? Or is it down to literally scraping each page? (which I can do with copy and paste for one-off operations).
Seems like this should be a generally useful function for things like seeding systematic reviews as well, so someone adding this to a package might well increase their H :-)
Although there's is a bunch of available Google's API, a google scholar-based API is not available. So, albeit a web crawler on google scholar pages might not be difficult to develop, I do not know to what extent it might be illegal. Check this.
Alternatively, you could use a third party solution like SerpApi. It's a paid API with a free trial. We handle proxies, solve captchas, and parse all rich structured data for you.
Example python code (available in other libraries also):
from serpapi import GoogleSearch
params = {
"api_key": "secret_api_key",
"engine": "google_scholar",
"hl": "en",
"cites": "12939847369066114508"
}
search = GoogleSearch(params)
results = search.get_dict()
Example JSON output:
{
"position": 1,
"title": "Lavaan: An R package for structural equation modeling and more. Version 0.5–12 (BETA)",
"result_id": "HYlMgouq9VcJ",
"type": "Pdf",
"link": "https://users.ugent.be/~yrosseel/lavaan/lavaanIntroduction.pdf",
"snippet": "Abstract In this document, we illustrate the use of lavaan by providing several examples. If you are new to lavaan, this is the first document to read … 3.1 Entering the model syntax as a string literal … 3.2 Reading the model syntax from an external file …",
"publication_info": {
"summary": "Y Rosseel - Journal of statistical software, 2012 - users.ugent.be",
"authors": [
{
"name": "Y Rosseel",
"link": "https://scholar.google.com/citations?user=0R_YqcMAAAAJ&hl=en&oi=sra",
"serpapi_scholar_link": "https://serpapi.com/search.json?author_id=0R_YqcMAAAAJ&engine=google_scholar_author&hl=en",
"author_id": "0R_YqcMAAAAJ"
}
]
},
"resources": [
{
"title": "ugent.be",
"file_format": "PDF",
"link": "https://users.ugent.be/~yrosseel/lavaan/lavaanIntroduction.pdf"
}
],
"inline_links": {
"serpapi_cite_link": "https://serpapi.com/search.json?engine=google_scholar_cite&q=HYlMgouq9VcJ",
"cited_by": {
"total": 10913,
"link": "https://scholar.google.com/scholar?cites=6338159566757071133&as_sdt=2005&sciodt=0,5&hl=en",
"cites_id": "6338159566757071133",
"serpapi_scholar_link": "https://serpapi.com/search.json?as_sdt=2005&cites=6338159566757071133&engine=google_scholar&hl=en"
},
"related_pages_link": "https://scholar.google.com/scholar?q=related:HYlMgouq9VcJ:scholar.google.com/&scioq=&hl=en&as_sdt=2005&sciodt=0,5",
"versions": {
"total": 27,
"link": "https://scholar.google.com/scholar?cluster=6338159566757071133&hl=en&as_sdt=2005&sciodt=0,5",
"cluster_id": "6338159566757071133",
"serpapi_scholar_link": "https://serpapi.com/search.json?as_sdt=2005&cluster=6338159566757071133&engine=google_scholar&hl=en"
},
"cached_page_link": "https://scholar.googleusercontent.com/scholar?q=cache:HYlMgouq9VcJ:scholar.google.com/&hl=en&as_sdt=2005&sciodt=0,5"
}
},
...
Check out the documentation for more details.
Disclaimer: I work at SerpApi.
i have created site ,name as testing under that created folder test.I am uploading images under test1 as sub folder under test by using rest API.i can get noderef of site by using url http://localhost:8081/alfresco/service/api/sites/testing
it give result like this
{
"url": "/alfresco/service/api/sites/testing",
"sitePreset": "site-dashboard",
"shortName": "testing",
"title": "Sample: Web Site Design Project",
"description": "This is a Sample Alfresco Team site.",
"node": "/alfresco/service/api/node/workspace/SpacesStore/b4cff62a-664d-4d45-9302-98723eac1319",
"tagScope": "/alfresco/service/api/tagscopes/workspace/SpacesStore/b4cff62a-664d-4d45-9302-98723eac1319",
"siteManagers":
[
"admin",
"mjackson"
],
"isPublic": true,
"visibility": "PUBLIC"
}
but i tried to get children of this by giving url
http://localhost:8081/alfresco/service/api/node/workspace/SpacesStore/b4cff62a-664d-4d45-9302-98723eac1319/children
it give 404 error please help this.I am using REST API