how to embed a github git README file on a website - javascript

I am making a website for someone and they want to be able to have that site fetch the github readme markdown file at a certain URL and display it on the website, so that instead of having to write the readme in two places, it just pulls from github. Is that possible? How do I do it? I saw this:
https://github.com/coreyti/showdown
which turns markdown into html, but I'm still not how I would fetch the readme URL and convert it into an object that showdown could parse.
Any ideas would be greatly appreciated.

You can use StackEdit. It allows you to publish your markdown document on Github and on others locations at the same time in Markdown or HTML format. For instance, you could publish the HTML on a public Google Drive or Dropbox location.
NOTE: I'm the developer of StackEdit

GitHub has an option to show file source, Raw button in top right corner. Raw link for your example is: https://raw.github.com/coreyti/showdown/master/README.md
Assuming that README file is formatted in Markdown already, you could just fetch source and format it on your side, libraries most probably already exist for your language.
UPDATE
I wouldn't actually download file from GitHub every time the page on your site is requested. GitHub may be down, connection may be slow -- and this will affect visitors of your site. Instead, you may want to have a cron job running on the server that would download a file from GitHub, say, every five minutes, and cache it locally. Then, every time you need to display the file, you'll read a local copy and don't depend on GitHub server being accessible. As a drawback, you will have a certain synchronization delay (5 minutes in my example).

Heroku seems to be doing it by copying the rendered html https://elements.heroku.com/buildpacks/stouffi/heroku-i18n-js-buildpack-ruby#buildpack-instructions

I’ve written riss.awk to insert a README.md on your website, optionally performing some transformations in the process.
be able to have that site fetch the github readme
You can automatically fetch the original README.md file like this:
curl https://raw.githubusercontent.com/cljoly/readme-in-static-site/main/README.md | awk -f riss.awk >readme-in-static-site.md
convert it into an object that showdown could parse
I couldn’t find showdown’s documentation, but there might be some kind of API you could use to upload the file generated above (readme-in-static-site.md)? A cronjob-like task could then run this process every few hours to keep things up to date.

Related

Uploading a file from client to server in python bokeh

We have set up a bokeh server in our institute, which works properly. We also have a python-based code to analyse fMRI data which at the moment uses matplotlib to plot and save. But I want to transfer the code to bokeh server and allow everybody to upload files into the server from the client and when the analysis is done in the server, save the output plots in their local HDD. This transfer file procedure seems to be lacking in bokeh atm. I saw a new feature recently added in github to upload json files, but my problem is fMRI files come in various formats, and asking (not necessarily tech-savvy) users to convert the files into a certain format beats the purpose. Also, I do not know any JS or the like, hence I do not know what solutions people usually use for such web-based applications.
If anybody has any solutions to get around this issue, it'd be happy to hear it. Even if it is a solution independent of bokeh (which would mean users need to open a separate page to upload the files, a page to run the analysis, and a page to save the output) please let me know. It won't be ideal, but at least better than no solution, which is the case in bokeh right now. Thanks!
I'm not sure where you are getting your information. The FileInput widget added in Bokeh 1.3.0 can upload any file the user chooses, not just JSON.

Is there an npm module to modify a pdf file in node.js?

I'm building a node.js app on Bluemix that should take a pdf file as request and then grey out (blank) some part of the pdf file. And also here the pdf file is the same for all, and the area we need to blank out will be fixed. So can anybody suggest an npm module that can perform this kind of functionality?
Yes I guess the most common used library is pdf-lib. Take a look at the official page.
I suggest you to try HummusPDF. Specifically take a look at the Hummus - Modification page, that explains how to edit existing PDF documents. In your case you could try to use the feature that allows to draw shapes.
Please try Aspose.PDF Cloud SDK for Node.js available at GitHub and npm. It provides API methods for a wide range of document processing operations; including creation, manipulation, conversion and rendering of Pdf documents in the cloud. You can use Redaction Annotation to grey out the required PDF area.
P.S: I work with Aspose as Support Developer

How to use PDF.js to load file included in web app (not from "file:" URL?

I want to be able to show PDF files within my Chrome app using PDF.js but the documentation is non-existent. I've been unable to find any simple examples or tutorials that show the code to load a PDF from a relative URL, show the page, and navigate through the PDF. They have very complex examples where 95% of the code does other things and it's very difficult to parse these and find the relevant functions. I would like to:
Include the relevant code in my app (is this the "pdf.js" created by "node make generic" and nothing else? Or do i need to include other JS files as well?)
Be able to show PDF files that are inside my myapp.crx file
Does pdf.js require "LocalStorage"? Will localStorage continue to be allowed in Chrome extensions/apps or is it deprecated?
Can someone tell me if #2 is possible and how to find some example code or documentation on the proper classes/functions to call and files to include/build?
node make generic outputs to the build/generic directory. This directory contains two subdirectories, "build" and "web".
"build" contains "pdf.js", which is the actual PDF engine.
"web" contains a viewer, similar to the one at http://mozilla.github.io/pdf.js/web/viewer.html.
After copying both of those previous directories to your app, you should be able to load the PDF file using chrome.extensi/web/viewer.html?file=path%2Fto%3Ffile.pdf
PDF.js does not require localStorage.It's used if available for persisting settings such as scroll position, but if unavailable, PDF.just continues to work without it.
There is one significant issue though: PDF.js loads the localization files using synchronous XMLHttpRequest. This is not allowed in a Chrome app. You could solve this issue by serializing all files in the locales, put it in a single JavaScript file, load this in viewer.html, and simplify l10n.js to read the translations from the file I just described.
Just to clarify: normally you should be able to access a file baked into your CRX by providing a relative or absolute path to it within the CRX's internal directory structure, e.g.:
'myfiles/pdfs/example.pdf'
With PDF.js, I guess that's what "path-to-file.pdf" should be in Rob's answer above, verbatim.

Parse Microsoft Office files in Node.JS

I'm working on a web application where users can upload Microsoft Office Document files. Right now, our server is running Node.JS with Express.js and we're hosted on Heroku. Because of this, I don't think that I can install programs such as abiword or catdoc. I can handle the file uploads, but can't parse the contents of the document.
How can I read the contents of the doc file? The information will then be put into a database. It'd be nice to preserve basic formatting (bold, italic, underline), but not essential.
While there don't seem to be anything you can get with NPM that will do Word directly, you might be able to use a REST API to request it via another cloud service. For example Saaspose (they of the famous Aspose tools) have public API for Word, Excel, PDF, and others. They list node.js, javascript, and Heroku support on their page.
EDIT:
I see that Saaspose is now called Aspose for Cloud
Another API that claims something similar is Doxument
Office package: npm install office seems to provide at least part of the answer. I use it to read Excel files, so far have not tried any Word docs.
There doesn't seem to be any yet. See below for something that might help.
Can I read PDF or Word Docs with Node.js?
You can use mammoth to parse .docx files https://www.npmjs.com/package/mammoth
and xlsx to parse .xlsx files https://github.com/SheetJS/js-xlsx

Client-only Dropbox access

I am trying to write an utility that logs into the user's Dropbox account and displays the files there (with some additional formatting, etc) in a browser. I would like to do this with only client-side technologies without any server-side code. Is this possible?
I found this: http://code.google.com/p/dropbox-js/ - haven't tried it yet. It doesn't have much documentation on how to get started. Any other alternatives?
The Chooser API will not allow you to apply custom formatting to files.
If you want to display the user's entire Dropbox, create an application with Full Dropbox access, and use dropbox.js to read the user's Dropbox.
This walks you through setting up your application: https://github.com/dropbox/dropbox-js/blob/master/doc/getting_started.md
This particular snippet (List a Directory's Contents) is most relevant to you: https://github.com/dropbox/dropbox-js/blob/master/doc/getting_started.md#list-a-directorys-contents
readdir documentation: http://coffeedoc.info/github/dropbox/dropbox-js/master/classes/Dropbox/Client.html#readdir-instance
The checkbox.js sample application uses readdir here: https://github.com/dropbox/dropbox-js/blob/master/samples/checkbox.js/public/checkbox.coffee#L135
If you run into roadblocks, open an issue on the dropbox.js GitHub page.
Check this out:
https://www.dropbox.com/developers/chooser
They have a specialised file for this. Try the demo and start using.

Categories