Changeset 99951bf


Ignore:
Timestamp:
Dec 4, 2005 1:55:27 PM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5faca98
Parents:
024b1a0
git-author:
polecat <polecat> (12/04/05 13:55:27)
git-committer:
zzz <zzz@…> (12/04/05 13:55:27)
Message:

Adding a schema for [link] to handle if you want to display links directly to your attachments within the context of the blog itself. Some redundant code here (3 files modified with cut & paste) so we may want to further abstract the External links: HTML generation code.

Location:
apps/syndie
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java

    r024b1a0 r99951bf  
    8888            for (int i = 0; i < _links.size(); i++) {
    8989                Link l = (Link)_links.get(i);
    90                 _postBodyBuffer.append("<a ").append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
    91                 if (l.schema != null)
    92                     _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
    93                 if (l.location != null)
    94                     _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
    95                 _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     90                String schema = l.schema;
     91                _postBodyBuffer.append("<p>Schema: ").append(schema).append("</p>");
     92                _postBodyBuffer.append("<a ");
     93                if(schema.equals("attachment")) {
     94                    /* No need for externallink double checker */
     95                    int ID = Integer.parseInt(l.location);
     96                    _postBodyBuffer.append("href=\"").append(getAttachmentURL(ID));
     97                    _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     98                } else {
     99                    _postBodyBuffer.append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
     100                    if (l.schema != null)
     101                            _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
     102                    if (l.location != null)
     103                            _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
     104                    _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     105                }
     106
    96107                _postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
    97108            }
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java

    r024b1a0 r99951bf  
    437437        if (!continueBody()) { return; }
    438438        if ( (schema == null) || (location == null) ) return;
    439         _bodyBuffer.append("<a ").append(getClass("externalLink")).append(" href=\"externallink.jsp?schema=");
    440         _bodyBuffer.append(sanitizeURL(schema)).append("&location=");
    441         _bodyBuffer.append(sanitizeURL(location)).append("&description=");
    442         _bodyBuffer.append(sanitizeURL(text)).append("\">").append(sanitizeString(text)).append("</a>");
     439        _bodyBuffer.append("<a ");
     440        if ( schema.equals("attachment") ) {
     441                int attachmentID = Integer.parseInt(location);
     442                _bodyBuffer.append("href=\"").
     443                        append(getAttachmentURL(attachmentID));
     444        } else {
     445                _bodyBuffer.append(getClass("externalLink")).append(" href=\"externallink.jsp?schema=");
     446                _bodyBuffer.append(sanitizeURL(schema)).append("&location=");
     447                _bodyBuffer.append(sanitizeURL(location)).append("&description=");
     448                _bodyBuffer.append(sanitizeURL(text));
     449        }
     450        _bodyBuffer.append("\">").
     451                    append(sanitizeString(text)).
     452                    append("</a>");
    443453    }
    444454
     
    640650                for (int i = 0; i < _links.size(); i++) {
    641651                    Link l = (Link)_links.get(i);
    642                     _postBodyBuffer.append("<a ").append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
    643                     if (l.schema != null)
    644                         _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
    645                     if (l.location != null)
    646                         _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
    647                     _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     652                    String schema = l.schema;
     653                    _postBodyBuffer.append("<a ");
     654                    if(schema.equals("attachment")) {
     655                            /* No need for externallink double checker */
     656                            int ID = Integer.parseInt(l.location);
     657                            _postBodyBuffer.append(" href=\"").append(getAttachmentURL(ID));
     658                            _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     659                    } else {
     660                            _postBodyBuffer.append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
     661                            if (l.schema != null)
     662                                _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
     663                            if (l.location != null)
     664                                _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
     665                            _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     666                    }
    648667                    _postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
    649668                }
  • apps/syndie/java/src/net/i2p/syndie/sml/ThreadedHTMLRenderer.java

    r024b1a0 r99951bf  
    406406            for (int i = 0; i < _links.size(); i++) {
    407407                Link l = (Link)_links.get(i);
    408                 _postBodyBuffer.append("<a ").append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
    409                 if (l.schema != null)
    410                     _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
    411                 if (l.location != null)
    412                     _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
    413                 _postBodyBuffer.append("\">").append(sanitizeString(l.location, 60));
     408                String schema = l.schema;
     409                    _postBodyBuffer.append("<a ");
     410                    if(schema.equals("attachment")) {
     411                            /* No need for externallink double checker */
     412                            int ID = Integer.parseInt(l.location);
     413                            _postBodyBuffer.append(" href=\"").append(getAttachmentURL(ID));
     414                            _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     415                    } else {
     416                            _postBodyBuffer.append(getClass("summDetailExternalLink")).append(" href=\"externallink.jsp?");
     417                            if (l.schema != null)
     418                                _postBodyBuffer.append("schema=").append(sanitizeURL(l.schema)).append('&');
     419                            if (l.location != null)
     420                                _postBodyBuffer.append("location=").append(sanitizeURL(l.location)).append('&');
     421                            _postBodyBuffer.append("\">").append(sanitizeString(l.location));
     422                    }
     423
    414424                _postBodyBuffer.append(getSpan("summDetailExternalNet")).append(" (").append(sanitizeString(l.schema)).append(")</span></a> ");
    415425            }
  • apps/syndie/jsp/smlref.jsp

    r024b1a0 r99951bf  
    1818  <li>[quote][/quote] = Quoted text</li>
    1919  <li>[img attachment="1"]alt[/img] = use attachment 1 as an image with 'alt' as the alt text</li>
     20  <li>[link schema="attachment" location="0"]text[/link] = offer a link to one of the attachments in your post (redundant, but useful in context sometimes)
     21  <li>[link schema="eep" location="http://forum.i2p"]text[/link] = offer a link to an external resource (accessible with the given schema)</li>
    2022  <li>[blog name="name" bloghash="base64hash"]description[/blog] = link to all posts in the blog</li>
    2123  <li>[blog name="name" bloghash="base64hash" blogentry="1234"]description[/blog] = link to the specified post in the blog</li>
    2224  <li>[blog name="name" bloghash="base64hash" blogtag="tag"]description[/blog] = link to all posts in the blog with the specified tag</li>
    2325  <li>[blog name="name" blogtag="tag"]description[/blog] = link to all posts in all blogs with the specified tag</li>
    24   <li>[link schema="eep" location="http://forum.i2p"]text[/link] = offer a link to an external resource (accessible with the given schema)</li>
    2526  <li>[archive name="name" description="they have good stuff" schema="eep" location="http://syndiemedia.i2p/archive/archive.txt"]foo![/archive] = offer an easy way to sync up with a new Syndie archive</li>
    2627</ul>
Note: See TracChangeset for help on using the changeset viewer.