More convention examples - regex

I've been trying to get my head around the Brunch conventions configuration – my lack of comprehension is more than likely due to my lack of experience/knowledge in the world of regex.
It would be great to see an example of how to change the default build location of specific files in the assets/ folder.
A use case
I want to move only the HTML pages to a folder that isn't the public folder. Here's my current folder setup:
app
assets
_inc
header.html
footer.html
...
_layouts
main.html
404.html
...
styles
main.scss
..
node_modules
public
craft
templates
In this case I'd like to move all the HTML files: assets/**/*.html (in glob parlance) to the craft/templates folder.
Any advice, tips, etc would be excellent!
Please & thank you!

In my opinion, you just need to loop through all files in your current folder, use a regex like assets\/.*\/*\.html to search for a match. If match is found, then move to the folder of your choice (i.e, craft/templates).
Here is the regex demo.

Related

Why did I get Template does not exist error, though it appears Django offers flexibility with respect to folder structure?

I have read several posts here where people discussed their preferred directory structure to keep various files of their Django project. But I get a file-does-not-exist error if I put my templates in the inner my_project folder instead of the outer my_project folder which contains the manage.py file. Is there some config file that specifies the default location of the templates (and other files)?can you please help me with the command change if I put templates in the inner (sub) folder? I just began my first Django project and would appreciate your help.
Ok, django looks for your templates at default places. I recommend you put your html files there (as a beginner).
Default places are:
- my_site_project/
-- templates/
--- base.html
--- navbar.html
--- footer.html
-- my_app1/
--- templates/
---- my_app1/
----- index_app1.html
----- about_app1.html
-- manage.py
If you put a general templates/ folder inside your project, same folder as your manage.py, those templates will be pulled.
If you want app specific templates the convention is to put a folder inside your app, again called templates/. This can lead to overlap if you put index.html inside your app-templates and an index.html inside your general templates/. Therefore you need to namespace the templates of your app. Create the app; create a folder called templates/ inside it; inside just created templates/folder you create another folder called my_app1; in that folder create your .html files.
Read the tutorial here. It is probably easier to understand than my jibberish. It is the official django tutorial.
A part of it:
First, create a directory called templates in your polls directory.
Django will look for templates in there.
Your project’s TEMPLATES setting describes how Django will load and
render templates. The default settings file configures a
DjangoTemplates backend whose APP_DIRS option is set to True. By
convention DjangoTemplates looks for a “templates” subdirectory in
each of the INSTALLED_APPS.
You can, in your settings.py via DIRS, specify where django looks for your templates. Although as a beginner I do not know why you should not stick to the conventions first.

Automatic Link to GitHub Pages URL from README.md?

Is there a way to create a link to a repository's GitHub page in the repository's README.md (or other Markdown file) without hardcoding the URL?
The use case I'm facing is the result of forking a repository in which the README includes [a link](https://their-org.github.io/repo/), and which I'd rather not have to manually update to [a link](https://my-org.github.io/repo/).
My readme is (repo)/blob/master/README.md
I'm not sure how robust this is, but this test worked for me:
test link: [testlink](../../)
Is that what you were asking for?
Relative links always works on README.md and in every markdown file in your repo. I'm using them to document a personal project and I've never had an issue with that. Take a look at (https://github.com/andreabenini/bM3tal/blob/master/README.md) plenty of relative links in each part of the project. I'm documenting it with md files because I'm lazy and for a bare doc markdown files are qu

Foundation 5 custom sass project setup

I have a project that I would like to use foundation 5 with. I have been through the steps of creating a new foundation project using the CLI but I don't like it. There is too many files and the structure does not match what I want. So...
I am intending to add only the required files to my project and use compass to compile all the css.
I have noticed in the project created on the CLI a few things that confuse me and would like some help in clearing them up.
In the project created on the CLI there are two _settings.scss files one under the foundation directory in bower_components and one in MY_PROJECT\scss. I'm assuming that because of this add_import_path "bower_components/foundation/scss" line in the config.rb, which of those files has preference?
Why does MY_PROJECT/stylesheets not have normalize.css (or foundation.css) in it? And how are they not there? (in my custom setup they are being generated, albeit in subdirectories of stylesheets, also the foundation.css that is being generated for me has no settings changes applied so I guess it shouldn't be being generated)
If you take a look inside \bower_components\foundation\scss you'll see the file foundation.scss. That file imports all the stylesheets for all the additional components that come in the Foundation 5 "package." In your root scss directory, the app.scss is what compiles the SASS into \stylesheets\app.css. So rather than this:
#import "foundation";
Uncomment the individual components you'll be using. Something like this:
#import
//"foundation/components/accordion",
//"foundation/components/alert-boxes",
"foundation/components/block-grid",
//"foundation/components/breadcrumbs",
//"foundation/components/button-groups",
//"foundation/components/buttons",
"foundation/components/clearing",
"foundation/components/dropdown",
//"foundation/components/dropdown-buttons",
//"foundation/components/flex-video",
"foundation/components/forms",
"foundation/components/grid",
//"foundation/components/inline-lists",
//"foundation/components/joyride",
//"foundation/components/keystrokes",
//"foundation/components/labels",
//"foundation/components/magellan",
//"foundation/components/orbit",
//"foundation/components/pagination",
//"foundation/components/panels",
//"foundation/components/pricing-tables",
//"foundation/components/progress-bars",
"foundation/components/reveal",
"foundation/components/side-nav",
//"foundation/components/split-buttons",
"foundation/components/sub-nav",
//"foundation/components/switches",
"foundation/components/tables",
//"foundation/components/tabs",
//"foundation/components/thumbs",
//"foundation/components/tooltips",
"foundation/components/top-bar",
"foundation/components/type",
"foundation/components/offcanvas",
"foundation/components/visibility";
If you'd like to streamline your file structure, I would suggest you remove any scss files from the \bower_components\foundation\scss\foundation\components directory that you will not use. Same with the js directory. You don't actually need to modify anything in the bower_components directory to get everything to work. Not entirely sure why it's all contained within bower_components, but I imagine it's got something to do with being able to update the core components later with future releases.
Someone else could probably give a more educated answer.
p.s. - make sure to compass watch in your CLI to see any of those changes made to your SASS files.

How to package an OpenStack Horizon Dashboard plugin correctly?

I am packaging a Horizon Plugin. I have a bunch of templates, a view, as well as css, js files, and images.
Everything should be contained so that the package is either a .deb or a tarball. So right now I keep all files in /opt/stack/horizon/openstack_dashboard/dashboards/<my-dashboard-name>.
My question is, how do I include js and css files properly? There is /opt/stack/horizon/openstack_dashboard/settings.py file that specifies HORIZON_CONFIG.js_files, however it is always empty! I put a list of files there, it still comes out as empty in the templates. So the question is, how do I include js and css files in a Horizon dashboard plugin, for the purpose of packaging it in either a single tarball or a .deb package?
You should store static files below <my-dashboard-name>/static. It's best to namespace your static files, I use the following directory structure:
<my-dashboard-name>/static/<my-dashboard-name>/js and so on for css and img then I reference the files in the HTML templates with /static/<my-dashboard-name>/js/jsfile.js, that way you won't get any name collisions.
When someone uses your plugin they extract your dashboard and register it in the right places and then additionally they have to run the collectstatic django management command from the base openstack_dashboard directory (in your case /opt/stack/horizon/), either:
$ ./run_tests.sh -m collectstatic
or
$ ./manage.py collectstatic
That should copy your static files to the right places according to how the site has been configured.

HTML5 Boilerplate - Modifying the build.xml for WordPress

I'm trying to get the Build Script that's included in HTML5 BoilerPlate (http://html5boilerplate.com/) to play nicely with WordPress. I've successfully changed the default config to compress style.css in the root of a WordPress theme, but I'm not sure how to modify the build.xml to run through the WordPress header.php and footer.php.
Normally build.xml runs through the index.html file and strips out commenting then, most importantly, changes the version name of the css and js file references.
I'm imagining this should be pretty easy for a developer to figure out, the build.xml uses regular expressions to replace lines of code.
I'd like the build.xml to wizz through my header.php and footer.php, performing the same optimisations as it does with index.html.
Can anyone suggest which parts of the build.xml I need to modify to accomplish this?
you do not need to edit the build.xml file. Just add the files you want parsed to build/config/default.properties :
#
# HTML, PHP, etc files to clean and update script/css references
#
file.pages.default.include = index.html, 404.html, header.php, footer.php