Adding a simple Href tag on Razor Page to download a .pdf file - href

This works in my C# .NET Web form. It is a simple link to a .pdf file and it either opens it or prompts for location to download it. I have about 8 of this links for various documents. This has been working for years.
Evaluation Procedure for New and Renewal Courses
But in my new .NET Core 2.2 Razor Pages application I am migrating the application to I can't figure out how to make this simple link. No matter how I make the link I get this error:
This localhost page can’t be found No webpage was found for the web address: http://localhost:xxxx/docs/evaluationprocedure.pdf
The pdf is in "Pages/docs/" folder.
I have tried:
Evaluation Procedure for New and Renewal courses
"./docs/evaluationprocedure.pdf"
"~/docs/evaluationprocedure.pdf"
"Pages/docs/evaluationprocedure.pdf"
"~Pages/docs/evaluationprocedure.pdf"
"../docs/evaluationprocedure.pdf"
I have searched pretty extensively and I seem to get mostly answers to the desire to stream a file or dynamically create the file at runtime.

So, right before I went to bed I tried googling the answer again and found this link over on the right that had no accepted answers (it had a zero in the green area in front of the Title/Link.
But I looked and there was an answer with 3 votes but no checkbox! My problem was that only the wwwwroot folder allows static file downloads. But the answer showed how to add code to the configuration in Startup.cs to allow downloads from a new custom folder of one's choosing.
Add a PDF link in a .NET Core project
So I got this link in the wwwroot folder to work:
<a href='#Url.Content("~/evaluationprocedure.pdf")'>Evaluation Procedure for New and Renewal courses</a>
I just copied the file over to wwwroot for initial test.
Now to use the rest of the answer to allow my docs folder to hold static files.

Related

WebKitGtk doesn't load local files

I've tried loading a local html file using webkit_web_view_load_uri() with a file:// URL. However, the webview would display a blank page. To circumvent this, I tried using webkit_web_view_load_html() and it worked correctly.
Now that I'm trying to load some images in the html using the <img> tag, the images aren't loaded (It displays a blank page).
I'm puzzled because I tried before (~ 2 months ago) a similar method and it worked.
Note: I copied the contents of the generated HTML into a file and loaded it with Firefox and it worked as it should (The images are visible), but with another WebKitGtk application I had lying around the images didn't load.
Note: I'm using C++ as the main programming language (I'd prefer having C++ types in the solutions only if possible)
Note: I have set webkit_settings_set_allow_file_access_from_file_urls() and webkit_settings_set_allow_universal_access_from_file_urls() to TRUE
Ok, I've managed to solve this. The solution had NOTHING to do with webkitgtk, which is strange. It seems that the application was trying to download the page instead of loading it. This traces to a faulty MIME type database.
Tl;Dr:
Execute this:
rm ~/.local/share/mime/packages/user-extension-html.xml
update-mime-database ~/.local/share/mime
and use webkit_web_view_load_uri() instead of webkit_web_view_load_html() with a file:// URI
I had the same problem in C. You have to explicitly set file:// as base_uri when you call webkit_web_view_load_html().
See also answer here

"Edit this page" or "View source option" for Jekyll blog post

For my jekyll blog, I'm knitting Rmd to Md for the posts. At somewhere (preferably top), I want to programmatically add a link to view the source page (Rmd) hosted under _sources folder in top level directory.
Similar implementation can be found at https://yihui.org/en/about/ (at the left sidebar- Edit this page option)
Can this be done by some modification in custom knit command?
OR
Some html-include with liquid syntax should be used?
What about this? This has the Github icon, and links to the repo on the github page. Without any reprex, or an example from you, this is the best I can do unless you give more details. Does Jekyll use YAML?
I got this working, so answering my own question
Well in Rmarkdown, we can access the current source file as knitr::current_input().
This can be combined with the url of repository to get the full link to the source file. The best way is to create a new YAML entry as
RmdSource: '_source/`r knitr::current_input()`'
Now to programmatically add the link, either we can use R code with some liquid syntex at the top of the source file OR we can use html-include file inside the current layout file.
I prefer the latter.

Referencing asset in javascript

The Ember CLI guide describes how assets can be referenced in the templates and the CSS - but what is the proper way of referencing an asset (say an image) from my javascript code?
Specifically I am concerned about the asset path getting fingerprinted correctly when building assets for production. It seems like ember-cli is using broccoli-asset-rev for this, but according to its documentation, only <script> tags in the HTML and url() in CSS will be fingerprinted. Is there any way (probably through another broccoli plugin) to get asset paths in the .js files fingerprinted, too?
I placed an image called car.jpeg under public/assets/images and then was able to reference it in my application.js route file as assets/images/car.jpeg
Works great
UPDATE
One picture is worth a thousand words... :)
I found the issue. This works out of the box as expected - it turned out that my asset (image) was not in the right location, so occurrences of it's path in the JS files never got replaced with the fingerprinted version.

Dajaxice: Having trouble getting Dajaxice working

I know, I know, the first thing you are thinking is to check all of the instructions online and on dajaxproject.com
Well I have checked and checked and rerun this installation and I cannot figure out what the problem is. I assume it has something to do with the version of Dajaxice I am using and the version the installation instructions are, but those details are usually missing.
At this point in the process, I have everything setup to accomplish a very simple task. Load a webpage from the IP:8000 (ie 1.2.3.4:8000) and have that page load a simple html form button. Once that button is pressed, the page should then send a mesage (using dajaxice) to the server, and once it returns an alert box will pop up, proving that the dajaxice install is working.
So, I have:
Installed Dajaxice (and dajax for that matter), by getting the zip from here: github [dot] com/jorgebastida/django-dajaxice/
Changed everything in a basic Django project to follow the details in this tutorial: http://django-dajaxice.readthedocs.org/en/latest/installation.html
I have setup all of the details of ajax.py, and index.html to work with this example: django-dajaxice [dot] readthedocs [dot] org/en/latest/quickstart.html
PS Sorry for the "[dot]"s, but being a new registered user they limit you to 2 per post, so I tried to give you the best links clickable.
I am stumped. I have been trying many different things, but the documentation available seems so sporadic. It's gotta be something simple I am messing up, but I cannot seem to find it.
Currently, the "Say Hello!" button shows up on the screen, but nothing happens when you press it. Any ideas?
Here is a link to the zip file of the Django project I am working with here: https://docs.google.com/open?id=0B5rzYk6W5HlrYk9veVRfM3JkTGc
The way I have it all organized, DjangoAjax is just the folder containing the Django project. ajax_prac is the project, and practice is an app. Also you'll see a folder called django_media...that's pretty self explanatory, it just holds all the "media" for my Django projects, including jquery.js and jquery.dajax.core.js
If there are some details that I have smudged in the code, contrary to the installation guide, I apologize. I have been working through so many iterations of this, that it is likely I could've forgotten to change something back when making this post.
Can anyone help?
All the documentation weirdness is probably related with the new release I made yesterday (8 hours ago). Probably you was using an old version of dajaxice reading the new documentation.
I've release django-dajaxice (0.5) and django-dajax (0.9.1), both fully compatible with the last version of Django (1.4.1).
django-dajaxice: http://pypi.python.org/pypi/django-dajaxice
django-dajax: http://pypi.python.org/pypi/django-dajax
For this release I've also rewrite both documentations and hosted them on readthedocs. Also, http://dajaxproject.com code is now opensource so everybody can read the code and see how dajaxice works in production.
django-dajaxice: http://django-dajaxice.readthedocs.org/en/latest/
django-dajax: http://django-dajax.readthedocs.org/en/latest/
example project: https://github.com/jorgebastida/dajaxproject.com
Could you please upgrade to django-dajaxice (0.5) follow the new installation steps (quite similar http://django-dajaxice.readthedocs.org/en/latest/installation.html) and post here any traceback/issue you could have?
Thanks
In your example code ( DjangoAjax / ajax_prac / templatedirectory / practice / index.html):
<input type="button" value="Send message to server!"
onclick="Dajaxice.ajax.sayhello(my_js_callback);">
Should be:
<input type="button" value="Send message to server!"
onclick="Dajaxice.ajax_prac.practice.views.sayhello(my_js_callback);">
I.e. It must reference a Python module that contains your registered Dajaxice view. And according to your sample code, ajax_prac.practice.views exists while ajax.sayhello does not.
Also the Python module must be prefaced with "Dajaxice" (which is probably a significant source of confusion).

Cannot find CFML template for custom tag

I am not a ColdFusion coder. Doing a favor for a friend who ported his CF site from a Windows server to Unix on GoDaddy.
Site is displaying error:
Cannot find CFML template for custom tag jstk. ColdFusion
attempted looking in the tree of installed custom tags but did not
find a custom tag with this name.
The site as I found it has at document root /CustomTags with the jstk.cfm file and a set of files in cf_jstk
My Googling located this:
You must store custom tag pages in any one of the following:
The same directory as the calling page;
The cfusion\CustomTags directory;
A subdirectory of the cfusion\CustomTags directory;
A directory that you specify in the ColdFusion Administrator
So I have:
Tried creating placing /CustomTags in /cfusion/CustomTags
Tried copying /cfusion/CustomTags to above document root
Tried copying jstk.cfm and subfolders into same directory as calling file(index.cfm)
Update: Per GoDaddy support I have also tried adding the following to no effect: <cfmodule template="CustomTags/jstk.cfm">
Can any one give me some tips on this or should I just tell my guy to look for a CF coder?
Thanks!
I don't know how GoDaddy is setup, so as a quick test, please do the following:
Create file test.cfm in the webroot with contents:
<cf_testtag/>
<cfoutput>test</cfoutput><cfabort/>
Create file testtag.cfm in the webroot with contents:
<cfdump var=#ThisTag# />
Then in a browser visit the test.cfm page.
You should get two debug dumps, followed by the 'test'; this will confirm that custom tags in general are working.
If that works move the testtag.cfm to the CustomTags directory, and see if you get the same behaviour or an error.
If this produces an error, for CF8 and above, you can add <cfset This.CustomTagPaths = "/CustomTags" /> inside the Application.cfc file (assuming there is a App cfc and not an Application.cfm) to ensure that directory is checked for tags.
It is possible to convert Application.cfm to Application.cfc - how easy this is depends on how complex the code is in there - might be something you could figure out, or might need an experienced CF dev, it depends.
Depending on the outcome of this, we can attempt to debug why the jstk tag isn't working (unless one of the above solves it).
In an effort to check the simple things before worrying about complex things:
Remember that filenames on *nix systems are case sensitive, but on windows are not.
For example, a windows server will pick up "application.cfm" but a linux server won't. It requires "Application.cfm".
Check to make sure all filenames/paths are the correct case.
Normally, CFML check every custom tags in current directory first, if not found, second is in CFMX8/customtags/.