The Inbox: HelpSystem-Core-ct.130.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: HelpSystem-Core-ct.130.mcz

commits-2
Christoph Thiede uploaded a new version of HelpSystem-Core to project The Inbox:
http://source.squeak.org/inbox/HelpSystem-Core-ct.130.mcz

==================== Summary ====================

Name: HelpSystem-Core-ct.130
Author: ct
Time: 2 March 2020, 10:39:50.205949 am
UUID: b3afc4b5-ac91-4042-9f09-5576de307df8
Ancestors: HelpSystem-Core-mt.119

Small refactoring of HtmlHelpTopic (apply Guard Clause idiom and add proper #key implementation)

=============== Diff against HelpSystem-Core-mt.119 ===============

Item was added:
+ ----- Method: HtmlHelpTopic>>key (in category 'accessing') -----
+ key
+
+ ^ self url!

Item was changed:
  ----- Method: HtmlHelpTopic>>subtopicUrls (in category 'accessing') -----
  subtopicUrls
 
+ | urls start end endGuard |
+ subtopicUrls ifNotNil: [^ subtopicUrls].
+
+ urls := OrderedCollection new.
- ^ subtopicUrls ifNil: [
- | start end endGuard |
- subtopicUrls := OrderedCollection new.
 
+ start := self document findString: '<a '.
+ start := self document findString: 'href' startingAt: start.
+ [start > 0] whileTrue: [
+ start := self document findString: '"' startingAt: start.
+ end := self document findString: '"' startingAt: start + 1.
+ endGuard := self document findString: '>' startingAt: start + 1.
+ end > 0 ifTrue: [
+ end < endGuard ifTrue: [
+ | nextUrl |
+ nextUrl := self document copyFrom: start + 1 to: end - 1.
+ urls addIfNotPresent: nextUrl].
+ start := self document findString: '<a ' startingAt: end + 1].
+ start > 0 ifTrue: [start := self document findString: 'href' startingAt: start]].
- start := self document findString: '<a '.
- start := self document findString: 'href' startingAt: start.
- [start > 0] whileTrue: [
- start := self document findString: '"' startingAt: start.
- end := self document findString: '"' startingAt: start+1.
- endGuard := self document findString: '>' startingAt: start+1.
- end > 0 ifTrue: [
- end < endGuard
- ifTrue: [subtopicUrls addIfNotPresent: (self document copyFrom: start+1 to: end-1)].
- start := self document findString: '<a ' startingAt: end+1].
- start > 0 ifTrue: [start := self document findString: 'href' startingAt: start]].
 
+ ^ subtopicUrls := urls
+ select: self selectBlock
+ thenCollect: self convertBlock!
- subtopicUrls := subtopicUrls
- select: self selectBlock
- thenCollect: self convertBlock.
- subtopicUrls]!