Changing html content for local application only - html

I want to organize my notes (on scientific articles).
I want to be able save text and images notes for each article
Save the pdf file
Organize it into a hierarchy with a document somewhere with a content table containing the hierarchy of thematics and link to all articles
I want to be able to move fast between articles (open note on an article fast)
Add tags to filter the articles
Add an importance level to filter articles
There is many softawre for that kind of thing but it's often difficult to combine pdf file and notes containing text and images and hierarchy and tags
And they are often not really customizable.
The best solution I can think of is to use html files to put the article contents, and other html files with links to the articles pages.
I currently use a python script that I call from command line with pdf download link and article name as argument
The script creates an empty html page for the article at the good place in the hierarchy, add link in the table of content html page, and the article link with his tags in a seperate file
What I would like to do is to have a button in my table of content html page which would allow me to add an article and so add and modify some files.
t's seems that a very specific case because I'm using web like technologies only to organize local files.
But I don't know how to do that and I don't know where to look. Could it be done with javascript or php ? Or may be use something like python dash to display the html page and run some python script in the background
Sorry for my english I'm not a native speaker

I found some app on github that did almost what I want: trilium and pervane
But I didn't use them because they were to complicated for me to customize them to add new functionalities
I finally find a solution by using flask to render my local notes that are stores as html.

Related

Is it possible to add notes to an rmarkdown html document AFTER knitting?

I am knitting a html markdown file for a customer with plenty of interactive visualizations inside it.
My client - not a tech user - would like to add their own comments, conclusions to the document, and using it for a presentation.
Is it possible to add a text box to an rmarkdown html document that can be edited and saved by a non-technical user?
What alternatives I have to keep the document interactive but editable after knitting?
I would like to avoid the case that the customer just copies screenshots from my html and pastes into a ppt.
As per my personal experience, I think you can add text commenting feature on the Rmd by uploading it to a Github page. You may follow this guidance on how to do so:
https://www.smaranyadey.com/post/creating-r-markdown-documents-and-publishing-them-using-github-pages
After the Github page set up, you can add widget like Hypothes.is which enable your client to annotate as well as highlight some texts.
You can make the Github page private so only your client can access your Rmd.
UPDATE:
Gosh, I just foud very simpler way to embed the Hypothesis script to the HTML output without the need for uploading to Github Page.
Just put this code under YAML:
---
<script src="https://hypothes.is/embed.js" async></script>
This update refers to an answer from this

confusion about files end with .thtml and what exactly are they

I was going over my company's code base, and I saw some file format I have never seen before. They are all ended with .thtml .
What exactly is the .thtml? I was told it is for template files, and every time I view it in vscode I need to choose a language at bottom right corner of the IDE (default was plain text). What is the use of template file in web development? Are they the substitutes of .html files?
HTML templates are HTML files enriched with variables, macros or other logic. They need to be preprocessed to ordinary HTML files before they can be viewed in a broswer. HTML templates are very useful when you want to create a lot of static HTML files sharing the same structure but with different contents.
There are several HTML templating engines out there, of which one happens to be named exactly thtml. (Of course this does not guarantee that it is the one your company uses.)

Using an HTML template across multiple subdirectories

I run a website for my photography where I have a stories page (http://www.traumantic.com/stories.htm) that is a long list of choices that lead to a sub folder and a gallery of images for that session.
I have an index.htm file in each of those folders that displays the gallery chosen.
I am trying to develop a new format for my pages, and putting it in place means replacing dozens of index.htm files and editing each one for that new format. A boatload of work.
I have noted that a lot of news sites seems to have a method of using a single template for the main body of the page and the elements of the news story are pulled in from another source.
I figured I could do this with XML like I did with my galleries, but I am lost.
I tried creating an XML file in a couple of text folders and then reading that form an HTM file two levels up. Didn't work.
Currently when you click on a link on my stories page, it opens the index.htm file in a sub-folder.
What I want to happen is this.
Clicking on a choice on my stories page launches an html template that reads the details from the folder.
The one html template would be used for all of the different story folders below. Making it far easier to modify the look of my web site quickly.
I'd rather put a ton a of work into designing this system that doing a mass replace and edit project on hundreds of files.
I hope this makes sense to some of you and that you can guide me to some study topics that will help me learn how to do this.
I am seeking advice on places where I can see example of this process.
The simplest option is to use an iframe
https://www.w3schools.com/tags/tag_iframe.asp
<iframe src="/path/to/file.html"></iframe>
Searching "html include" will yield a few guides that have various JavaScript implementations. (e.g., https://www.w3schools.com/howto/howto_html_include.asp)
If you're able to run php, you could use include
https://www.w3schools.com/php/php_includes.asp
But at that point, you might want to consider installing some sort of template engine like twig https://twig.symfony.com/doc/2.x/intro.html

live content from html to html

I'm using UIWebView to display data from my organization data (publicize and legal), however, for instance, I would only want to pull specific data from the html file rather than pulling the whole URL. e.g. I want to pull the "News" section of the html and I want the user to only stay in that page, not enabling them to go into other parts of the website (e.g. home page, contact us) and allowing them to view the PDF article on the HTML file.
I've asked around and read up on DOM and screen scraping, but it seem that the data pulled are stored in a database instead.
Is there any way that I can pull just the HTML "News" section with the PDF URL into my customized HTML file and that it will be updated live (maybe every 30second it will refresh and pull information from the website so that the content and list of PDF are up to date)(e.g. added in 3new article into the main website, my customize HTML file will also refresh and pull information from website and update my article list)
If anyone can point to me a specific method that allow HTML to HTML data passing (live), that will be great and I can go do more research on it. Currently very lost and confuse as it is my first time doing this. Any help/feedback will be very much appreciated :)
EDIT: For example, google map or google search. I don't want to use the whole google webpage, just taking the important thing that i want like the search result or map display.
This will involve quite a lot of learning on your part - you'll have to learn HTML / the DOM / JavaScript and iOS/UIWebVIew.
Lets leave the live refresh part for now, I'll post another answer or edit to that later on.
That's not going to easy either (check out my earlier posting today on background execution issues that will affect you, unless the update is only to take place in the foreground
iOS Run Code Once a Day)
You will have to do something like this. And note that I've never tried this, nor seen posting of people who have on here, but in theory it should work, but there will be a lot of learning as I've said, and lots of trial and error. Its a big task when you're not familiar with these things.
1) Download the html page and load it in a UIWebView, but that UIWebView is hidden so the user's can't see it.
2) When the page has loaded its dom will be accessable.
3) You can use Javascript to access the DOM and look for the parts you want.
How you inject and run the Javascript in UIWebView can be answered in a separate question (this answer will get too long if all the exact details are included).
4) Remove the parts of the dom you are not interested in. Or use use events to make only those parts you are interested in appear, jQuery can probably help here.
5) Display the UIWebView
Alternatively the HTML could be saved to a file and string parsing could be used to search for the bits you are looking for and create a new text html file from it. I think this would get very messy, better to take advantage of the fact that UIWebView will parse the HTML page and create the dom for you.

How should I handle autolinking in wiki page content?

What I mean by autolinking is the process by which wiki links inlined in page content are generated into either a hyperlink to the page (if it does exist) or a create link (if the page doesn't exist).
With the parser I am using, this is a two step process - first, the page content is parsed and all of the links to wiki pages from the source markup are extracted. Then, I feed an array of the existing pages back to the parser, before the final HTML markup is generated.
What is the best way to handle this process? It seems as if I need to keep a cached list of every single page on the site, rather than having to extract the index of page titles each time. Or is it better to check each link separately to see if it exists? This might result in a lot of database lookups if the list wasn't cached. Would this still be viable for a larger wiki site with thousands of pages?
In my own wiki I check all the links (without caching), but my wiki is only used by a few people internally. You should benchmark stuff like this.
In my own wiki system my caching system is pretty simple - when the page is updated it checks links to make sure they are valid and applies the correct formatting/location for those that aren't. The cached page is saved as a HTML page in my cache root.
Pages that are marked as 'not created' during the page update are inserted into the a table of the database that holds the page and then a csv of pages that link to it.
When someone creates that page it initiates a scan to look through each linking page and re-caches the linking page with the correct link and formatting.
If you weren't interested in highlighting non-created pages however you could just have a checker to see if the page is created when you attempt to access it - and if not redirect to the creation page. Then just link to pages as normal in other articles.
I tried to do this once and it was a nightmare! My solution was a nasty loop in a SQL procedure, and I don't recommend it.
One thing that gave me trouble was deciding what link to use on a multi-word phrase. Say you had some text saying "I am using Stack Overflow" and your wiki had 3 pages called "stack", "overflow" and "stack overflow"....which part of your phrase gets linked to where? It will happen!
My idea would be to query the titles like SELECT title FROM articles and simply check if each wikilink is in that array of strings. If it is you link to the page, if not, you link to the create page.
In a personal project I made with Sinatra (link text) after I run the content through Markdown, I do a gsub to replace wiki words and other things (like [[Here is my link]] and whatnot) with proper links, on each checking if the page exists and linking to create or view depending.
It's not the best, but I didn't build this app with caching/speed in mind. It's a low resource simple wiki.
If speed was more important, you could wrap the app in something to cache it. For example, sinatra can be wrapped with the Rack caching.
Based on my experience developing Juli, which is an offline personal wiki with autolink, generating static HTML approach may fix your issue.
As you think, it takes long time to generate autolinked Wiki page. However, in generating static HTML situation, regenerating autolinked Wiki page happens only when a wikipage is newly added or deleted (in other words, it doesn't happen when updating wikipage) and the 'regenerating' can be done in background so that usually I don't matter how it take long time. User will see only the generated static HTML.