I'm trying to write a #mixin for High Density Display like the iPhone 4+ Retina Display. Therefore I want to automatically append "#2x" as a suffix to the images filenames.
Since image-url() throws back the whole path I can't append the suffix. Not I'm trying to access the Image-Path I've set in the config to patch the URL together by myself.
Like:
background: $color url("#{$http_images_path}"+"#{$image-name}"+"#2x"+"#{$image-extension}") $x $y no-repeat
But #{$http_images_path} is undefined. Is there a way to access it? I don't really want to define the image-path seperatly since it would make the config quite unnecessary.
Even nicer would be if I could split the return of image-url() before the "." of the extension and add "#2x", because I wouldn't need to define the extension separately. I've tried to use Ruby in the sass file like puts "test" but it didn't work. So I'm not sure if theres a way to split strings with sass.
Do you guys have some good ideas?
Thanks!
Alex
You can concatenate your image name inside image_url()
config.rb
images_dir = "images"
http_images_path = "/your/path"
screen.sass
$image-name: "asset"
$image-extension: ".png"
.class
background-image: image_url($image-name + "#2x" + $image-extension)
screen.css
/* line 4, ../sass/screen.sass */
.class {
background-image: url('/your/path/asset#2x.png?1327210853');
}
If you want to go the route of splitting the file name and inserting #2x, you'll have to create an extension where ruby does that for you. You could use my Compass extension as a starting point.
Related
I looked everywhere, but there are not any guides or explanations of how to use QSkyBoxEntity.
I created Entity and filled it with transform (set translation and 3d scale). Also changed name and extension.
When I'm trying to run program it says
"Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit for "skyboxTexture""
I checked several times and tried different png files but no luck.
My image (I know it's fake transparency, but it shouldn't change anything, right?)
And here's part of a code:
Qt3DCore::QEntity *resultEntity = new Qt3DCore::QEntity;
Qt3DExtras::QSkyboxEntity *skyboxEntity = new Qt3DExtras::QSkyboxEntity(resultEntity);
skyboxEntity->setBaseName("skybox"); //I tried using path as well
skyboxEntity->setExtension("png");
Qt3DCore::QTransform *skyTransform = new Qt3DCore::QTransform(skyboxEntity);
skyTransform->setTranslation(QVector3D(0.0f,0.0f,0.0f));
skyTransform->setScale3D(QVector3D(0.1f,0.1f,0.1f));
skyboxEntity->addComponent(skyTransform);
Looks like it's not finding the skybox texture. Did you use an absolute path when you say "I tried using path as well"? The path you set is relative to the build path, i.e. it's not where your C++ file lies.
Alternatively, you could use a resources file and then load then image using
"qrc:/[prefix]/[filename without extension]"
You can also check out the Qt3D manual SkyBox test here:
https://github.com/qt/qt3d/tree/dev/tests/manual/skybox
It's important to properly name files in order for skybox to work and use resource file for storing.
I recommend .tga, but other formats should work as well.
You can read about it here:
https://doc.qt.io/qt-6/qml-qt3d-extras-skyboxentity.html
And here's example how it should look
I'm using Docusaurus to publish documentation for an open source library's API. The headings of my source markdown files correspond to the names of methods and properties for classes in the library. This all works fine.
However, the anchors that are created in the HTML are all lowercase. I want them to respect the capitalization used in the markdown file.
For example, this markdown header:
###.doSomething()
Generates the following HTML:
<h3>
<a aria-hidden="true" tabindex="-1" class="..." id="dosomething"></a>.
<code>.doSomething()</code>
<a class="..." href="#dosomething" title="...">#</a>
</h3>
As you can see, camelCase is transformed to lowercase. I would like to keep capitalization intact. Is it possible?
P.S. The markdown files are automatically generated from jsdoc comments. In jsdoc, links to a method or properties include capitalization.
TL;DR
Inside your project, navigate to the directory node_modules > github-slugger;
Open the index.js file;
Remove the line if (!maintainCase) string = string.toLowerCase()
The function will become something like this:
function slugger (string, maintainCase) {
if (typeof string !== 'string') return ''
// if (!maintainCase) string = string.toLowerCase() <-- remove this!
return string.trim()
.replace(specials, '')
.replace(emoji(), '')
.replace(whitespace, '-')
}
IMPORTANT!
If you update the docusaurus, you may need to apply this change again;
It may be necessary to edit the doc to see the changes, because of cache. Here I edited the doc file and it worked;
You must restart the docusaurus service after you make this change. And probably needs to clear the cache with npm cache clear --force;
Also, I think you should delete the folder .docusaurus to force the rebuild of all documents.
RESULT
The .md file:
---
id: intro
---
# Random title
### WriNTinG with CaSeS
test 1
### .doAnotherThink()
test 3
### .doCamelCaseWithSeveralLETTERS()
test 3
ROADMAP
I must say that this one was hard. First I tried to track down the anchor tags, then the description. Eventually I found about the github-slugger, and looked like that was the way.
But once I made the changes, nothing had happened to the document! So after hours trying, I gave up… Then, just for curiosity, I decide to see what the slug function did to the document, by adding a second header with the same name. And — luck! — it kept the original case.
It turns out that you can simply use explicit IDs to solve this issue: https://docusaurus.io/docs/next/markdown-features/headings#explicit-ids
I am trying to generate multiple CSS classes for a single .css file to be used by the body element of a page to change the page's entire color scheme.
I have a folder of .less files containing variables #base00 to #base0F for their specific color scheme (https://github.com/AndrewBelt/hack.chat/tree/master/client/base16) and would like to import each of these files for each CSS class name.
Here's some psuedocode to achieve what I need.
// This syntax does not exist in LESS
for each #scheme in ./base16/ {
#import "#scheme"
body.#{scheme} {
background: #base00;
color: #base07;
}
...
}
I might have to think outside of the box for this one, like creating a Makefile to build by replacing variable by command line and concatenate each .css file generated by LESS to a single master .css file. But perhaps there is a more elegant way using pure LESS.
No, there's no built-in file system functions/features Less. (It's designed to work in several environments and some of those do not even permit "directory sniffing"). If necessary one can write a plugin to provide such functionality, but I suppose in this case it would be more easy to do this externally.
Compiling and concatenating multiple files is not necessary the simplest method. For example you can simply generate Less file that imports all schemes and applies each to a main template, e.g. just a list of:
.scheme-name {
#import "scheme-name";
#import (multiple) "scheme-styles-template";
}
statements. Where scheme-styles-template is the same as your scheme.less except body to be defined as:
body& {
background: #base00;
color: #base05;
}
I had to come up with quite a complicated setup to enable database based styling options for users. Users enter styles (like background color, font face, etc...) in the django admin backend.
I am creating a dynamic LESS file by rendering a template view as plain text view like so:
views.py:
class PlainTextView(TemplateView):
"""
Write customized settings into a special less file to overwrite the standard styling
"""
template_name = 'custom_stylesheet.txt'
def get_context_data(self, **kwargs):
context = super(PlainTextView, self).get_context_data(**kwargs)
try:
#get the newest PlatformCustomizations dataset which is also activated
platform_customizations = PlatformCustomizations.objects.filter(apply_customizations=True).order_by('-updated_at')[0]
except IndexError:
platform_customizations = ''
context.update({
'platform_customizations': platform_customizations,
})
return context
def render_to_response(self, context):
return super(PlainTextView, self).render_to_response(context, content_type='plain/text')
The template custom_stylesheet.txt looks kind of like this. It takes the database styling entries the users entered in the admin backend:
#CIBaseColor: {{ dynamic_styles.ci_base_color }};
#CIBaseFont: {{ dynamic_styles.ci_base_font }};
...etc...
Now I include this dynamic less files in my main.less file with other normal static LESS files. Like so:
main.less:
#import "bootstrap_variables.less";
//this is the dynamicly created custom stylesheet out of the dynamic_styles app
#import url(http://127.0.0.1:8000/dynamic_styles/custom_stylesheet.less);
//Other styles
#import "my_styles.less";
This setup works fine. The dynamic variables out of my database get rendered into the template and LESS compiles all my less files together.
I have a problem when pushing the code to my production setup where I compile the LESS server side and compress it with django-compressor.
I get the following error:
FilterError: [31mFileError: 'http://127.0.0.1:8000/dynamic_styles/custom_stylesheet.less' wasn't found.
[39m[31m in [39m/home/application/***/media/static-collected/styles/less/main.less[90m:13:0[39m
[90m12 //this is the dynamicly created custom stylesheet out of the dynamic_styles app[39m
13 [7m[31m[1m#[22mimport url(http://127.0.0.1:8000/dynamic_styles/custom_stylesheet.less);[39m[27m
[90m14 [39m[0m
Has anybody ever experienced problems with django compressor like that? Does it have problems with dynamically created files like this? Could the absolute url be a problem?
Could you think of another solution get dynamically generated less files working with django compressor?
I guess Django-Compressor can't read dynamically created less files which are only available "on-the-fly" if you hit the url. At least I did not get it working. Also the file needs to be on the COMPRESS_ROOT.
Now I write the less file to disk physically every time the model gets saved. Here's the code. It still needs some improvement like try except, etc. But it works:
def save(self, *args, **kwargs):
#todo add try except
less_file = open(os.path.join(settings.PROJECT_ROOT, 'media', 'static', "styles", "less", "custom_stylesheet.less"), "w")
less_file.write(render_to_string('template/custom_stylesheet.txt', {'platform_customizations': self}))
less_file.close()
super(PlatformCustomizations, self).save(*args, **kwargs)
I have seen this line of code in Yii when playing with layout:
<?php $this->beginContent('//layouts/main'); ?>
Normally I only see single forward slash, but now double. And, when I remove one forward slash in the above code, the output display didn't change at all.
So, could you tell me why Yii using double slashes instead of single slash? And does them return the same resutl?
Thank you.
In Yii context and this example //layouts/main will be rendered to protected/views/layouts/main.php. It's path to your layouts folder.
You want to use double slashes if there is non-default layout directory.
For example if you have two folders layouts and layouts-fancy under protected/views/{here}
You can switch to fancy layouts by prefix path with '//'. By default Yii will be using layouts (see http://www.yiiframework.com/doc/guide/1.1/en/basics.view#layout).
For better testing create new layout protected/views/layout-fancy/main.php and add variable public $layout = '//layout-fancy/main.php'; to your base Controller.php and see what happen.