Laravel composer breaks when moving a view file - view

More of a 'wonder why' than something broken since I can leave files where they currently are.
In my main view, I #include a header view. the header view file resides in the same directory as my main view. I have a composer set up to load an array variable with data when the header view is called. And it works great.
However, if I move my header to a partials folder located in the same directory as the main, and change the #include to point to the new location, when I run the application, it tells me I have an undefined variable in the header file.
I have looked through what code I code find (or more remember where was) and I dont see anything that specifically references paths for the view in the composer.
Is there somewhere I need to look to specifically tell the composers where the view is located?

Related

Laravel refresh page takes up to 4s to load the whole DOM

I'm new with Laravel's framework, so correct me if i'm mistaken.
I have set up some templates with some assets (css and js) in its corresponding folder:
SASS and JS goes inside resources/sass and resources/js respectively, which then gets compiled into public/css and public/js
Views go into resources/views, and then i have set up some routes inside routes/web.php
If you want me to add some more information i can for sure add it.
Image of console network debugging
Please, ignore images time load as I dont care the loading of them cause they load after DOM.
What I'm asking here is: why is every .css file or .js file taking more than a second to load?
Solution found
Seems like xDebug was causing strong loads in my page, commenting it fixed it.

Custom Pagination

I'm following the tutorial here in the docs:
Custom Presenters
But where do I place the Zurb Presenter class in my file system and how do I let Laravel know it exists?
There isn't really a defined place to put the actual file so you usually put it wherever feels the most natural to you. I'd probably create a presenters folder within your app folder and put it in there.
To let Laravel know where it is, there are a couple things you can do.
The first is adding it via composer. In your composer.json file, in the autoload classmap section, simply add your folder app/presenters. Then you will want to open up your command line, navigate to your project's directory, and run the command composer dump-autoload. Now it should automatically be loaded via composer.
The other solution would be to open up global.php in your app/start folder and add another entry in the ClassLoser::addDirectories() entry pointing to your new folder.
app_path().'/presenters',

updating existing site built in dreamweaver, handling DWT file

I have a client that want's me to make a change to her OTHER site. The other site was built using Dreamweaver.
I guess (I don't build using Dreamweaver) the site pages are being controlled by the template file EXCEPT for the content that is specific to the page.
So I need to change the navigation items.
I found a folder called templates and in that folder is the template.dwt file. I tried copying that file to my desktop, then making the change and uploading back to the ftp site. Of course that had no effect on the nav items. My guess is the file on my desktop does not know to update the other pages as it doesn't know where those pages are.
So how do I go about making the changes to the files on the ftp site using the DWT file?
Do I have to download ALL the html files and the DWT files and somehow create a relationship so when I make the change to the DWT file it updates all the pages on my desktop THEN re-upload all those files back to the ftp site?
Thanks
My guess is that you already figured this out, but just to be sure. You're question is right, the DW template works by when the template is modified (in DW) then you can update all the pages that are linked to it.
If you take the template out of DW and just modify and upload that alone, then nothing will happen to the other pages. So yea, if you know a way to create a link between the template and the other files outside of DW, then that is what you need to do. The other option is using DW and modify the template and then update the other pages, which is done in a semi-automatic way. Semi-automatic, meaning that DW gives the option to update the files either once you save the template or you can save the template and update the files later using DW.
And your guess is correct, the template modifies areas that are not specific to a page. Usually, this is done by creating Editable Regions in the template. Those regions are excluded from change when the template is modified.
You have to create a project in DW and put inside all the files that are "linked" with the template. They usually have tags inside that refer to the template.
Make sure that you keep the same file and folder distribution that the original had. If not, you could have a mess with relative links.
Then, with your template also in the project, open and modify it.
When you save the template, DW will ask you for scan and update related files, if you are lucky it will find and update all of them.

Changing Where CKEditor Looks for Images

I am wondering if there is some way to change where CKEditor looks for images. Right now it uses the location of the web page containing the editor as the root directory but I would like to write a javascript function that can change this directory to any arbitrary path passed to the function.
The bigger picture for this is that I'd like to extend the functionality of CKEditor to be able to save the source it creates to whatever location is picked by the user. I've already implemented getting the source and saving it using wxWidgets but am having trouble getting CKEditor to change its working directory so that images can be included from the directory the user picks.
I've tried using some of the properties like baseDir, basePath, and baseHref to make this possible but as far as I can tell none of them quite do what I'm looking for.
So the process would be:
(1) The user picks a directory where the source will be saved
(2) The user creates a page using CKEditor where images from the directory chosen can be included AND DISPLAYED in CKEditor
(3) The user saves the source of their page to the chosen directory (the source saved here should use the relative path to the images because the source is now located in the same directory as the images it includes)
I realize this is a rather unconventional use of CKEditor but if someone might be able to kick me in the right direction to making this happen, I'd really appreciate it.
EDIT:
So after a little experimenting and changing some backslashes to regular slashes, it looks like the baseHref attribute does what I'd like. I've still not been able to change its value at runtime though as I would like. Does anybody know if this is possible with CKEditor? I'd still like to have a javascript function that I can pass a path to and have it change this baseHref value. Right now I have set its value in config.js.
If this isn't possible, I know you can read and write the source in and out of the editor. So I would like to resort to reading and storing the source from the editor, reloading CKEditor with a new config.baseHref, and then writing the source back into the editor. Does anyone know if the CKEditor api provides functionality to reload its configuration?
Thanks.
I don't expect too many people will be trying to do what I was doing here since CKEditor is usually hosted on a server somewhere, but in case someone finds it helpful, here's what I ended up doing.
As I mentioned in the edit to my question, modifying the baseHref gave me the functionality of prepending the image filename with the directory path leading to it. I wasn't able to find a way to modify it while the editor was running so I ended up telling CKEditor to load an external configuration file each time it started with the line
config.customConfig = 'C:/Users/kenwood/Desktop/MarkCreator2/ckeditor/custom_config.js';
Then I used C++ to write new contents to custom_config.js any time I wanted to switch directories.
Unfortunately this method meant I had to read the contents out of the editor, refresh the page, and then write the editor contents back in any time I wanted to change directories. This was adequate for what I needed though.

Ruby app running on Sinatra using HAML, can't access files in uploads directory?

I have a Ruby app which is an Image Resizer. It uses the RMagick gem to do this. The app asks the user to upload a file, and then resizes it and saves the newly generated file.
It seems that Sinatra by default puts all uploaded files into the 'uploads' directory, and the newly generated file also seems to be saved there. I am assuming this is default behavior, not sure how to change this, but it isn't an immediate problem at the moment (although if you know how to do this, that would be appreciated too).
Now, in my 'success.haml' page which is displayed after the file is generated correctly, I am trying to display the newly generated image with a simple img tag. The path to the file is found in #filepath, so when I did:
%img(src=#filepath)
the HTML rendered (when inspected using Firebug) is correctly showing
<img src="uploads/filename.jpg">
and this file does indeed exist in my folder structure. However, the image appears broken.
Any ideas on how to overcome this problem?
Thank you.
Relative urls (uploads/filename.jpg) are called so because they are relative to web root. In Sinatra this is the public folder. By default it's located in your app directory and called public. But you can override that.
set :public_folder, 'my_root' # this will make my_root dir the web root.
So, to make your uploads visible to the internet, put them into your public folder.
Read this for more Sinatra settings and customizations.

Resources