How can I rename files uploaded through ADAM in 2SXC? - dotnetnuke

Using the 2SXC Content module, I have a simple Hero content type and template that includes a title and a background image. I use a C# Razor template and when my users upload a background image via ADAM, the razor template applies the background through inline CSS. Something like this:
#if (Content.BackgroundImage != "") {
<style type="text/css">
section.hero {
background-image: url(#Content.BackgroundImage);
}
}
The problem is that if the user uploads a file name that has spaces and/or illegal characters, the background image will not appear because the browser doesn't like spaces in the filenames in the inline CSS.
How can I make it so that the file uploaded by ADAM strips out the spaces and removes the illegal characters?

You'll have to url-encode them, like replacing with %20. Use https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525738(v%3Dvs.90) or HttpUtility.UrlEncode or one of the variations :)

#HttpUtility.UrlEncode(Content.BackgroundImage).Replace("+", "%20").Replace("%2f","/")
Using iJungleBoy's suggestion, I used HttpUtility.URLEncode. But it replaced the spaces with +, and / with %2f, so I use .Replace to swap out + for %20 and %f for / to make a nice simple URL. This now accepts images with spaces in it.

Related

How can I insert an emoji on config.toml in Hugo rendered website?

I want to add a cloud emoji on my webpage's footer, but apparently the config.toml file doesn't support emojis
[params]
footerText = ":cloud: David Jorquera - 2020"
...is rendered as text.
How can this be done?
Why that doesn't work?
Hugo uses the emojify function to parse templates for emojis substitution. But it doesn't apply such functions to the configuration.
To do so, you would have needed to pass your variable to the function in the template using {{ .footerText | emojify }} as documented in this other question.
Use directly UTF-8 characters in configuration
Your TOML configuration file can be considered as an UTF-8 document.
As such, you can directly add the emoji in the config value:
[params]
footerText = "☁️ David Jorquera – 2020"
This sample uses an emoji and a dash between your name and the year.

Can we put underline in single line text field of contentful?

I added one field which is of type text as single line. Now I need to make some
of the text as underline.for example:-
He is a good employee.
I want underline in employee text. How can I add that in contentful?
👋🏻
When you're using the Markdown editor the problem the problem is not with Contentful but rather the markdown specs themselves. They do not provide the "underline" functionality.
The question about underline is a common question. The idea of markdown is to only care about content and not really the representation (e.g. "bold" translates to the html strong element which stands syntactically for important parts) though.
IMO underlined text can also be confused with links too easily.
If you have to make this work you can either bring in inline HTML (has the downside that you'll loose cross-platform compatibility because not every system can deal with HTML) or you handle the underline functionality in your application consuming Contentful with some CSS for example.
E.g. assuming that you want to highlight something in your application/website I could see that the "bold"/"strong" meaning could work for you.
Overall rule of thumb with markdown is thinking of the document structure and content rather then it's appearance. "These are important words in this paragraph" (👍) vs. "These are words that should be underlined" (👎).
In Contentful write the text under Markdown as:-
He is a good <u>employee</u>
Now in our reactjs application we can write:-
dangerouslySetInnerHTML={{
__html: employee.childMarkdownRemark.html,
}}
Hence if we render the output in the childMardownRemark.html under dangerouslySetInnerHTML then employee will come as underline in our UI.

CakePHP - Remove asterisk from required inputs

I'm building a CakePHP application that involves forms, and I'm looking for a way to remove the asterisk from required fields. I have several input fields that are required, but I do not want the asterisk to show.
I've tried using 'required'=>false, but that makes the field optional as well as removing the asterisk. I just want to remove the asterisk; the field needs to remain required.
You could modify the css that adds that. I've made changes in my css, so I'm not sure if it's the one that comes out of the box anymore (for that matter, I don't know if you are using the one that comes out of the box), but the css that adds those asterisk(s?) on my form is
label.required:after {
color: #EE3322;
content: "*";
display: inline;
}
And you should just replace that content:"*" with
content: "";
Now, if your css isn't the same as mine, inspect the label element, and look for a similar line (it's probably using a content: "*", so you know what you have to look for).
If you want to delete the asterisks for a single view, add an inline style in the view. If it is for the whole application, delete the line in the css file.

Custom font Xcode 4.6 using storyboard

I have added Imago font (including bold, italic and those both with those names: boolta, med and medlta) to Info.plist, but now I'm totally stuck with several tutorials.
I'm using storyboard mode.
Could someboby tell me what codes I have to write and where to get these font to work?
been having a lot of issues with fonts myself recently and there are a few things I suggest checking: -
1/ Always use .ttf format
2/ Make sure your font is included in 'Copy Bundle Resources' in your project 'Build Phases'
3/ Custom fonts should be defined in the array in your '[appname]-Info.plist' like you said above, it's under the heading 'Fonts provided by application'
4/ Make sure that you are using the correct font name as it is usually different to the filename. To get a list of available font names use the below code. Just using finders 'Get Info' is not always reliable: -
for (NSString* family in [UIFont familyNames]){
for (NSString* name in [UIFont fontNamesForFamilyName: family]){
NSLog(#"font=%#", name);
}
}
Then use the font name outputted in your log
5/ If that STILL doesn't work, it may mean your font encoding is a little messed up. I had this recently with a .ttf font, the app just couldn't see it so I stuffed the file into this online converter and whatever the issue was disappeared, magic!

Sublime Text 2: Different language highlighting based on context? (a la Webstorm)

I was watching some videos on Egghead.io about AngularJS. The creator of the videos uses Webstorm (and, I believe, works for them). One feature I noticed is that he can set different syntax highlighting within different scopes or quotation marks. So, in code like the following (from an AngularJS directive)
return {
template: '<div>something</div>',
// ^^^ these guys ^^^
}
...he can get the inside of the quotation marks to highlight as HTML.
I use Sublime Text 2, and am fairly wedded to it. Is there an existing feature/plugin for Sublime that could handle a case like this? If not, is something like this technically possible using the Sublime Text 2 API?
I don't think it's built in, but it's certainly possible. I've been doing some work with graphviz and wanted to do something similar. Labels can be generated with html like syntax. Anyways, I played around with the .tmLanguage file and added a new pattern to match the context where html like entries were valid (I look for label = <). The patterns I used for the captures aren't that good, but it works for fine for me. This give me the following, which I think is similar to what you are looking for.
I don't know anything about AngularJS, so I can't help you with anything specific to that, but it is certainly possible. Note that in the image below, the last <table></table> are just to show that highlighting doesn't occur there.
Edit:
Forgot to include this in the original post, but here is my updated tmLangauage file. That first pattern is what I added(link). I used PlistJsonConverter to go from JSON to plist, then saved the file as .tmLanguage. Hope this helps.
#skuroda is right, I implemented #skuroda's code with an additional plugin to easily edit HTML within an AngularJS directive JS file. The result is HTML syntax highlighting within a directive JS file and additional functionality to remove string related delimiters while editing templates.... Sublime AngularJS HTML Template Plugin

Resources