SpecFlow tests does not work in OrchardCMS 1.4 - orchardcms

How to run SpecFlow tests in OrchardCMS 1.4?
Steps:
Download OrchardCMS from here.
Run UsersFeature.ICanCreateANewUser() test. (WITHOUT BUILDING ALL SOLUTION!)
Result in Unit Test Sessions - Session window:
...
error: Unable to locate <input> name SiteName in page html:
<html>
<head>
<title>A 'script' named 'jQuery' could not be found.</title>
<style>
...
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>A 'script' named 'jQuery' could not be found.</i> </h2></span>
...
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br><br>
<b> Exception Details: </b>System.InvalidOperationException: A 'script' named 'jQuery' could not be found.<br><br>
<b>Source Error:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
Line 259: throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "A '{1}' named '{0}' could not be found.", settings.Name, settings.Type));
Line 260: }
<font color=red>Line 261: ExpandDependencies(resource, settings, allResources);
</font>Line 262: }
Line 263: requiredResources = (from DictionaryEntry entry in allResources</pre></code>
</td>
</tr>
</table>
<br>
<b> Source File: </b> ...OrchardCMS_1.4\src\Orchard\UI\Resources\ResourceManager.cs<b> Line: </b> 261
<br><br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[InvalidOperationException: A 'script' named 'jQuery' could not be found.]
Orchard.UI.Resources.ResourceManager.BuildRequiredResources(String resourceType) in F:\coding\zulatm\OrchardCMS_1.4\src\Orchard\UI\Resources\ResourceManager.cs:261
Orchard.Core.Shapes.CoreShapes.WriteResources(Object Display, TextWriter Output, String resourceType, Nullable`1 includeLocation, Nullable`1 excludeLocation) in F:\coding\zulatm\OrchardCMS_1.4\src\Orchard.Web\Core\Shapes\CoreShapes.cs:354
CallSite.Target(Closure , CallSite , CoreShapes , Object , TextWriter , String , ResourceLocation , Object ) +420
System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid6(CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) +1323
Orchard.Core.Shapes.CoreShapes.HeadScripts(Object Display, TextWriter Output) in F:\coding\zulatm\OrchardCMS_1.4\src\Orchard.Web\Core\Shapes\CoreShapes.cs:286
</body>
That is shown for every test case in SpecFlow I tried.

have you tried with a source enlistment rather than downloading the 1.4 release?

Didn't build all solution. Hence the Jquery module was not built and no JQuery script files there. Stupid mistake!

Related

Get the all values of "a" tags

I make a mini-project to reach a better level but I stuck here. Here is my code:
from bs4 import BeautifulSoup
import requests
html_from = requests.get("http://www.muhfak.hacettepe.edu.tr/tr/duyurular")
html_from.encoding = "UTF-8"
html_text = html_from.text
soup = BeautifulSoup(html_text, 'html.parser')
titles = soup.find_all("div", class_="liste")
print(titles[0])
I have to add "[0]" after the "titles" because the whole part is in a one-length list. I can see all the sections that I need in HTML codes. Is there a way to put each value in different list values?
When I make "titles[0].text", I can see the values I want. But "print(titles[0].a.text)" is not working and its output is only the latest value. How can I reach that values?
This is "titles[0].text" :
Yandal Başvurusu Hakkında 2022-01-05 15:00:00
2019/2020 - 2020/2021 Akademik Yıllarını Kapsayan Fakültemiz Faaliyet Raporu için Tıklayınız.
2021-12-14 08:00:00
13 Eylül 2021 Tarihinde Yapılan Mezuniyet Töreni Videosu için Tıklayınız. 2021-09-15 15:00:00
...
This is "titles[0].text" :
Yandal Başvurusu Hakkında
This is the part of the source and there are lots of "a" tags :
<script charset="utf-8" type="text/javascript">
$(document).ready(function() {
$('#duyurular_7').dataTable( {
"sPaginationType": "full_numbers",
"bStateSave": false,
"bSort": false,
"olanguage": {
"url": "//hu-iys.hacettepe.edu.tr/templates/template3/js/datatables_langs/tr.json"
}
} );
} );
</script>
<table class="table table-striped table-bordered" id="duyurular_7">
<thead>
<tr> <th>Başlık</th> </tr>
</thead>
<tbody>
<tr><td>Yandal Başvurusu Hakkında <span class="tarih">2022-01-05 15:00:00</span></td></tr>
<tr><td><a href="/tr/20192020_20202021_akademik_yil-184">2019/2020 - 2020/2021 Akademik Yıllarını Kapsayan Fakültemiz Faaliyet Raporu için Tıklayınız.
</a> <span class="tarih">2021-12-14 08:00:00</span></td></tr>
<tr><td>13 Eylül 2021 Tarihinde Yapılan Mezuniyet Töreni Videosu için Tıklayınız. <span class="tarih">2021-09-15 15:00:00</span></td></tr>
<tr><td>Fakültemiz Bölümlerinin Tanıtım Günleri İçin Tıklayınız. <span class="tarih">2021-08-06 10:00:00</span></td></tr>
<tr><td>2020-2021 Akademik Yılı Yandal Programı Sonuçları için tıklayınız. <span class="tarih">2020-10-02 11:00:00</span></td></tr>```
To get all <a> tags under tag with class="liste" you can use CSS selector ".liste a". For example:
import requests
from bs4 import BeautifulSoup
html_from = requests.get("http://www.muhfak.hacettepe.edu.tr/tr/duyurular")
html_from.encoding = "UTF-8"
html_text = html_from.text
soup = BeautifulSoup(html_text, "html.parser")
for a in soup.select(".liste a"):
print(a.get_text(strip=True))
print(a["href"])
print()
Prints:
Yandal Başvurusu Hakkında
/tr/yandal_basvurusu_hakkinda-177
2019/2020 - 2020/2021 Akademik Yıllarını Kapsayan Fakültemiz Faaliyet Raporu için Tıklayınız.
/tr/20192020_20202021_akademik_yil-184
13 Eylül 2021 Tarihinde Yapılan Mezuniyet Töreni Videosu için Tıklayınız.
https://www.youtube.com/watch?v=k55WKZAfmU8
Fakültemiz Bölümlerinin Tanıtım Günleri İçin Tıklayınız.
https://universitem.hacettepe.edu.tr/hayatin-butun-renkleri-burada-2/
...and so on.

How do I add an <a> tag attribute to a docusign html document

This is surely a simple issue. This is what I want. To add an a tag to my html document for docusign such that when a user clicks it, they are routed to the link page.
I have done some research on the docusign api docs and indeed the a tag and href attribute are supported in the api.
Here is my code for creating the html document
1function document1(data) {
2 // Data for this method
3 // args.signerEmail
4 // args.signerName
5 // args.ccEmail
6 // args.ccName
7
8 return `
9 <!DOCTYPE html>
10 <html>
11 <head>
12 <meta charset="UTF-8">
13 </head>
14 <body style="font-family:sans-serif;margin-left:2em;">
15 <h1 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
16 color: darkblue;margin-bottom: 0;">THE JANE GOODALL INSTITUTE</h1>
17 <h2 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
18 margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
19 color: darkblue;">Chimpanzee Habitat Improvement Audit</h2>
20 <h4>Ordered by ${data.initiatorName}</h4>
21 <p style="margin-top:0em; margin-bottom:0em;">Email: ${data.initiatorEmail}</p>
22 Below is a snapshot of the current map and changes made to it by 23${data.initiatorName}.
24 </p>
25 <p style="margin-top:0em; margin-bottom:0em;">If you wish to make changes to the map
26 follow this link but if you are okay with it
pleasesign
27and agree</p>
28 <!-- Note the anchor tag for the signature field is in white. -->
29 <h3 style="margin-top:3em;">Agreed: <span 30style="color:white;">**signature_1**/</span></h3>
31 </body>
32 </html>`;
33}
As you can see on line 26 I am using the a tag as I normally would use it in traditional html. Is there anything I am doing wrong?? Any suggesstions will be greatly appreciated.
It is usually better to include ancillary documents in the envelope itself. They can be included as supplemental documents that are available but not visible by default.
If you still want a link, you can add a link tab via the Envelopes:create API call (not via the HTML).
Live example of a link tab
What you can do is create anchor text in the HTML. The anchor text will later be used for positioning the tab. Make the anchor text white so it is not visible on the screen. Example of the HTML:
<span color="white">/linkAnchor/</span>
Then the JSON in the Envelopes:create request
The tabLabel must start with #HREF_
"textTabs": [
{
"anchorString": "/linkAnchor/",
"underline": "true",
"fontColor": "BrightBlue",
"fontSize": "Size12",
"locked": "true",
"value": "Link text", // link text
"required": "true",
"tabLabel": "#HREF_ExampleLink",
"name": "https://www.docusign.com" // link URL
}
]

Compiling Bootstrap 3 in a Symfony 2 project on Windows

I have been trying for some time now to compile Bootstrap 3 in a Symfony 2 project on Windows. But I can't get it to work. My primary objective is to compile my very own LESS file. I called it "styles.less". In there, I want to be able to use bootstrap mixins like "make-xs-column" for example. So I need to import bootstrap.less for that.
Here is what I did so far:
In my composer.json, I added the bootstrap bundle:
{
...
"require": {
...
"twitter/bootstrap": "v3.0.3"
},
....
}
Since I want to use Bootstrap 3, I cannot use the lessphp filter, so I use the less filter instead. For that, I had to install nodejs, and then less (by running the command "npm install less -g"). Finally, I modified my config.yml like so:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ JoePersonalWebSiteBundle ]
filters:
cssrewrite: ~
less:
node: "C:\\dev\\nodejs\\lessc.cmd"
node_paths:
- "C:\\dev\\nodejs\\node_modules"
apply_to: "\.less$"
Now, in my layout.html.twig, I added the following:
{% stylesheets filter='less' '#JoePersonalWebSiteBundle/Resources/less/styles.less' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}
And in my "styles.less" file, I import"bootstrap.less" like so:
#import '../../../../../../vendor/twitter/bootstrap/less/bootstrap.less';
But I always get an error. In fact, even if my "styles.less" file is completely empty, I always get an error like this one:
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
"C:\dev\nodejs\lessc.cmd" "C:\Users\joe\AppData\Local\Temp\assDE7E.tmp"
Error Output:
[31mParseError: missing opening `{`[39m[31m in [39mC:\Users\joe\AppData\Local\Temp\assDE7E.tmp[90m on line 17, column 1:[39m
[90m16 });[39m
17 [0m[0m
[1] Assetic\Exception\FilterException: An error occurred while running:
"C:\dev\nodejs\lessc.cmd" "C:\Users\joe\AppData\Local\Temp\assDE7E.tmp"
Error Output:
[31mParseError: missing opening `{`[39m[31m in [39mC:\Users\joe\AppData\Local\Temp\assDE7E.tmp[90m on line 17, column 1:[39m
[90m16 });[39m
17 [0m[0m
I tried to create my own recess filter to use that instead of less (based on the work by boteeka found here). But that didn't work either. The less files never compile. Even an empty one, or a simple one.
Could someone please point me in the right direction? Is it possible on Windows, to compile Bootstrap 3 in a Symfony 2 project? If so, can someone give me the exact steps I should follow?
I use lessphp in windows with Bootstrap v3.0.0. The original idea is from http://mossco.co.uk/symfony-2/symfony-2-and-bootstrap-3-assetic-config-and-base-html-template-file/
I have also added to the entries for the fonts, icons.
My composer.json
"require": {
"components/jquery": "dev-master",
"leafo/lessphp": "v0.4.0",
"twbs/bootstrap": "v3.0.0",
},
For the config.yml copy 'cssembed' and 'yuicompressor' to '%kernel.root_dir%/Resources'
/java/
My config.yml
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
java: C:\Program Files\Java\jre7\bin\java.exe
filters:
cssrewrite: ~
cssembed:
jar: %kernel.root_dir%/Resources/java/cssembed-0.4.5.jar
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
assets:
jquery_js:
inputs:
- "%kernel.root_dir%/../components/jquery/jquery.min.js"
filters: [?yui_js]
bootstrap_js:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/transition.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/alert.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/modal.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/dropdown.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/scrollspy.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/tab.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/tooltip.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/popover.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/button.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/collapse.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/carousel.js"
- "%kernel.root_dir%/../vendor/twbs/bootstrap/js/affix.js"
filters: [?yui_js]
bootstrap_less:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/less/bootstrap.less"
filters: [lessphp, cssembed]
fonts_glyphicons_eot:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.eot"
output: "fonts/glyphicons-halflings-regular.eot"
fonts_glyphicons_svg:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.svg"
output: "fonts/glyphicons-halflings-regular.svg"
fonts_glyphicons_ttf:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.ttf"
output: "fonts/glyphicons-halflings-regular.ttf"
fonts_glyphicons_woff:
inputs:
- "%kernel.root_dir%/../vendor/twbs/bootstrap/fonts/glyphicons-halflings-regular.woff"
output: "fonts/glyphicons-halflings-regular.woff"
And here my base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}
{% stylesheets '#bootstrap_less' combine=true %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet">
{% endstylesheets %}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}{% endblock %}
{% block javascripts %}
{% javascripts '#jquery_js' '#bootstrap_js' filter='?yui_js' combine=true %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
</body>
</html>
Somehow cssembed unnecessary or does not function properly and can be removed with this solution!

translation cannot work with symfony2.1

have a problem with translation is Symfony2.1
I tried almost all methods provided in the symfony_book but, only the translation from english to frensh that works, the reverse doesn't work
here is my routing.yml
_acceuil:
pattern: /{_locale}/acceuil/
defaults: { _controller: gestionConferenceApplicationBundle:acceuil:acceuil, _locale: en }
requirements:
_locale: en|fr|de
is my layout page I have thoses to links that allaw to switch between langage:
<a style="padding-top: -10px;" href="{{ path('_acceuil', {'_locale': 'fr' }) }}" >FRANCAIS</a>
<a style="padding-top: -10px;" href="{{ path('_acceuil', {'_locale': 'en' }) }}" >ANGLAIS</a>
and this line for test
{{ 'welcome in my site'|trans }}
and here is my messages.fr.xlf
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>welcome in my site</source>
<target>bienvenue dans mon site</target>
</trans-unit>
</body>
</file>
</xliff>
and here is my messages.en.xlf
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="fr" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>bienvenue dans mon site</source>
<target>welcome in my site</target>
</trans-unit>
</body>
</file>
</xliff>
and here is the part wwe are interested in my config.yml :
framework:
#esi: ~
translator: { fallback: en }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: "%kernel.debug%"
form: true
csrf_protection: true
validation: { enable_annotations: true }
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
default_locale: en
trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
session: ~
and when I run I have always :
bienvenue dans mon site
how can I achieve that
thank you in advance
I know why your translations don't work.
Because the translation source is still this same. It's string from your template.
So ex:
{{'My Trans'|trans()}}
messages catalogues shoudl look like this fr:
'My Trans': 'My trans FR'
and the en trans:
'My Trans': 'My trans EN'
I hope this example will help you.

how can I get a unknown length string from a webpage

I need to get a string in perl whose length is varying each day. Look at the URL content below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /isos/preFCS5.3/LATESTGOODCVP</title>
</head>
<body>
<h1>Index of /isos/preFCS5.3/LATESTGOODCVP</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th>Name</th><th>Last modified</th><th>Size</th><th>Description</th></tr><tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td>Parent Directory</td><td> </td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td>CVP-LATEST-5.3.0.37.iso</td><td align="right">19-Jul-2011 03:32 </td><td align="right">816M</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td>ChangeLog-LATEST.2011-07-19-03h.30m.01s</td><td align="right">19-Jul-2011 03:32 </td><td align="right"> 16K</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td>is.iso</td><td align="right">19-Jul-2011 03:32 </td><td align="right">816M</td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[ ]"></td><td>md5SUM</td><td align="right">19-Jul-2011 03:32 </td><td align="right">111 </td></tr>
<tr><th colspan="5"><hr></th></tr>
</table>
<address>Apache/2.2.3 (Red Hat) Server at www.google.com Port 80</address>
</body></html>
You can see a string named "CVP-LATEST-5.3.0.37.iso".
I need to get that into $name.
the string CVP-LATEST-5.3.0.37.iso will keep on changing everyday
say CVP-LATEST-5.3.0.39.iso or CVP-LATEST-5.3.39a.iso or to CVP-LATEST-6.1.iso or CVP-LATEST-6.23.23.112.iso.
Is there any way I can get this ?
Here is the code
use strict;
use warnings;
use LWP::Simple;
my $oldVersion = CVP-LATEST-5.3.0.37.iso;
my $url = 'http://www.google.com/isos/preFCS5.3/LATESTGOODCVP/';
my $newPage = get($url)
or die "Cannot retrieve contents from $url\n";
if ( $newPage =~ /href=\"CVP-LATEST-5\.3\.0\.(\d\d)/ ) {
my $version = $1;
if ( $version != $oldVersion ) {
my $status = getstore($url . "CVP-LATEST-5.3.0.$version.iso",
"CVP-LATEST-5.3.0.$version.iso");
} else {
print "Already at most recent version\n";
}
} else {
die "Cannot find version tag in contents from $url\n";
}
Here if you see the code its getting only the number(xx) after 5.3.0."XX" and is of known length that is 2.
Is there anyway I can change it so that it will read the whole filename ie. CVP-LATEST-XXXXXX*.iso and then compare it with the $oldversion ?
Please note the string "CVP-LATEST-" and ".iso" remains constant, but later numbers change and can also contain alphabets.
Also note that there is one more file called is.iso in the URL content. I don't want to get that.
You should use a module that knows how to parse HTML when you want to parse HTML.
Your Question is Asked Frequently:
perldoc -q url
How do I extract URLs?
use HTML::SimpleLinkExtor;
...
my $extor = HTML::SimpleLinkExtor->new();
$extor->parse($newPage);
my($version) = grep /^CVP-LATEST-.*\.iso/, $extor->href;
Try
if ( $newPage =~ /href=\"CVP-LATEST-(.*?)\.iso\"/ ) {
my $name = "CVP-LATEST-${1}.iso";
$name contains the whole filename.
the secret to html regexes , not doublequote
/href="([^"]*)"/i

Resources