File:  [LON-CAPA] / modules / damieng / graphical_editor / loncapa_daxe / web / nodes / lcd_file.dart
Revision 1.1: download - view: text, annotated - select for diffs
Thu Feb 23 21:28:09 2017 UTC (7 years, 3 months ago) by damieng
Branches: MAIN
CVS tags: HEAD
added lcdfile node display to handle LON-CAPA /res absolute path for images

/*
  This file is part of LONCAPA-Daxe.

  LONCAPA-Daxe is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  LONCAPA-Daxe is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Daxe.  If not, see <http://www.gnu.org/licenses/>.
*/

part of loncapa_daxe;

/**
 * Extension of DNFile to handle LON-CAPA absolute paths.
 * Display type: 'lcdfile'.
 */
class LCDFile extends DNFile {
  
  LCDFile.fromRef(x.Element elementRef) : super.fromRef(elementRef) {
  }
  
  LCDFile.fromNode(x.Node node, DaxeNode parent) : super.fromNode(node, parent) {
  }
  
  @override
  String fixSrcPath(List<String> segments, Uri imgUri) {
    // make path relative to the XML file if this is not a /res path
    if (imgUri.path.startsWith('/daxeopen/res/'))
      return imgUri.path.substring('/daxeopen'.length);
    else
      return super.fixSrcPath(segments, imgUri);
  }
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>