I have multiple JSON files being looped over and populating a single template as seen in this question: Using Assemble, generate HTML files from multiple data files using one template file?
Each one of my JSON files has a title and description - how can I load these into the template (generally done with YFM) so that each generated HTML file has a unique title and description?
In assemble v0.4.x when you pass in the pages as a data object (like you're doing), only the data object is used. The data parsed out of the page content is not used.
Try updating your code to add the properties to data instead of concating the template:
// read in the data file
var data = grunt.file.readJSON(filepath);
data.title = data.project.projectTitle;
data.description = data.project.meata.description;
This is fixed in v0.6.x
Turns out that it's not important for the projectTemplate to have the YFM injected up top. To get it to show up, I just modified the data object with the title and description.
In essence, this gist https://gist.github.com/patrickng/c138c4ac8e6891fecbfc becomes https://gist.github.com/patrickng/5d36eb9ada2d353ff98e
Related
How can I retain HTML form field values in JSP after submitting form to Servlet?
I am trying to retain a csv file in the jsp but it looks not possible. I also tried to pass the csv file back to the jsp and send it as a part of form back to the controller but not able to do it. so please suggest a way to retain the csv file or redirect it back to the jsp and be able to use the second time the page reloads
I have done some research and came to a conclusion that it is not possible to retain an input field of type csv file. Please correct me if I am wrong
Answer: As per my knowledge it is not possible as suggested in this https://stackoverflow.com/questions/2598904/how-do-i-keep-form-data-after-submitting-the-form-using-javascript#:~:text=To%20keep%20the%20values%2C%20you,request%20parameters%20into%20the%20fields.&text=You%20can%20use%20cookies%20from,you%20access%20something%20called%20document. answer once the form is submitted the entire page is replaced by response from the server so to retain the csv file values I think we can only use an jQuery.post or jQuery.ajax to send the form data rather than actually submitting the form
If you want to retain any thing that was passed from a jsp and use it in back end, you can do one thing . once passed to the controller, we can read the data of the csv file and set that object in the session using .setAttribute("object name", object). The session object can be fetched and set an object using the following lines of code
HttpSession session = request.getSession();
session.removeAttribute("<object name>");
session.setAttribute("<object name>", object);
and use this object the second time the control moves from jsp to controller by using the getAttribute()
<className> <objectName> = session.getAttribute("<object name>");
and use it as needed.
In a Plone's File content type, which property stores the file's original filename?
I'm using plone.jsonapi.routes to upload files to a plone instance. I can set the id ant the title but I can't set the associated file's filename.
For example, when I upload a file to Plone in the regular way, I can set its id and title, but additionally to that, the original file name is stored somewhere. You can see it here:
objects-essay.pdf - PDF document indicates the name the original file has.
But when I upload it with plone.jsonapi.routes that field is empty. So, I'm trying to figure it out which property stores the name to pass it to the api or to set it by hand.
Thanks.
IIRC, all Archetypes-based content types have a setFilename method that you can use to do this.
On Dexterity-based content types file's content is stored in blobs in the ZODB (instances of NamedBlobFile) and there's a parameter named filename that you can use to set it.
You can see an example of the later in plone.app.contenttypes.
I am trying to pass the variables from one page to another in Drupal 7. Since in Drupal 7 we do not create the php file as such the content of the page gets saved as a plain text in DB, no files get created, so GET/POST are out of the solution.
How can I do this?
Content is saved in database, but every content is defined in some content type. And for every content type you can have different template file. Inside that template file you can put your php code reading GET/POST, or what ever.
So, you can use the usual way and read parameters from template, do what ever you want with them.
One way is to use variable_set() to save the value to database and variable_get() to retrieve the value from database.
To save the value:
variable_set('my_variable_unique_id', 'the value to be saved.');
To read the value back:
$myVariable = variable_get('my_variable_unique_id', 'default value in case could not find a saved value for the variable.');
I am using Ext.js4 and Java servlets. When the user clicks a button on a panel, I execute a Servlet which in turn executes another application, which produces a log file in .txt format. I know the servlet and the other application are being executed. I want the servlet to return the contents of the .txt file, which Ext.js should in turn display as straight text on a separate "Log" tab. Do I need a store and model for something like this? Note that the data returned by the servlet is just text, not JSON or HTML, and special characters (which would preclude the use of JSON or HTML) may be included in that text. Thanks in advance.
No, you don't need a store and model for this.
I would write a servlet that simply returns the contents of the .txt file.
Then use the Ext.Ajax class to create a request to this servlet and save the text as a variable.
Then you can just do: logTab.update(theText) to fill your tab with the contents of the .txt file (where logTab is your tab you want updated).
For example:
Ext.Ajax.request({
url: '../textServlet',
success: function(response){
var theText = response.responseText;
logTab.update(theText); // or however you define your tab
}
});
I would like to generate an image using text and a custom font.
As it is mentioned here Output text as GIF or PNG for use in eBook
How can I store the file in my content's file field?
All you need to do is call the field accessor with a file-like object, preferably one that includes the file mime-type (image/png or image/gif in your case). Zope's OFS.File.File provides such info. Let's say your file field is simply called file (so it's setter is called setFile) and you have your image in a string variable named imagedata containing a PNG image:
from OFS.Image import File
image = File('ignored-id', 'ignored-title', imagedata, 'image/png')
contentobject.setFile(image)
Note that you may want to change your field to type ImageField though; it provides a richer interface for images, including HTML tag generation and scaling.
Get the python file-like object corresponding to the image and pass it as an argument to the field mutator method. If the field if called fooImage, then the mutator, by default, is object.setFooImage(image_file_here). Or you could pass it in using the object.update(fooImage=image_file_here) method.