relative-path

Regex to replace relative link with root relative link

a 夏天 提交于 2019-12-04 17:42:55
I have a string of text that contains html with all different types of links (relative, absolute, root-relative). I need a regex that can be executed by PHP's preg_replace to replace all relative links with root-relative links, without touching any of the other links. I have the root path already. Replaced links: <tag ... href="path/to_file.ext" ... > ---> <tag ... href="/basepath/path/to_file.ext" ... > <tag ... href="path/to_file.ext" ... /> ---> <tag ... href="/basepath/path/to_file.ext" ... /> Untouched links: <tag ... href="/any/path" ... > <tag ... href="/any/path" ... /> <tag ... href=

CherryPy configuration tools.staticdir.root problem

随声附和 提交于 2019-12-04 17:02:29
How can I make my static-file root directories relative to my application root folder (instead of a hard-coded path)? In accordance with CP instructions ( http://www.cherrypy.org/wiki/StaticContent ) I have tried the following in my configuration file: tree.cpapp = cherrypy.Application(cpapp.Root()) tools.staticdir.root = cpapp.current_dir but when I run cherrpy.quickstart(rootclass, script_name='/', config=config_file) I get the following error builtins.ValueError: ("Config error in section: 'global', option: 'tree.cpapp', value: 'cherrypy.Application(cpapp.Root())'. Config values must be

How to convert absolute path to relative in c linux

半腔热情 提交于 2019-12-04 16:55:54
I would like to know how an absolute path of a symbolic link can be converted to relative based on a given directory (that includes the linked file) in c language on linux (Ubuntu) OS. I thought searching for the sub-string of the relative path, but what if it already exists higher in the folder's hierarchy? Here is a more specific description of what I want to do: Relative path: folder/folder1/folder2 Absolut path: /home/giorgos/Desktop/folder/folder1/folder2/a.pdf changed to /home/giorgos/Desktop/myfolder/folder1/folder2/a.pdf Obviously I cant' simply search for and replace "folder/",

How to make xcodeproj file relative in Xcode 4.5

亡梦爱人 提交于 2019-12-04 16:50:00
I was following this tutorial and stumbled across this screen shot: apparently there was a way to make the Xcode project file relative to some user defined env variable in earlier versions of Xcode (you get there by highlighting the project file then clicking cmd + i ) I couldn't find a way to this in Xcode 4.5 (the closest I could get to that was this post, but the instructions don't work on Xcode 4.5) ideas? update : I tried the idea of changing the 'header search paths' under build settings.. and setting 'always search user paths' to 'yes' as suggested here .. but then my project always

Flask: serve assets without leading slash using url_for

醉酒当歌 提交于 2019-12-04 14:48:12
问题 I'm working on a Flask app that uses url_for to specify the route to some static assets (js, css, etc). Here's an example from one of the templates: <script src='{{ url_for('static', filename='js/search.js') }}'></script> When this gets rendered into html, the path looks like this: <script src='/static/js/search.js'></script> Is it possible to modify this behavior such that the leading slash is dropped from the rendered script path? The goal is to render the following: <script src='static/js

CSS Background URL

China☆狼群 提交于 2019-12-04 14:32:41
问题 Can someone help explain how exactly the CSS URL for a background image works? How exactly does the CSS know where to start looking up the URL? for example I have these 3 URLs #web_content{ background: URL(images/background.jpg); } #web_content{ background: URL(/images/background.jpg); } #web_content{ background: URL(localhost:1234/newWebSite/images/background.jpg); } I tried all 3 of these on different PCs. Using the same web browser that are the same versions and everything. Basically all

Thymeleaf URL expression in .css file

让人想犯罪 __ 提交于 2019-12-04 14:00:37
I'm using Spring MVC and the Thymeleaf view engine. I have an external style.css file with the CSS for my page. In the CSS file, I want to refer to a relative image URL. This is my style.css file: .background { width: 100%; background-image: url('/path/to/image/bg.png'); } The above tries to access an image with the following URL, which doesn't exist: http://localhost/path/to/image/bg.png My real image is at: http://localhost/myapp/path/to/image/bg.png This StackOverflow question gives the answer to my question for inline CSS: How to set background url for css files in thymeleaf? But how do I

How to set relative path to Images directory inside C# project?

冷暖自知 提交于 2019-12-04 13:00:00
I am working on C# project i need to get the images from Images directory using relative path. I have tried var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Images\logo.png"; var logoImage = new LinkedResource(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)+@"\Images\logo.png") But no luck with these... I have made the images to be copied to output directory when the program is running but it doesn't pickup those images. If you are using LinkedResource() in C# it is most likely not to pickup your relative URI or the file location. You can use some extra

Relative path for the Subreport

主宰稳场 提交于 2019-12-04 10:08:57
I'm working with iReport 3.5.0, and I'm using a subreport inside my main report. I don't want to give the absolute path for the subreport expression, but for example if I just give "bpSubReport.jasper" as the subreport expression (because sub and main are in the same directory), then iReport can find bpSubReport.jasper and compile the main report into bPReport.jasper, but my Java (gwt) application can't. It throws the exception net.sf.jasperreports.engine.JRException: Could not load object from location : bpSubReport.jasper Can you help me on how to give a relative path for the subreport and

XAMPP relative urls not working correctly

流过昼夜 提交于 2019-12-04 09:33:36
on http://www.exampleSite.com/aPage.php , the following image loads correctly <img src="/images/sidenav/analysis-2.gif" /> but at http://localhost/exampleSite/aPage.php , it tries to get localhost/images/... instead of localhost/exampleSite/images/... My file structure is: C:\xampp\htdocs\exampleSite\ I have had this problem across multiple projects, and have previously resorted to absolute URLs, but now I am just trying to make some quick updates on a page, and I cannot view it correctly on my localhost. If you don't want to mess up with the src attributes throughout your website, you may