Is it possible to make a template with no ContentType to fetch arbitrary data in Bolt CMS? - bolt-cms

I'm in the process of building an education site, with Departments, Courses, and Modules (all working out fine so far).
I need to make a custom Timetable page that will fetch all Modules of all Courses and plot them into a weekly calendar.
I've setup a menu entry for /calendar and made a calendar.twig template, but since there is no ContentType called Calendar the template cannot be found.
Making a ContentType for Calendar doesn't really make sense since the Calendar will be fetching and displaying Modules and Courses, for which there are already working templates.
Is there a way to setup a menu option / route to a template with no specific pre-fetched content, allowing me to just pull in everything I need via twig 'setcontent' to build my calendar? Or does this go against the grain of Bolt?

Turns out there is support for exactly this (in Bolt 3.0) just putting the answer here in case it helps anyone else.
I added this to my routing.yml and it now works as expected, allowing me to fetch any content via twig:
templatebinding:
path: /calendar
defaults:
_controller: controller.frontend:template
template: calendar

Related

Convert a JSON Response to pdf - NodeJS

When a get request is sent to: 'http://localhost:4000/features'
There is a response with JSON Data which has HTML inside it.
I need the contents of the field name and description to be saved as PDF
Sample:
[{"_id":"5ad4951d0ba1c37c65818bc7","name":"Find your work faster","description":"<p>With an improved <strong>quick search</strong>, searching through all your issues and projects will be nothing else but a breeze. Whether you know the full issue key, part of the issue name, or just have a distant memory of a project from a year ago, start typing the words, and we’ll do the rest for you. The quick search instantly shows the most relevant results, and refreshes them whenever you change your search term.</p>\n\n<p><img alt=\"\" src=\"https://confluence.atlassian.com/jirasoftware/files/945521251/945528523/1/1518181922686/quicksearch.png\" style=\"height:400px; width:800px\" /></p>\n\n<p>If you’ve already found what you were looking for, just treat quick search as a handy work diary. Click anywhere in the box to see the issues and projects you’ve been working on recently, and have the most important work always at your fingertips.</p>\n\n<p>Learn more</p>\n","__v":0},{"_id":"5ad5ddddcd054b2b5b20143c","name":"Project sidebar","description":"<p>The project sidebar that we previewed in JIRA 6.4 is here to stay. We built this new navigation experience to make it easier for you to find what you need in your projects. It's even better, if you are using JIRA Agile: your backlog, sprints, and reports are now just a click away. If you've used the sidebar with JIRA Agile before, you'll notice that cross-project boards, which include multiple projects, now have a project sidebar as well — albeit a simpler version.</p>\n","__v":0}]
Can this be done in nodeJS?
Conversion isn't the right word but generation is. According to the generalized response in json response you can write logic for generation of pdf from it in node-js server.
PDFKit and PDFmake are two good libraries for this purpose.
I've used pdfmake and is very good.
See doc here: https://pdfmake.github.io/docs/
Use html-pdf to generated PDF from html, Where it works on top of phantom
var pdf = require('html-pdf');
pdf.create(file[0].description).toFile('./' + file[0].description + '.pdf', function (err, res) {
console.log(res.filename);
});
Note : Sample code snippet above to handle first object in your array

How can I pass a data element that has been bound on one HTML file to another HTML file in an AngularJS app

I am using this statement in the Index.html file to bind the element: Show Products.
I see that is is bound in the Index fie by displaying its value there. But when the products1.html file opens, the bound field does not display. I want to use it in as a placeholder in an input box in products1.html.
I am thinking of re-creating index.html as an SPA, but not sure this will work. if I add products1.html as a template into the view. I expect I might have the same problem.
Yes I am a Angularjs newbie after 2 years of experience.
Assuming that you have different controllers for the two pages, it seems that your problem is that you are not sharing the data between those controllers. Each of the controllers define a scope. It looks like the information that you want to show is well loaded in the "Index.html" controller scope, but then is not passed to the "products1.html" controller. If that is the case, there is several solutions to share data between Angular controllers:
Using services
Using $state.go services
Using stateparams
using rootscope
You can check how to do it in: Share data between AngularJS controllers

Include categories custom fields in REST api

I am working with Advanced custom fields, where I add an image selector for categories in wp - But I can't see the data in my JSON response for categories?
I have tried to use several plugins to do the same, but That haven't worked either -
I am using ACF to rest plugin to include acf fields in the response, which works fine on custom post types - where it creates an array field called "acf"
This field is not created in my categories though - Am i missing a function to use it in taxonomies?
examples.
domain.com/wp-json/wp/v2/recipies (a custom post type)
returns everything including acf.
domain.com/wp-json/v2/categories (a texonomy)
returns all of the categories, but nothing about acf
domain.com/wp-json/wp/v2/categories/37 (a single category)
returns the category but nothing about acf.
domain.com/wp-json/wp/v2/categories/37?_embed[0] (way of getting all embedded stuff)
Does not show acf
Hope that you can put me on the right path.
To anybody who is interested, and runs into this problem.
I talked to the developer of acf-to-rest, and there is a bug in version 2, where it doesn't save taxonomies correctly - It is fixed in version 3, but you can't update it yet through wordpress, since it is still in beta -
Redownload the plugin and go into your wp-config file
here you need to define that you are going to use version 3. paste this line into the wp-config file
define('ACF_TO_REST_API_REQUEST_VERSION', 3);
The endpoints has been rewritten, so you also need to read up on that if you are using the acf endpoints for updating etc.
To read more about the bug, go github page
To read about the end points - go here
I hope that this will help somebody in the future.

Onenote does not return pages

This is similar question as OneNote pages API doesn't return pages in section-groups.
I'm using the Get sections and get Section pages with Sections expanded to get names for all pages in a notebook. However using the same requests all the time, the sections in section groups sometimes disappears, and wont reappear before recreating the group.
Is this a bug that one can somehow work around, or is there a better way of polling all the page names from a specific notebook? The pages need to be in order.
If you are trying to get all the page names for a Notebook, a work-around exists by using an OData nested filter. The idea is to query for all pages, $expand the parentNotebook, and then $filter on the id of the parentNotebook. Here is an example URL.
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}'
Here is another SO question where someone employs a similar pattern: Best way to use One Note API to GET specific pages in specific section in specific notebook?
Update:
You can control the order of the returned pages by using OData's $orderby and specifying properties that exist on the entities in the returned entity set (in this case, the entity is pages). From dev.onenote.com: "The default [order] is lastModifiedTime desc (most recently modified page first)."
Under https://dev.onenote.com/docs#/reference/get-pages there is a section, "Page properties", that shows all the properties returned by this call. Since we are getting all the pages available to a user that exist in a notebook, the only property we can use is unfortunately createdTime.
The query param to add looks like $orderby=createdTime
In full:
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}&$orderby=createdTime
I just tested this using Fiddler against my own pages so I think it should work. The nice thing is that it is a single request.
GET https://www.onenote.com/api/v1.0/me/notes/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$YOUR_NOTEBOOK_ID_HERE}'&$orderby=createdTime

Multiple Shiny apps using the ui to populate the second app

I currently have a app that manages projects. The user sees a list of projects and can select one. They can should (it would be nice) be able to click a run button and have another app open. The parameters stored in the project they selected are populated into the second application. The issue I am having is firing the second application. runApp generates the following.
ui code line:
actionButton("RunProj", "Run"),
Warning in run(timeoutMs) :
Unhandled error in observer: Key / already in use
observeEvent(input$RunProj)
I would like to trigger the second app and pass in the location of the project directory I have looked at parseQueryString and still trying to figure out a way to include that. Maybe via a redirect?
Any suggests would be much appreciated.
Regards,
Rich
I'm not 100% sure if I understand your intention correctly but here is a few things I think you may want to think about.
In one project, if you want to run a few kinds of analyses, you may want to try navbarPage
If there are many different types of analyses, you may want to try shinydashboard
If you know the link to each app and you really want to add those "run" buttons, you can add a button manually in ui.R. I think you can write some codes in server.r to generate the link based on your database.
tags$a(href="the link to your apps", class= "btn btn-default", "Run App")