diff --git a/dev/src/ExercismDev/ExercismManager.extension.st b/dev/src/ExercismDev/ExercismManager.extension.st index 5e9230ff..960dfc1f 100644 --- a/dev/src/ExercismDev/ExercismManager.extension.st +++ b/dev/src/ExercismDev/ExercismManager.extension.st @@ -41,6 +41,44 @@ ExercismManager >> dependencyGraph [ ] +{ #category : #'*ExercismDev' } +ExercismManager >> shareExercisePasteEE: package [ + | source i result | + package = self class legacyExercismPackage + ifTrue: [ self error: 'Select the sub-package with your solution!' ]. + source := String + streamContents: [ :s | + s << '{"description":"test","sections":['. + i := 0. + package solutionSources + keysAndValuesDo: [ :filename :code | + i > 0 + ifTrue: [ s << ', ' ]. + s + << + ('\{"name":"{1}","syntax":"{3}","contents":{2}\}' + format: + {filename. + code asJSON. + ((filename endsWith: '.st') + ifTrue: [ 'smalltalk' ] + ifFalse: [ 'autodetect' ])}). + i := i + 1 ]. + s << ']}' ]. + result := ZnClient new + systemPolicy; + beOneShot; + https; + host: 'api.paste.ee'; + path: '/v1/pastes'; + setBasicAuthenticationUsername: 'ub4sqYh4qD5I1eLrYgn3M19DQza5F6ckpZDmPov2C' + password: ''; + entity: (ZnEntity text: source); + contentType: ZnMimeType applicationJson; + post. + ^ (STONJSON fromString: result) at: 'link' +] + { #category : #'*ExercismDev' } ExercismManager class >> trackActive [ ^true diff --git a/dev/src/ExercismTools/ClassDescription.extension.st b/dev/src/ExercismTools/ClassDescription.extension.st index 12178eec..eb15ee57 100644 --- a/dev/src/ExercismTools/ClassDescription.extension.st +++ b/dev/src/ExercismTools/ClassDescription.extension.st @@ -73,9 +73,10 @@ ClassDescription >> exPrintOutOn: aWriteStream [ nextPutAll: self definition; nextPut: $.; cr; cr. - aWriteStream nextPut: $". - self comment trimBoth encodeDoublingDoubleQuotesOn: aWriteStream. - aWriteStream nextPut: $"; cr; cr. + self hasComment ifTrue: [ + aWriteStream nextPut: $". + self comment trimBoth encodeDoublingDoubleQuotesOn: aWriteStream. + aWriteStream nextPut: $"; cr; cr ]. self exPrintOutCategoriesFor: self class on: aWriteStream. self exPrintOutCategoriesFor: self on: aWriteStream diff --git a/dev/src/ExercismTools/ClyExercismFetchCommand.class.st b/dev/src/ExercismTools/ClyExercismFetchCommand.class.st index 0960654b..cdc9d85d 100644 --- a/dev/src/ExercismTools/ClyExercismFetchCommand.class.st +++ b/dev/src/ExercismTools/ClyExercismFetchCommand.class.st @@ -46,7 +46,7 @@ ClyExercismFetchCommand >> defaultMenuItemName [ { #category : #accessing } ClyExercismFetchCommand >> description [ - ^'Fetch a named exercise to begin solving it' + ^'Fetch a named Exercism exercise to begin solving it' ] { #category : #execution } diff --git a/dev/src/ExercismTools/ClyExercismProgressCommand.class.st b/dev/src/ExercismTools/ClyExercismProgressCommand.class.st index b64526da..9f86f1f5 100644 --- a/dev/src/ExercismTools/ClyExercismProgressCommand.class.st +++ b/dev/src/ExercismTools/ClyExercismProgressCommand.class.st @@ -40,7 +40,7 @@ ClyExercismProgressCommand >> defaultMenuItemName [ { #category : #accessing } ClyExercismProgressCommand >> description [ - ^'Open track progress in a web browser' + ^'Open your Exercism track progress in a web browser' ] { #category : #execution } diff --git a/dev/src/ExercismTools/ClyExercismShareCommand.class.st b/dev/src/ExercismTools/ClyExercismShareCommand.class.st index 91cb281f..a5ce0c44 100644 --- a/dev/src/ExercismTools/ClyExercismShareCommand.class.st +++ b/dev/src/ExercismTools/ClyExercismShareCommand.class.st @@ -1,6 +1,9 @@ Class { #name : #ClyExercismShareCommand, #superclass : #ClyExercismExerciseCommand, + #classVars : [ + 'hasConfirmedSharing' + ], #category : #'ExercismTools-Menus' } @@ -9,6 +12,28 @@ ClyExercismShareCommand class >> contextMenuOrder [ ^15 ] +{ #category : #accessing } +ClyExercismShareCommand class >> hasConfirmedSharing [ + ^ hasConfirmedSharing ifNil: [ false ] +] + +{ #category : #accessing } +ClyExercismShareCommand class >> hasConfirmedSharing: aBoolean [ + ^hasConfirmedSharing := aBoolean +] + +{ #category : #internal } +ClyExercismShareCommand >> confirmSharing [ + self class hasConfirmedSharing + ifTrue: [ ^ true ]. + + ^ (UIManager default + proceed: + 'Please confirm you are happy to anonymously store your exercise code, on a temporary (7 day) random url at dpaste.com.\Exercism and Pharo.org are not associated with this service, it is provided as a convenience to help users\more easily discuss ideas with a wider community.' withCRs) + ifTrue: [ self class hasConfirmedSharing: true ] + ifFalse: [ false ] +] + { #category : #accessing } ClyExercismShareCommand >> defaultMenuIconName [ ^#publish @@ -16,12 +41,12 @@ ClyExercismShareCommand >> defaultMenuIconName [ { #category : #accessing } ClyExercismShareCommand >> defaultMenuItemName [ - ^'Share on web' + ^'Share on web...' ] { #category : #accessing } ClyExercismShareCommand >> description [ - ^'Share your proposed solution on the web to discuss with others' + ^'Create a web link to anonymously share your proposed solution on dpaste.com to discuss with others' ] { #category : #execution } @@ -29,7 +54,7 @@ ClyExercismShareCommand >> execute [ | exerciseName result url | exerciseName := self selectedItem exerciseName. - + self confirmSharing ifTrue: [ [ UIManager default informUser: 'Sharing...' during: [ @@ -49,5 +74,5 @@ ClyExercismShareCommand >> execute [ ] ] on: ExercismError - do: [ :ex | self reportError: ex for: nil ] + do: [ :ex | self reportError: ex for: nil ] ] ] diff --git a/dev/src/ExercismTools/ExercismManager.class.st b/dev/src/ExercismTools/ExercismManager.class.st index 93e5e703..d1765c99 100644 --- a/dev/src/ExercismTools/ExercismManager.class.st +++ b/dev/src/ExercismTools/ExercismManager.class.st @@ -162,44 +162,6 @@ ExercismManager >> shareExerciseDPaste: exercise [ post ] -{ #category : #exercism } -ExercismManager >> shareExercisePasteEE: package [ - | source i result | - package = self class legacyExercismPackage - ifTrue: [ self error: 'Select the sub-package with your solution!' ]. - source := String - streamContents: [ :s | - s << '{"description":"test","sections":['. - i := 0. - package solutionSources - keysAndValuesDo: [ :filename :code | - i > 0 - ifTrue: [ s << ', ' ]. - s - << - ('\{"name":"{1}","syntax":"{3}","contents":{2}\}' - format: - {filename. - code asJSON. - ((filename endsWith: '.st') - ifTrue: [ 'smalltalk' ] - ifFalse: [ 'autodetect' ])}). - i := i + 1 ]. - s << ']}' ]. - result := ZnClient new - systemPolicy; - beOneShot; - https; - host: 'api.paste.ee'; - path: '/v1/pastes'; - setBasicAuthenticationUsername: 'ub4sqYh4qD5I1eLrYgn3M19DQza5F6ckpZDmPov2C' - password: ''; - entity: (ZnEntity text: source); - contentType: ZnMimeType applicationJson; - post. - ^ (STONJSON fromString: result) at: 'link' -] - { #category : #exercism } ExercismManager >> shareExerciseStfx: package [ | source | diff --git a/dev/src/ExercismTools/RPackage.extension.st b/dev/src/ExercismTools/RPackage.extension.st index ea9d5820..b3fb32a5 100644 --- a/dev/src/ExercismTools/RPackage.extension.st +++ b/dev/src/ExercismTools/RPackage.extension.st @@ -18,7 +18,7 @@ RPackage >> exPrintOutExtensionsFor: aClass on: aWriteStream [ { #category : #'*ExercismTools' } RPackage >> exerciseName [ - ^ (name allRegexMatches: '\w+') last + ^ (self name allRegexMatches: '\w+') last ] { #category : #'*ExercismTools' } diff --git a/dev/src/ExercismTools/RPackageTag.extension.st b/dev/src/ExercismTools/RPackageTag.extension.st index 347a4f93..13e234f9 100644 --- a/dev/src/ExercismTools/RPackageTag.extension.st +++ b/dev/src/ExercismTools/RPackageTag.extension.st @@ -8,7 +8,7 @@ RPackageTag >> definedClasses [ { #category : #'*ExercismTools' } RPackageTag >> exerciseName [ "Provided for legacy compatibility" - ^self name + ^self name asString ] { #category : #'*ExercismTools' }