Simple paragraph break - dashcode

I am trying to make a simple paragraph break in my text file (name.js) so that when the iphone pulls the information (name.js) there is not one big run on paragraph. I have looked and looked and cannot find this information can you help me project is due at this time...

try something like this in the javascript:
var pageBreak = document.createElement("/p");
document.getElementsByTagName("tagToInsertBreakAfter")[0].appendChild(pageBreak);

I am away from my machine so i cannot check but try a \n or \r\n
Well it had to be one or the other it'
<br />
i just hacked a widget and tried it. By the way i am assuming you are doing some like the following
// localised strings
var backString_01 = "World Second <br />offers unbeatable exchange rates and exceptional service for foreign exchange and international payments";
then outputting to the document with
document.getElementById('services_headline').innerHTML = backString_01;
With the element in the html something like ....
<div id="services_headline" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis"></div>

Related

Typoscript filelink - Wrap URL within link

First, here is the Typoscript :
20 = TEXT
20 {
value {
field = field_title
wrap = |.txt
}
filelink {
stdWrap.wrap = <li>|</li>
path = fileadmin/txt-files/
}
}
The result I get is :
<li>
<a href="/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
And what I need is :
<li>
<a href="/fileadmin/force_download_script.php?filepath=/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
I need to make the link downloadable, rather than opening the file in the browser. For that I have a force_download_script.php, but when I do that :
wrap = fileadmin/force_download_script.php?filepath=|txt
instead of the current wrap, filelink doesn't find the file anymore.
I have tried using ATagBeforeWrap.wrap but it doesn't look like it's made for that purpose. I also tried typolinkConfiguration.wrap without any success.
Any idea of how to achieve that ? Using a COA maybe ?
Thank you !
I would not do this with a script, but with server configuration. If you use Apache and have .htaccess enabled, you can add the configuration to a .htaccess file in the directory where the files are located. See https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
Alternatively you can also use the HTML5 download attribute. This is not supported by Internet Explorer however (it is supported by Edge though).
The issue can get quite a bit complicated, but step by step:
your code above might be wrong if it's not just a copy & paste fault:
wrap = fileadmin/force_download_script.php?filepath=|.txt
The dot before txt was missing.
Nevertheless it is still interesting if the php-script is triggered.
It's possible that the script is not triggered due to some settings in typo3conf/LocalConfiguration.php respectively some settings in the install-tool.
Depending on the TYPO3-Version it's also possible that the script is not triggered at all because all scripts are being required now in an extension. That means you might need to create an extension for that script.
Also simple wrapping of the result with the script-path might not be enough, but you have to call it explicitly by TypoScript perhaps by including the script as user-function or lib.
The admin-panel might be useful to debug some things about your script but if not you've to include some debug-output first in your own code, if that's not enough in the core (temporary).
So you've to find out if your script is triggered and if not, the reason for it.
Are you sure .filelink is what you are looking for?
.filelink is for a set of files. For all files in the folder given by .path a link will be generated. see manual
From your description you want a text wrapped with a link to one single file. That would be more a problem for .typolink where you specify the link in .parameter.
if you really want a link list of multiple files, each wrapped with your script you need to modify .typolinkConfiguration.parameter which will be used internaly by .filelink.
Anyway it might be possible to do a wrap which then would be:
.typolinkConfiguration.parameter.wrap = /fileadmin/force_download_script.php?|
Maybe it is easier to build your list with .stdWrap.filelist, where you can use the filenames in any way to wrap your own href parameter for an A-tag.
To use the TYPO3 core solution with file links you can use this guide:
Create a file storage where you want your "secured" files in TYPO3 backend
Do not set the checkbox "Is public?" in the storage record
The links will be rendered with eID and file parameters
You can look into the FileDumpController handling these links: https://github.com/TYPO3/TYPO3.CMS/blob/2348992f8e3045610636666af096911436fa1c89/typo3/sysext/core/Classes/Controller/FileDumpController.php
You can use the included hook to extend this controller with your logic.
Unfortunately I can't find any official documentation for this feature, but will post it when I find something or wrote it myself. ;)
Maybe this can help you, too: https://extensions.typo3.org/extension/fal_securedownload/
Here is the official part, but it's not much: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Fal/Administration/Storages.html?highlight=filedumpcontroller

Selenium IDE, selecting muliple text using same class

I have a page with lots of text using the same class. I am wanting to select and store all the text with that same class. Is this possible? All advice & comments appreciated!
I have HTML code like this:
<p class="foo">Some sample text</p>
<p class="foo">Some more sample text</p>
I have tried this:
<tr>
<td>storeText</td>
<td>//p[#class=foo']</td>
<td>var1</td>
</tr>
I expected var1 to be:
Some sample text
Some more sample text
Alternatively do I need to set up a while statement and gather each individually?
This page talks about a similar exercise, but uses Selenium for Python: Get the text from multiple elements with the same class in Selenium for Python?
//gather all p[class=foo]
List<WebElement> ele = driver.findElements(By.cssSelector("p.foo"));
Iterator<WebElement> iter = ele.iterator();
// initialize array, map, whatever
While(iter.hasNext()) {
// insert text into map
// print to log
// store in array
//whatever you need
var.add( iter.next().text() );
}
I didn't get to try out the answer from #bcar because I am not a javascript expert nor am I sure I could put the answer into IDE. I found another way however. I discovered that the text is stored in tables, so I am using the following code to extract the entire table (which includes the text I need).
<tr>
<td>storeText</td>
<td>//div/h2[text()="Elements and Performance Criteria"]/following::table</td>
<td>Content</td>
</tr>
Now I have to work out how to replace the new lines with as this is plain text. Another question for stackoverflow! Thanks.
Quite easy:
Just loop through the stored elements.
Whenever you use find_elements_by_class_name, it returns the list of selenium web elements. Hence you just need to iterate with a loop, like this.
names = driver.find_elements_by_class_name("_xEcR")
for i in names:
print(i.text)

xpath query question

below is my xml document and right now my query is: /description/*/text(), I can get all the text except that the text inside the <strong> lunch </strong> which "lunch" doesn't display.
This is probably a simple fix but I just couldn't get it correct.
<description>
<![CDATA[
<p>
Envie is a brand new Bar Lounge that offers a modern-design space opening onto Wyndham Street, where on busy nights the crowd spills out onto the street...
</p>
<p>
If you are in for a <strong>lunch</strong>, the Twangoo voucher will offer you two delicious Lunches – perfect for that lunch meeting, a casual date or just a get together with friends in a relaxed and modern atmosphere.
</p> ]]>
</description>
Try
/description//text()
Right now you are selecting every text only for all the child nodes of description.
If you use //text() instead; you are selecting every text for all nodes that are descendant of the current node (description).
Your query /description/*/text() selects the text node children of the element children of the description element. But the description element has no element children. It would have, except that the CDATA is telling the parser not to treat the <p>...</p> content as markup, but as plain text. I don't know why the XML is wrapping this stuff in CDATA, but it makes it much harder to process it or query it.

Convert links in blockquotes to plain text

So, I've been asking a lot of Xpath questions recently.
Sorry, but I've only just started using it, and I'm working on a kind of hard project.
You see, at the moment I'm parsing HTML like this (not a copy and paste, just an example):
<span id="no153434"></span>
<blockquote>Text here.<br/>More text.<br/>Some more text.</blockquote>
And I'm using
//span[starts-with(#id, 'no')]/following::*[1][name()='blockquote']//node()
To get the text inside.
It's working fine, although it's very frustrating. I need to manually check for then manually combine the strings before and after the br, add a newline, and so on. But it stills works. Until there is a link in the text, that is. Then the code is like this:
<span id="no153434"></span>
<blockquote>Text here.<br/>Text.<br/><font class = "unkfunc">linkhere</font></blockquote>
I have absolutely NO idea where to go from here, as the link is included as a completely seperate item (twice) in the array. Atleast with the br I knew where it had to be moved to. Really contemplating giving up in this project after all this effort.
You can use this XPath to obtain text inside element: //span[starts-with(#id, 'no')]/following::*[1][name()='blockquote']//text()
So you receive following result:
Text here.
Text.
linkhere
If you want only text nodes and br:
//span
[starts-with(#id, 'no')]/
following::*[1][name()='blockquote']
//node()
[ count(.|..//text()) = count(..//text())
or
name()='br'
]
returns
Text here.
<br />
Text.
<br />
linkhere
The answer is to not use XPath for this kind of work.
Got it working 1,000,000x easier with Objective-C-HTML-Parser.

Find and replace variable div contents

I have a php page which contains a large amount of HTML in it. One part of the HTML has a div in the following format:
<div class="reusable-block" id="xyzabcwy">there is a lot of HTML here which may be in any format</div>
Keep in mind, this div is contained within the DOM at any location however, I do know the div ID programatically.
I was originally finding this string within my database, since a record of it exists there however, the format between the data in the database record and the page are sometimes different due to whitespace but other than the white space, the strings are exactly the same. The problem is, I don't know what format the whitespace is in.
It seems it is better to write a regular expression to find this div and replace it entirely.
I could use a hand though.
Other ideas are also welcome.
Many thanks!
If you are using jQuery,
$('#xyzabcwy').html(new_data);
if not
document.getElementById('xyzabcwy').innerHTML = new_data;
otherwise, here is a PHP example.
Edit: PHP
<?php
$id = "xyzabcwy";
$html = "<div id=\"" . $id . "\">this is html</div>";
$newdata = "test";
echo preg_replace("#<div[^>]*id=\"{$id}\".*?</div>#si",$newdata,$html);
?>
 This should output
<div id="123">test</div>
Answer from: Replace a div content with PHP