angelozerr / eclipse-wtp-webresources

Provides completion, hyperlink, hover inside WTP HTML editor for Web Resources (CSS, JS, Images)
Eclipse Public License 1.0
13 stars 9 forks source link

Mark folders as web root folders #37

Closed kaloyan-raev closed 9 years ago

kaloyan-raev commented 9 years ago

Consider the following project structure:

+ project
  + public
    + img
      - myimage.png
  + deep
    + deep
      + deep
        - template.phtml

The template.phtml file is not directly accessible, but via inclusion in another PHP/HTML resource. Therefore any relative paths does not really follow the project tree hierarchy and are marked as validation errors, e.g. <img src="/img/myimage.png" /> will be marked as error.

This situation can be improved by marking a folder in the project (i.e. "public" in the above case) as the web root folder. I am thinking about providing a project property for this. The user can right-click on the project, choose properties, then go to the Web Resources node and browse a folder to specify as Web Root. Then the validator should consider the value of this property.

Is such improvement acceptable? Any other suggestions to resolve the above case?

angelozerr commented 9 years ago

@kaloyan-raev I think it's a good idea. It seems that it's similar issue than https://github.com/angelozerr/eclipse-wtp-webresources/issues/24

Today I'm very busy with tern.java, I will do this issue when I will have time.

MichaelChambers commented 9 years ago

It would be great if we could mark a list of source folders that would each be counted as the root. I'm looking at a project now with the following structure: src/main/resources/static/css, js, etc target/generated-resources/static/css, js, etc These static folders are combined later when deploying. I think I would need both static folders to be marked as web root.

angelozerr commented 9 years ago

I agree @MichaelChambers but I'm very busy for the moment with JSON Editor and Grunt development.

Any contribution are welcome!

kaloyan-raev commented 9 years ago

I am working on this. I will consider @MichaelChambers suggestion.

kaloyan-raev commented 9 years ago

PR #41

kaloyan-raev commented 9 years ago

@MichaelChambers could you update from the snapshot repository and check if this solution works for you? http://oss.opensagres.fr/eclipse-wtp-webresources/0.9.0-SNAPSHOT/

angelozerr commented 9 years ago

@kaloyan-raev I tell me why Web Root Folders Preferences is inside Web Resources -> Validation -> Web Root Folders menu item. This config works too for completion, no? Wyh don't set this menu to Web Resources -> Web Root Folders ?

nitind commented 9 years ago

Isn't this what the Deployment Assembly property page already does and then surfaces through the ModuleCore APIs?

angelozerr commented 9 years ago

@nitind I'm sorry I don't understand what you mean?

kaloyan-raev commented 9 years ago

@angelozerr No, currently web root folder are not considered for completion - just for validation. I had only the validation in my mind and did not thought about the completion. Therefore, I placed the new property page under the Web Resource > Validation one. When completion starts considering web root folders, I agree the page should me moved directly under Web Resources.

The Deployment Assembly page that @nitind mentioned is used in the WTP Java EE Tools. Here is screenshot: image It provides mapping between project structure and deployment package structure. However, there some issues to use it to resolve the problem targeted by this issue:

  1. There is no guarantee that the deployment package will be deployed in the web server's root. Of course, such assumption can be made, but it might be wrong. Whereas in the Web Root Folders property page, the user explicitly declares such intention.
  2. In the case of PHP, there is no such clear deployment strategy like in Java EE, where it is defined by a specification. Very often PHP projects are not deployed, but just uploaded to the server. Perhaps, this may be the reason that PDT was not integrated with the WTP Module Core framework.
angelozerr commented 9 years ago

Many thanks for your information.

It should be cool if completion could use your preferences.

anubas commented 9 years ago

This works perfectly. Thanks!