Is it possible to save file locations in Visual Studio Code to navigate between folders? - file

I have a Visual Studio Code project with lots of files in lots of subfolders. As I am working on my code I need to navigate back and forth through all of these different (sub-)locations which is very tedious. Is there a way to save links to files to quickly access them?

With the extension HTML Related Links you can create a file with relative paths to files and have a Related Links View in the Explorer bar. This View can be locked to the file with the links.
Create a file in the workspace root: filelinks.txt
file: subdir1/file1.py
file: subdir1/file2.py
file: subdir2/file3.json
file: subdir2/file4.xml
You can add line numbers at the end of the filepath: #123
Add the following setting:
"html-related-links.include": {
"plaintext": [
{ "find": "file:\\s+((?!.*?#).+?)" },
{ "find": "file:\\s+((?=.*?#).+?)#(\\d+)", "lineNr": "$2" }
]
}
When you view the file filelinks.txt, press the lock button in the Related Links View
When you add or remove files the view is updated.
You can close the editor for filelinks.txt when you have locked the file. When you want to change the list open filelinks.txt again.

Related

Where to save user uploaded images in CodeIgniter?

What I want to do is let a user save an image and when they're accessing their accounts I want the image to display.
What I'm currently doing is I'm saving the images in public folder
Store the path to the database
Path: css\img\myPic.jpg
Display the image
<img class="border" src='esc($empInfo['img'])' style="height: 200px; width: 200px">
But since this is a public folder I can't save personal pictures in this folder
I also tried saving the path to writable\uploads\myPic.jpg but no luck
If you look for a manual or a concept , you can also try this:
You must have some folder where you store all personal images
When user needs it, copy the file into Public folder with a random generated 32 character name (GUID type) but with the original extension.
Then feed it to the user in the view.
Once displayed after the view is called you can delete the image from that folder.
As of the the moment. the solution that I got is "copying" the file(in my case it is an image file)from writable/uploads to public using Publish Library.
$publisher = new Publisher(WRITEPATH . 'uploads', FCPATH. 'img/');
$publisher->addPaths([
'img/myPic.jpg',
]);
$publisher->copy(true); // `true` to enable overwrite
Source Path: WRITEPATH . 'uploads'
Destination Path: FCPATH. 'img/'
Source File: img/myPic.jpg
Now you can ref the image in img tags.
Next step should be replacing/deleting the image after use, because this is not gonna be different when you upload the image at public folder. Will try to update if I found a solution
Source: https://codeigniter.com/user_guide/libraries/publisher.html
PS. Feel free to correct me :) I am also new to web developing in general
Part2: I added this to my function. what it does is after copying the image to the public folder I then rename to 'myPic.jpg'. this will solve my previous problem "replacing/deleting the image after use".
$renameFile = rename(FCPATH. 'img/'.$fileName, FCPATH . 'img/'. 'myPic.jpg');
if($renameFile){
return true;
}
else{
return false;
}

Is there a way to rename automatically generated routes JSON file in Next.js?

I have a problem, when I click to go to the /analytics page on my site, adblockers block the analytics.json file that's being requested by Next.js as they think it's an analytics tracker (it's not, it's a page listing analytics products).
Is there a way to rename the route files Next.js uses when navigating to server-side rendered pages on the client-side?
I want to either obfuscate the names so they're not machine readable, or have a way to rename them all.
Any help appreciated.
With thanks to #gaston-flores I've managed to get something working.
In my instance /analytics is a dynamic page for a category, so I moved my pages/[category]/index.tsx file to pages/[category]/category.tsx and added the following rewrite:
// next.config.js
module.exports = {
async rewrites() {
return [
{
source: "/:category",
destination: "/:category/category",
},
];
},
};
This now gets the category.json file rather than analytics.json, which passes the adblockers checks and renders as expected.
Note that due to having a dynamic file name in the pages/[category] directory (pages/[category]/[product].tsx), I had to move that to pages/[category]/product/[product].tsx as I was seeing the /analytics page redirected to /analytics/category for some reason without this tweak.

Extension manifest content scripts matches local files

I would like to know if it is possible to add a content script file to a local extension file named for example "test.html", I tried the following but I can not get it to work :
"content_scripts": [
{
"matches": ["popup/test.html"],
"all_frames":true,
"js": ["js/content_script_test.js"]
}
]
I am trying to do this because I would like to be able to use Message Passing from my background script.
You don't need a content script for this, APIs like browser.runtime.sendMessage() and browser.runtime.onMessage.addListener() are available in extension pages, including popups.

The file download folder view in Struts 2

I'm creating a project of a school. I want to show the uploaded stuff by teachers to students.
But I also need to save the file in the folder which is named as faculty name. Student will be able to browse the main directory and after that he can go in the particular faculties folder.
How can I do it? Any suggestions will be appreciated.
For file upload I would start with example like in this answer. Moving files from temporary folder could be easily done by the file uploading action.
For browsing files in your case I would create an action that is able to navigate to the folder where the files are and get a list of files from that folder. Something like this
String file = application.getRealPath("/upload");
File f = new File(file);
String [] fileNames = f.list();
File [] fileObjects= f.listFiles();
for (int i = 0; i < fileObjects.length; i++) {
if(!fileObjects[i].isDirectory()){
String fname = file+fileNames[i];
out.println(fileNames[i]);
}
}
Then map this files to the JSP as links. When that link is clicked you can retrieve the actual path on the server when action is executed. What to do with the data, of course you can return stream result from the action that is used for streaming to the client browser. You can use docs examples from the Struts site or like in this example.
To navigate to the folder use parameters in GET request, that will be used to store current directory in session. You can change it if a user change the current directory from the view layer.

Detecting if the user downloaded a file or not

I want to detect if the user has clicked on the download or the view hyperlinks. It's a page where people can upload files and if needed they can look at files too(files uploaded by anyone). I am uploading the files using asp.NET and storing it in the sql server database. These files are then displayed on the webpage using the database and can be seen by anyone who logs in. There are multiple files on the webpage and all have view or download links(files like zip files don't have view). I want to create a functionality that allows the user who uploaded the files to see who saw his/her file. Something like a table column for the file name and everyone watching the file getting added to the column in the database.
This is what I am using in the gridview:
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DownloadFile.aspx?Id={0}" HeaderText="Download" Text="Download" />
You just need to have your download/view/links/whatever go to a server-side component which records the click in a database before serving the file.
in the HTML part use this for the button code:
<button type="button" onClick="check_download();"> Click Me </button>
and on the script part add this function
var downloaded = false;
function check_download() {
if (downloaded == true ) {
alert('You have already downloaded this file.');
return false;
} else {
downloaded = true;
document.location.href = 'http://Your.File.ToBe.Downloaded.URL';
return true;
}
}

Resources