From 1f179bc96b66e9f7231a3ca9f3e5d379406c1669 Mon Sep 17 00:00:00 2001 From: mazevedo Date: Wed, 25 Jan 2023 11:31:24 -0300 Subject: [PATCH 01/17] Add readonly option to codemirror setup --- Wikipedia/Code/CodemirrorSetupUserScript.swift | 4 ++-- Wikipedia/Code/SectionEditorViewController.swift | 4 ++-- Wikipedia/assets/codemirror/codemirror-index.html | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Wikipedia/Code/CodemirrorSetupUserScript.swift b/Wikipedia/Code/CodemirrorSetupUserScript.swift index a0020d6c4a8..b677ded1ace 100644 --- a/Wikipedia/Code/CodemirrorSetupUserScript.swift +++ b/Wikipedia/Code/CodemirrorSetupUserScript.swift @@ -9,10 +9,10 @@ class CodemirrorSetupUserScript: PageUserScript, WKScriptMessageHandler { let messageHandlerName = "wmfCodemirrorReady" let completion: () -> Void - init(languageCode: String, direction: CodemirrorDirection, theme: Theme, textSizeAdjustment: Int, isSyntaxHighlighted: Bool, completion: @escaping () -> Void) { + init(languageCode: String, direction: CodemirrorDirection, theme: Theme, textSizeAdjustment: Int, isSyntaxHighlighted: Bool, readOnly: Bool, completion: @escaping () -> Void) { self.completion = completion let source = """ - wmf.setup('\(languageCode)', '\(direction.rawValue)', '\(theme.webName)', \(textSizeAdjustment), \(isSyntaxHighlighted), () => { + wmf.setup('\(languageCode)', '\(direction.rawValue)', '\(theme.webName)', \(textSizeAdjustment), \(isSyntaxHighlighted), \(readOnly), () => { window.webkit.messageHandlers.\(messageHandlerName).postMessage({}) }) """ diff --git a/Wikipedia/Code/SectionEditorViewController.swift b/Wikipedia/Code/SectionEditorViewController.swift index 54c3477c09a..139fba6a1cd 100644 --- a/Wikipedia/Code/SectionEditorViewController.swift +++ b/Wikipedia/Code/SectionEditorViewController.swift @@ -41,7 +41,6 @@ class SectionEditorViewController: ViewController { private var needsSelectLastSelection: Bool = false @objc var editFunnel = EditFunnel.shared - private var isInFindReplaceActionSheetMode = false @@ -185,7 +184,8 @@ class SectionEditorViewController: ViewController { let contentLanguageCode: String = articleURL.wmf_contentLanguageCode ?? dataStore.languageLinkController.preferredLanguageVariantCode(forLanguageCode: languageCode) ?? languageCode let layoutDirection = MWKLanguageLinkController.layoutDirection(forContentLanguageCode: contentLanguageCode) let isSyntaxHighlighted = UserDefaults.standard.wmf_IsSyntaxHighlightingEnabled - let setupUserScript = CodemirrorSetupUserScript(languageCode: languageCode, direction: CodemirrorSetupUserScript.CodemirrorDirection(rawValue: layoutDirection) ?? .ltr, theme: theme, textSizeAdjustment: textSizeAdjustment, isSyntaxHighlighted: isSyntaxHighlighted) { [weak self] in + + let setupUserScript = CodemirrorSetupUserScript(languageCode: languageCode, direction: CodemirrorSetupUserScript.CodemirrorDirection(rawValue: layoutDirection) ?? .ltr, theme: theme, textSizeAdjustment: textSizeAdjustment, isSyntaxHighlighted: isSyntaxHighlighted, readOnly: false) { [weak self] in self?.isCodemirrorReady = true } diff --git a/Wikipedia/assets/codemirror/codemirror-index.html b/Wikipedia/assets/codemirror/codemirror-index.html index 5aa16f3db35..8200de7afa4 100644 --- a/Wikipedia/assets/codemirror/codemirror-index.html +++ b/Wikipedia/assets/codemirror/codemirror-index.html @@ -429,12 +429,13 @@ } } - const setupCodemirror = (language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, callback) => { + const setupCodemirror = (language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, readOnly, callback) => { applyTheme(themeName) if (!isSyntaxHighlighted) { toggleSyntaxColors() } scaleBodyText(textSizeAdjustment) + let xhr = new XMLHttpRequest() let url = `config/codemirror-config-${language}.json` xhr.open('GET', url, true) @@ -452,6 +453,7 @@ }, inputStyle: 'contenteditable', direction: direction, + readOnly: setupReadOnly(readOnly), autocorrect: true, autocapitalize: true, spellcheck: false, @@ -462,6 +464,12 @@ }; xhr.send() } + + const setupReadOnly = (readOnly) => { + if (readOnly) { + return "nocursor" + } + } const wrapSelectionWith = (openingMarkup, closingMarkup) => { if (closingMarkup === undefined) { @@ -883,7 +891,7 @@ completion() }) } - wmf.setup = (language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, callback) => setupCodemirror(language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, callback) + wmf.setup = (language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, readOnly, callback) => setupCodemirror(language, direction, themeName, textSizeAdjustment, isSyntaxHighlighted, readOnly, callback) wmf.applyTheme = (themeName) => applyTheme(themeName) wmf.highlightAndScrollToWikitextForSelectedAndAdjacentText = highlightAndScrollToWikitextForSelectedAndAdjacentText From 505e5fd5207f88c21206955fd25bbb2caa362487 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 16:57:08 -0600 Subject: [PATCH 02/17] Prepare panels for displaying blocked errors - Allow subheadingHTML to display links - Fix safe area extended bug - Add BlockedPanelViewController --- Wikipedia/Code/Panels.swift | 59 ++++++++++++ .../Code/ScrollableEducationPanelView.xib | 51 +++++----- ...rollableEducationPanelViewController.swift | 89 +++++++++++------- .../error-icon-large.imageset/Contents.json | 12 +++ .../error-icon-large.pdf | Bin 0 -> 3378 bytes 5 files changed, 151 insertions(+), 60 deletions(-) create mode 100644 Wikipedia/Images.xcassets/error-icon-large.imageset/Contents.json create mode 100644 Wikipedia/Images.xcassets/error-icon-large.imageset/error-icon-large.pdf diff --git a/Wikipedia/Code/Panels.swift b/Wikipedia/Code/Panels.swift index b6d7cdea8c1..c06c41dadb9 100644 --- a/Wikipedia/Code/Panels.swift +++ b/Wikipedia/Code/Panels.swift @@ -169,6 +169,38 @@ class EnableReadingListSyncPanelViewController : ScrollableEducationPanelViewCon } } +class BlockedPanelViewController : ScrollableEducationPanelViewController { + + private let messageHtml: String + + init(messageHtml: String, primaryButtonTapHandler: ScrollableEducationPanelButtonTapHandler?, subheadingLinkAction: ((URL) -> Void)?, theme: Theme) { + self.messageHtml = messageHtml + super.init(showCloseButton: true, primaryButtonTapHandler: primaryButtonTapHandler, secondaryButtonTapHandler: nil, traceableDismissHandler: nil, theme: theme) + self.subheadingLinkAction = subheadingLinkAction + } + + required public init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + image = UIImage(named: "error-icon-large") + subheadingHTML = messageHtml + primaryButtonTitle = CommonStrings.okTitle + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + evaluateConstraintsOnNewSize(view.frame.size) + } + + private func evaluateConstraintsOnNewSize(_ size: CGSize) { + width = size.width * 0.9 + } +} + class AddSavedArticlesToReadingListPanelViewController : ScrollableEducationPanelViewController { override func viewDidLoad() { super.viewDidLoad() @@ -472,6 +504,33 @@ extension UIViewController { present(panel, animated: true) } + /// Displays a blocked panel message, for use with fully resolved MediaWiki API blocked errors. + /// - Parameters: + /// - messageHtml: Fully resolved message HTML to display + /// - linkBaseURL: base URL that relative links within messageHtml will reference + /// - currentTitle: Wiki title representing the article the user is currently working against. Used to help resolve relative links against. + /// - theme: initial theme for panel. + func wmf_showBlockedPanel(messageHtml: String, linkBaseURL: URL, currentTitle: String, theme: Theme) { + + let panel = BlockedPanelViewController(messageHtml: messageHtml, primaryButtonTapHandler: { [weak self] sender in + self?.dismiss(animated: true) + }, subheadingLinkAction: { [weak self] url in + + guard let baseURL = linkBaseURL.wmf_URL(withTitle: currentTitle) else { + return + } + + let fullURL = baseURL.resolvingRelativeWikiHref(url.relativeString) + + self?.presentingViewController?.dismiss(animated: true) { + self?.navigate(to: fullURL) + } + + }, theme: theme) + + present(panel, animated: true) + } + func wmf_showReadingListImportSurveyPanel(primaryButtonTapHandler: ScrollableEducationPanelButtonTapHandler?, secondaryButtonTapHandler: ScrollableEducationPanelButtonTapHandler?, footerLinkAction: ((URL) -> Void)?, traceableDismissHandler: ScrollableEducationPanelTraceableDismissHandler?, theme: Theme, languageCode: String) { let panel = ReadingListImportSurveyPanelViewController(primaryButtonTapHandler: { sender in diff --git a/Wikipedia/Code/ScrollableEducationPanelView.xib b/Wikipedia/Code/ScrollableEducationPanelView.xib index 17161f357e3..3d2783aacda 100644 --- a/Wikipedia/Code/ScrollableEducationPanelView.xib +++ b/Wikipedia/Code/ScrollableEducationPanelView.xib @@ -1,9 +1,10 @@ - + - + + @@ -22,9 +23,9 @@ - - - + + + @@ -35,13 +36,13 @@ - + - + - + @@ -60,7 +61,7 @@ - + @@ -69,31 +70,31 @@ - + - + + + + - - - - + + + + - + @@ -144,7 +145,7 @@ - + @@ -199,11 +200,13 @@ + + - + @@ -229,7 +232,7 @@ - + diff --git a/Wikipedia/Code/ScrollableEducationPanelViewController.swift b/Wikipedia/Code/ScrollableEducationPanelViewController.swift index fcef942ee65..2a6ea08e6c6 100644 --- a/Wikipedia/Code/ScrollableEducationPanelViewController.swift +++ b/Wikipedia/Code/ScrollableEducationPanelViewController.swift @@ -42,7 +42,7 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { @IBOutlet fileprivate weak var closeButton: UIButton! @IBOutlet fileprivate weak var imageView: UIImageView! @IBOutlet fileprivate weak var headingLabel: UILabel! - @IBOutlet fileprivate weak var subheadingLabel: UILabel! + @IBOutlet fileprivate weak var subheadingTextView: UITextView! // use as an indication of what triggered a dismissal private var lastAction: LastAction = .none @@ -115,47 +115,24 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { var subheading:String? { get { - return subheadingLabel.text + return subheadingTextView.attributedText.string } set { - subheadingLabel.text = newValue - view.setNeedsLayout() + subheadingHTML = newValue + updateSubheadingHTML() } } var subheadingHTML: String? { didSet { - guard let html = subheadingHTML else { - subheadingLabel.attributedText = nil - return - } - let attributedText = html.byAttributingHTML(with: .subheadline, - boldWeight: .bold, - matching: traitCollection, - color: theme.colors.primaryText, - tagMapping: ["em": "i"], // em tags are generally italicized by default, match this behavior - additionalTagAttributes: [ - "u": [ - NSAttributedString.Key.underlineColor: theme.colors.error, - NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue) - ], - "strong": [ - NSAttributedString.Key.foregroundColor: theme.colors.primaryText - ] - ]) - - var attributes: [NSAttributedString.Key : Any] = [:] - if let subheadingParagraphStyle = subheadingParagraphStyle { - attributes[NSAttributedString.Key.paragraphStyle] = subheadingParagraphStyle - } - attributedText.addAttributes(attributes, range: NSRange(location: 0, length: attributedText.length)) - subheadingLabel.attributedText = attributedText + updateSubheadingHTML() + view.setNeedsLayout() } } - + var subheadingTextAlignment: NSTextAlignment = .center { didSet { - subheadingLabel.textAlignment = subheadingTextAlignment + updateSubheadingHTML() } } @@ -203,13 +180,48 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { } var footerLinkAction: ((URL) -> Void)? = nil + var subheadingLinkAction: ((URL) -> Void)? = nil var subheadingParagraphStyle: NSParagraphStyle? { let pStyle = NSMutableParagraphStyle() pStyle.lineHeightMultiple = 1.2 + pStyle.alignment = subheadingTextAlignment return pStyle.copy() as? NSParagraphStyle } + private func updateSubheadingHTML() { + guard let subheadingHTML = subheadingHTML else { + subheadingTextView.attributedText = nil + return + } + + let attributedText = subheadingHTML.byAttributingHTML(with: .subheadline, + boldWeight: .bold, + matching: traitCollection, + color: theme.colors.primaryText, + handlingLinks: true, + linkColor: theme.colors.link, + tagMapping: ["em": "i"], // em tags are generally italicized by default, match this behavior) + additionalTagAttributes: [ + "u": [ + NSAttributedString.Key.underlineColor: theme.colors.error, + NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue) + ], + "strong": [ + NSAttributedString.Key.foregroundColor: theme.colors.primaryText + ] + ]) + + var attributes: [NSAttributedString.Key : Any] = [:] + if let subheadingParagraphStyle = subheadingParagraphStyle { + attributes[NSAttributedString.Key.paragraphStyle] = subheadingParagraphStyle + } + attributedText.addAttributes(attributes, range: NSRange(location: 0, length: attributedText.length)) + + subheadingTextView.attributedText = attributedText.removingRepetitiveNewlineCharacters() + subheadingTextView.tintColor = theme.colors.link + } + var footerParagraphStyle: NSParagraphStyle? { let pStyle = NSMutableParagraphStyle() pStyle.lineBreakMode = .byWordWrapping @@ -315,6 +327,7 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { stackView.spacing = spacing footerTextView.delegate = self + subheadingTextView.delegate = self apply(theme: theme) } @@ -332,7 +345,7 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { fileprivate func reset() { imageView.image = nil headingLabel.text = nil - subheadingLabel.text = nil + subheadingTextView.attributedText = nil primaryButton.setTitle(nil, for: .normal) secondaryButton.setTitle(nil, for: .normal) footerTextView.text = nil @@ -375,7 +388,7 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { adjustImageViewVisibility(for: traitCollection.verticalSizeClass) // Collapse stack view cells for labels/buttons if no text. headingLabel.isHidden = !headingLabel.wmf_hasAnyNonWhitespaceText - subheadingLabel.isHidden = !subheadingLabel.wmf_hasAnyNonWhitespaceText + subheadingTextView.isHidden = !subheadingTextView.wmf_hasAnyNonWhitespaceText footerTextView.isHidden = !footerTextView.wmf_hasAnyNonWhitespaceText primaryButton.isHidden = !primaryButton.wmf_hasAnyNonWhitespaceText secondaryButton.isHidden = !secondaryButton.wmf_hasAnyNonWhitespaceText @@ -434,8 +447,6 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { return } headingLabel?.textColor = theme.colors.primaryText - subheadingLabel?.textColor = theme.colors.primaryText - footerTextView?.textColor = theme.colors.secondaryText closeButton.tintColor = theme.colors.primaryText primaryButton?.tintColor = theme.colors.link secondaryButton?.tintColor = theme.colors.secondaryText @@ -454,13 +465,19 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { roundedCornerContainer.layer.borderWidth = 0 } roundedCornerContainer.backgroundColor = theme.colors.cardBackground + updateSubheadingHTML() updateFooterHTML() } } extension ScrollableEducationPanelViewController: UITextViewDelegate { public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool { - footerLinkAction?(URL) + if textView == footerTextView { + footerLinkAction?(URL) + } else if textView == subheadingTextView { + subheadingLinkAction?(URL) + } + return false } } diff --git a/Wikipedia/Images.xcassets/error-icon-large.imageset/Contents.json b/Wikipedia/Images.xcassets/error-icon-large.imageset/Contents.json new file mode 100644 index 00000000000..666f6e5ed5c --- /dev/null +++ b/Wikipedia/Images.xcassets/error-icon-large.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "error-icon-large.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Wikipedia/Images.xcassets/error-icon-large.imageset/error-icon-large.pdf b/Wikipedia/Images.xcassets/error-icon-large.imageset/error-icon-large.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a875a98d90cb8ee8f0b9c34839974603074eb449 GIT binary patch literal 3378 zcmZu!U5`^Y5PiSD!Y@ehfMd_tp0R|G%2KMTtxA`^p+2P93v9KUw3|@T{`#JAZtM#* z4=8)$kC`)Pj)zCDU%q-8y-ZVd!5x18V{-1@}SPNqFF~ull zd^zs+Q&i6(a?I{>U~=~pvo9%!T2|=Y#0h5=!4YFEXJ3MH33hC#nX}{KIaSRDF=>hH zb`uMJ)>y%X&q<1^10=$lEFzV{0b3DGDjLN_&oQMewpD$NRWt(>&VswR`lN}eI`Whd zzPf~@Q%FewDaXhaTT}I#lo3=!Mma$Nr5$7|vCe+C zY7`ZUYpi-gI%F)4m5jO;<|>v?-_H@%$hB76zud#*nL_~wz?O)BRTd7$5zr-eR6QrI z%C>UJ5j98MGO1w;8^BPl+87?ZK?yN~YQ*081tw7xIvSNQc@QcaaQ7%$f<6+8tH@_m z7pUYwnM@gr2$Fg#i4s)M)dH+&&Ml%LE8H1F(S+SyeZUe)0RKa#z)C7HG_iF(Tf|C% zlN-86W=kKA4jI^P)lCDvn^0*Y5^XA5_CqHeNhCLB&i6o1St3E`>xiIHr7E?dOYFd+ zK)DTDa)iQB`D|RT*Z>-+6cR%h-Xi%_C?KA}Z-j=R9H@0vVmFZwRRfx06b

C2$ll z*sBX^L?Y|`E&}vZP_1b5m0HmIA!nG;kX7(hQ-$`2`rsr@r*17%FrRT8ZtZ#=#ptph zQ16c&Ebu~lZ>75x*n6&DFA-fMK5JH!cp;VmqQvWTOAte_S=GLQtKu?G`TYKA>MBKL*wIZ_`kPhH+`5Wdpr+j z{A5%r!B_7mGM(UIpcP7N&M0tdtgKooCTCcL>*5=fAaEyh5}-ISF?3YmBvRm^cMUC) zMGV!DU}UymLK*j>7>j+N#FSkb(TC?v{`@D4~t#O>~4y=8YR+%z(Ci;{$JIxxIJcx){j zfg`{@3@fqq1@cA@;x)o<0b8IInRSl92GD{Y4{J8TK?tC8&HDe;=kvNji+K3(C|TXW z2*IWC9(EMWq08~~ItVnNT(AbKo8nDs7={9DIoA!3AYFhIz%e0cSf}aGvVozZ(x&JF zXF@!kkAb!NN=i}N`+iv|m@F`6VSX7Wf^}5NW{~yWiY!6~@940~7@%;sdW{7n8Ag>M zl{L1`d#oG`jS~lx<8JbU^AY8!4ivRyGpac9?wIM|-L#*6nQXjWX4lK0YcuV6048DS z^Ka@f=Hksa`~Bf`bZ>vdoQ%)r*MI(;-RAZ7{k#A_%{RB(7l%*oEe6BIx%(GPAJpYSq9hc za?jP_BlgCx;y(georJk|b&@4`>=%y2uePV{-QoS`TR%O_@222nI;U^{x`O#8JHX2) zV!pPI+jj`F%I6R%9{w*O8_ey~H*&ym`6YzO@&cV6wzqfl!(`R_{w3&md_3IGPu%0% qn Date: Wed, 1 Feb 2023 17:01:35 -0600 Subject: [PATCH 03/17] Add error models and resolving helper methods to Fetcher superclass - Determines best error from array of errors - Parses error blockreason from wikitext to html - Fetches blocked template if necessary and updates placeholders with blockinfo --- WMF Framework/Fetcher.swift | 229 +++++++++++++++++++++++++ WMF Framework/MediaWikiApiErrors.swift | 91 ++++++++++ WMF Framework/WMFLegacyFetcher.h | 3 + WMF Framework/WMFLegacyFetcher.m | 4 + Wikipedia.xcodeproj/project.pbxproj | 4 + 5 files changed, 331 insertions(+) create mode 100644 WMF Framework/MediaWikiApiErrors.swift diff --git a/WMF Framework/Fetcher.swift b/WMF Framework/Fetcher.swift index 3c9ee14f2e5..7be37fdf4c9 100644 --- a/WMF Framework/Fetcher.swift +++ b/WMF Framework/Fetcher.swift @@ -125,6 +125,233 @@ open class Fetcher: NSObject { return task } +// MARK: Resolving MediaWiki Block Errors + + /// Chain from MediaWiki API response if you want to resolve a set of error messages into a full html string for display. Use this method for raw dictionary responses. For Swift Codable responses, use resolveMediaWikiBlockedError(from apiErrors: [MediaWikiAPIError]...). + /// - Parameters: + /// - result: Serialized dictionary from MediaWiki API response + /// - completionHandler: Completion handler called when full html is determined, which is packaged up in a MediaWikiAPIBlockedDisplayError object. + @objc(resolveMediaWikiApiBlockErrorFromResult:siteURL:completionHandler:) + func resolveMediaWikiApiBlockErrorFromResult(_ result: [String: Any], siteURL: URL, completionHandler: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { + + var apiErrors: [MediaWikiAPIError] = [] + + guard let errorsDict = result["errors"] as? [[String: Any]] else { + completionHandler(nil) + return + } + + for errorDict in errorsDict { + if let error = MediaWikiAPIError(dict: errorDict) { + apiErrors.append(error) + } + } + + resolveMediaWikiBlockedError(from: apiErrors, siteURL: siteURL, completion: completionHandler) + } + + /// Chain from MediaWiki API response if you want to resolve a set of error messages into a full html string for display. Use from Swift Codable responses that capture a collection of [MediaWikiAPIError] items. + /// - Parameters: + /// - apiErrors: Decoded MediaWikiAPIError items from API response + /// - completion: Called when full html is determined, which is packaged up in a MediaWikiAPIBlockedDisplayError object. + public func resolveMediaWikiBlockedError(from apiErrors: [MediaWikiAPIError], siteURL: URL, completion: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { + + let blockedApiErrors = apiErrors.filter { $0.code.contains("block") } + let firstApiErrorWithInfo = blockedApiErrors.first(where: { $0.data?.blockinfo != nil }) + let fallbackApiError = blockedApiErrors.first(where: { !$0.html.isEmpty }) + + let fallbackCompletion: () -> Void = { + guard let fallbackApiError else { + completion(nil) + return + } + + let displayError = MediaWikiAPIBlockedDisplayError(messageHtml: fallbackApiError.html, linkBaseURL: siteURL, code: fallbackApiError.code) + completion(displayError) + return + } + + guard let blockedApiError = firstApiErrorWithInfo, + let blockedApiInfo = blockedApiError.data?.blockinfo else { + + fallbackCompletion() + return + } + + resolveMediaWikiApiBlockError(siteURL: siteURL, code: blockedApiError.code, html: blockedApiError.html, blockInfo: blockedApiInfo) { displayError in + + guard let displayError = displayError else { + fallbackCompletion() + return + } + + completion(displayError) + } + } + + private func resolveMediaWikiApiBlockError(siteURL: URL, code: String, html: String, blockInfo: MediaWikiAPIError.Data.BlockInfo, completionHandler: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { + + // First turn blockReason into html, if needed + let group = DispatchGroup() + + var blockReasonHtml: String? + var templateHtml: String? + var templateSiteURL: URL? + + group.enter() + parseBlockReason(siteURL: siteURL, blockReason: blockInfo.blockreason) { text in + blockReasonHtml = text + group.leave() + } + + group.enter() + fetchBlockedTextTemplate(isPartial: blockInfo.blockpartial, siteURL: siteURL) { text, siteURL in + templateHtml = text + templateSiteURL = siteURL + group.leave() + } + + group.notify(queue: DispatchQueue.global(qos: .default)) { + + guard var templateHtml = templateHtml else { + completionHandler(nil) + return + } + + let linkBaseURL = templateSiteURL ?? siteURL + + // Replace encoded placeholders first, before replacing them with blocked text. + templateHtml = templateHtml.replacingOccurrences(of: "%241", with: "$1") + templateHtml = templateHtml.replacingOccurrences(of: "%242", with: "$2") + templateHtml = templateHtml.replacingOccurrences(of: "%243", with: "$3") + templateHtml = templateHtml.replacingOccurrences(of: "%244", with: "$4") + templateHtml = templateHtml.replacingOccurrences(of: "%245", with: "$5") + templateHtml = templateHtml.replacingOccurrences(of: "%246", with: "$6") + templateHtml = templateHtml.replacingOccurrences(of: "%247", with: "$7") + templateHtml = templateHtml.replacingOccurrences(of: "%248", with: "$8") + + // Replace placeholders with blocked text + templateHtml = templateHtml.replacingOccurrences(of: "$1", with: blockInfo.blockedby) + + if let blockReasonHtml { + templateHtml = templateHtml.replacingOccurrences(of: "$2", with: blockReasonHtml) + } + + templateHtml = templateHtml.replacingOccurrences(of: "$3", with: "") // IP Address + + // $4 not used + + templateHtml = templateHtml.replacingOccurrences(of: "$5", with: String(blockInfo.blockid)) + + let blockExpiryDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockexpiry, siteURL: linkBaseURL) + templateHtml = templateHtml.replacingOccurrences(of: "$6", with: blockExpiryDisplayDate) + + let username = MWKDataStore.shared().authenticationManager.loggedInUsername ?? "" + templateHtml = templateHtml.replacingOccurrences(of: "$7", with: username) + + let blockedTimestampDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockedtimestamp, siteURL: linkBaseURL) + templateHtml = templateHtml.replacingOccurrences(of: "$8", with: blockedTimestampDisplayDate) + + let displayError = MediaWikiAPIBlockedDisplayError(messageHtml: templateHtml, linkBaseURL: linkBaseURL, code: code) + completionHandler(displayError) + } + + } + + private func blockedDateForDisplay(iso8601DateString: String, siteURL: URL) -> String { + var formattedDateString: String? = nil + if let date = (iso8601DateString as NSString).wmf_iso8601Date() { + + let dateFormatter = DateFormatter.wmf_localCustomShortDateFormatterWithTime(for: NSLocale.wmf_locale(for: siteURL.wmf_languageCode)) + + formattedDateString = dateFormatter?.string(from: date) + } + + return formattedDateString ?? "" + } + + private func parseBlockReason(attempt: Int = 1, siteURL: URL, blockReason: String, completion: @escaping (String?) -> Void) { + + let params: [String: Any] = [ + "action": "parse", + "prop": "text", + "mobileformat": 1, + "text": blockReason, + "errorformat": "html", + "erroruselocal": 1, + "format": "json", + "formatversion": 2 + ] + + performMediaWikiAPIGET(for: siteURL, with: params, cancellationKey: nil) { [weak self] result, response, error in + + + guard let parse = result?["parse"] as? [String: Any], + let text = parse["text"] as? String else { + + // If unable to find, try app language once. Otherwise return nil. + guard attempt == 1 else { + completion(nil) + return + } + + guard let appLangSiteURL = MWKDataStore.shared().languageLinkController.appLanguage?.siteURL else { + completion(nil) + return + } + + self?.parseBlockReason(attempt: attempt + 1, siteURL: appLangSiteURL, blockReason: blockReason, completion: completion) + return + } + + completion(text) + } + } + + private func fetchBlockedTextTemplate(isPartial: Bool = false, attempt: Int = 1, siteURL: URL, completion: @escaping (String?, URL) -> Void) { + + // Note: Not enough languages seem to have MediaWiki:Blockedtext-partial, so forcing MediaWiki:Blockedtext for now. + + let templateName = "MediaWiki:Blockedtext" + if let parseText = templateName.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { + let params: [String: Any] = [ + "action": "parse", + "prop": "text", + "mobileformat": 1, + "page": parseText, + "errorformat": "html", + "erroruselocal": 1, + "format": "json", + "formatversion": 2 + ] + + performMediaWikiAPIGET(for: siteURL, with: params, cancellationKey: nil) { [weak self] result, response, error in + + guard let parse = result?["parse"] as? [String: Any], + let text = parse["text"] as? String else { + + // If unable to find, try app language once. Otherwise return nil. + guard attempt == 1 else { + completion(nil, siteURL) + return + } + + guard let appLangSiteURL = MWKDataStore.shared().languageLinkController.appLanguage?.siteURL else { + completion(nil, siteURL) + return + } + + self?.fetchBlockedTextTemplate(isPartial: isPartial, attempt: attempt + 1, siteURL: appLangSiteURL, completion: completion) + return + } + + completion(text, siteURL) + } + } + } + +// MARK: Decodable + @discardableResult public func performDecodableMediaWikiAPIGET(for URL: URL?, with queryParameters: [String: Any]?, cancellationKey: CancellationKey? = nil, completionHandler: @escaping (Result) -> Swift.Void) -> CancellationKey? { let url = configuration.mediaWikiAPIURLForURL(URL, with: queryParameters) let key = cancellationKey ?? UUID().uuidString @@ -160,6 +387,8 @@ open class Fetcher: NSObject { return task } +// MARK: Tracking + @objc(trackTask:forKey:) public func track(task: URLSessionTask?, for key: String) { guard let task = task else { diff --git a/WMF Framework/MediaWikiApiErrors.swift b/WMF Framework/MediaWikiApiErrors.swift new file mode 100644 index 00000000000..d45170669d0 --- /dev/null +++ b/WMF Framework/MediaWikiApiErrors.swift @@ -0,0 +1,91 @@ +import Foundation + +/// An object that is passed through from fetchers to view controllers, for reference when displaying blocked errors in a BlockedPanelViewController. +@objc public class MediaWikiAPIBlockedDisplayError: NSObject { + + // Fully resolved html to display in the blocked panel. + @objc public let messageHtml: String + + // Base url to be referenced when user taps a relative link within the messageHtml in the blocked panel. + public let linkBaseURL: URL + + // Error code, passed through from original MediaWikiAPIError. Currently used for logging. + public let code: String + + public init(messageHtml: String, linkBaseURL: URL, code: String) { + self.messageHtml = messageHtml + self.linkBaseURL = linkBaseURL + self.code = code + } +} + + +/// Represents errors that come in the MediaWiki API response. +/// See https://www.mediawiki.org/wiki/API:Errors_and_warnings +public struct MediaWikiAPIError: Codable { + + public struct Data: Codable { + public struct BlockInfo: Codable { + let blockreason: String + let blockpartial: Bool + let blockedby: String + let blockid: Int64 + let blockexpiry: String + let blockedtimestamp: String + + init?(dict: [String: Any]) { + + guard let blockReason = dict["blockreason"] as? String, + let blockPartial = dict["blockpartial"] as? Bool, + let blockedBy = dict["blockedby"] as? String, + let blockID = dict["blockid"] as? Int64, + let blockExpiry = dict["blockexpiry"] as? String, + let blockedTimestamp = dict["blockedtimestamp"] as? String else { + return nil + } + + self.blockreason = blockReason + self.blockpartial = blockPartial + self.blockedby = blockedBy + self.blockid = blockID + self.blockexpiry = blockExpiry + self.blockedtimestamp = blockedTimestamp + } + } + + let blockinfo: BlockInfo? + + init?(dict: [String: Any]) { + + guard let blockInfoDict = dict["blockinfo"] as? [String: Any] else { + self.blockinfo = nil + return + } + + self.blockinfo = BlockInfo(dict: blockInfoDict) + } + } + + public let code: String + let html: String + let data: Data? + + init?(dict: [String: Any]) { + + guard let code = dict["code"] as? String, + let html = dict["html"] as? String + else { + return nil + } + + self.code = code + self.html = html + + guard let dataDict = dict["data"] as? [String: Any] else { + self.data = nil + return + } + + self.data = Data(dict: dataDict) + } +} diff --git a/WMF Framework/WMFLegacyFetcher.h b/WMF Framework/WMFLegacyFetcher.h index 80ce7f8ce98..1c04082eb0a 100644 --- a/WMF Framework/WMFLegacyFetcher.h +++ b/WMF Framework/WMFLegacyFetcher.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN @class WMFSession; @class WMFConfiguration; @class WMFFetcher; +@class MediaWikiAPIBlockedDisplayError; // Bridge from old Obj-C fetcher classes to new Swift fetcher class @interface WMFLegacyFetcher : NSObject @@ -22,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSURLSessionTask *)performCancelableMediaWikiAPIGETForURL:(NSURL *)URL cancellationKey:(NSString *)cancellationKey withQueryParameters:(NSDictionary *)queryParameters completionHandler:(void (^)(NSDictionary * _Nullable result, NSHTTPURLResponse * _Nullable response, NSError * _Nullable error)) completionHandler; - (NSURLSessionTask *)performMediaWikiAPIPOSTForURL:(NSURL *)URL withBodyParameters:(NSDictionary *)bodyParameters completionHandler:(void (^)(NSDictionary * _Nullable result, NSHTTPURLResponse * _Nullable response, NSError * _Nullable error))completionHandler; +- (void)resolveMediaWikiApiBlockErrorFromResult: (NSDictionary *)result siteURL:(NSURL *)siteURL completionHandler:(void (^)(MediaWikiAPIBlockedDisplayError * blockedDisplayError)) completionHandler; + - (void)cancelAllFetches; // only cancels tasks started with the methods provided by WMFLegacyFetcher - tasks started directly on the session are not canceled - (void)cancelTaskWithCancellationKey:(NSString *)cancellationKey; diff --git a/WMF Framework/WMFLegacyFetcher.m b/WMF Framework/WMFLegacyFetcher.m index e1779ef651e..9f61f5a4413 100644 --- a/WMF Framework/WMFLegacyFetcher.m +++ b/WMF Framework/WMFLegacyFetcher.m @@ -60,6 +60,10 @@ - (NSURLSessionTask *)performCancelableMediaWikiAPIGETForURLRequest:(NSURLReques return [self.fetcher performMediaWikiAPIGETForURLRequest:urlRequest cancellationKey:cancellationKey completionHandler:completionHandler]; } +- (void)resolveMediaWikiApiBlockErrorFromResult: (NSDictionary *)result siteURL:(NSURL *)siteURL completionHandler:(void (^)(MediaWikiAPIBlockedDisplayError * blockedDisplayError)) completionHandler { + [self.fetcher resolveMediaWikiApiBlockErrorFromResult:result siteURL:siteURL completionHandler:completionHandler]; +} + - (void)cancelAllFetches { [self.fetcher cancelAllTasks]; } diff --git a/Wikipedia.xcodeproj/project.pbxproj b/Wikipedia.xcodeproj/project.pbxproj index fddf20d4f70..54b04fc1b18 100644 --- a/Wikipedia.xcodeproj/project.pbxproj +++ b/Wikipedia.xcodeproj/project.pbxproj @@ -905,6 +905,7 @@ 67B64D5D2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67B64D5B2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift */; }; 67B64D5E2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67B64D5B2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift */; }; 67B64D5F2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67B64D5B2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift */; }; + 67B7E77E2988777A00708A81 /* MediaWikiApiErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67B7E7792988768C00708A81 /* MediaWikiApiErrors.swift */; }; 67BEFFD528AD9DF000606B38 /* TalkPageType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BEFFD428AD9DF000606B38 /* TalkPageType.swift */; }; 67BEFFD628AD9DF000606B38 /* TalkPageType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BEFFD428AD9DF000606B38 /* TalkPageType.swift */; }; 67BEFFD728AD9DF000606B38 /* TalkPageType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BEFFD428AD9DF000606B38 /* TalkPageType.swift */; }; @@ -4292,6 +4293,7 @@ 67B5333B28416A3B00C33E13 /* UserDataExportCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDataExportCache.swift; sourceTree = ""; }; 67B64D562507DE3E00FA27F3 /* ArticleAsLivingDocSectionHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleAsLivingDocSectionHeaderView.swift; sourceTree = ""; }; 67B64D5B2507E9FD00FA27F3 /* ArticleAsLivingDocSmallEventCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleAsLivingDocSmallEventCollectionViewCell.swift; sourceTree = ""; }; + 67B7E7792988768C00708A81 /* MediaWikiApiErrors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaWikiApiErrors.swift; sourceTree = ""; }; 67BEFFD428AD9DF000606B38 /* TalkPageType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkPageType.swift; sourceTree = ""; }; 67BEFFD928AEDF3600606B38 /* WikimediaProject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WikimediaProject.swift; sourceTree = ""; }; 67C1757528AD4D6000C5ABA4 /* TalkPageDataController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkPageDataController.swift; sourceTree = ""; }; @@ -9384,6 +9386,7 @@ 6761AEEA270613B400E47BAD /* SharedContainerCache.swift */, 6779618C29245BF300C2A65F /* PageIDToURLFetcher.swift */, 6779618E29246BC900C2A65F /* NSUserActivity+Extensions.swift */, + 67B7E7792988768C00708A81 /* MediaWikiApiErrors.swift */, ); path = "WMF Framework"; sourceTree = ""; @@ -12338,6 +12341,7 @@ 834F47F42833D91F00F86C80 /* RemoteNotificationFilterType.swift in Sources */, 835A042D223AD63000D4D758 /* ArticleSummaryController.swift in Sources */, D844D9B81D6CB7980042D692 /* MWKRecentSearchEntry.m in Sources */, + 67B7E77E2988777A00708A81 /* MediaWikiApiErrors.swift in Sources */, D8FA18AF1E1BD891009675C3 /* NSNumberFormatter+WMFExtras.swift in Sources */, D844DA091D6CC4D40042D692 /* MWKLanguageFilter.m in Sources */, 67F1A180286F34A5000D0F74 /* FeatureFlags.swift in Sources */, From d2c32e6578516cc5880206d091f7c81d7de63579 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:04:05 -0600 Subject: [PATCH 04/17] Display blocked panel upon section editor publish - Update WikiTextSectionUploader params so that we get more error info - Send response object into Fetcher helper method to resolve blocked error - Pass error informaation back to EditSaveViewController - Present panel and handle link taps --- Wikipedia/Code/EditSaveViewController.swift | 11 ++ Wikipedia/Code/WikiTextSectionUploader.h | 5 +- Wikipedia/Code/WikiTextSectionUploader.m | 153 +++++++++++--------- 3 files changed, 103 insertions(+), 66 deletions(-) diff --git a/Wikipedia/Code/EditSaveViewController.swift b/Wikipedia/Code/EditSaveViewController.swift index 6daac199dc2..b1686e99af9 100644 --- a/Wikipedia/Code/EditSaveViewController.swift +++ b/Wikipedia/Code/EditSaveViewController.swift @@ -337,6 +337,17 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel case .server, .unknown: WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil) editFunnel?.logSectionSaveError(source: editFunnelSource, language: languageCode, errorText: "other") + case .blocked: + + WMFAlertManager.sharedInstance.dismissAlert() // Hide "Publishing..." + + guard let blockedError = nsError.userInfo[NSErrorUserInfoBlockedDisplayError] as? MediaWikiAPIBlockedDisplayError, + let currentTitle = articleURL?.wmf_title else { + return + } + + wmf_showBlockedPanel(messageHtml: blockedError.messageHtml, linkBaseURL: blockedError.linkBaseURL, currentTitle: currentTitle, theme: theme) + default: WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil) editFunnel?.logSectionSaveError(source: editFunnelSource, language: languageCode, errorText: "other") diff --git a/Wikipedia/Code/WikiTextSectionUploader.h b/Wikipedia/Code/WikiTextSectionUploader.h index 95cdcd701e6..856a7b241f7 100644 --- a/Wikipedia/Code/WikiTextSectionUploader.h +++ b/Wikipedia/Code/WikiTextSectionUploader.h @@ -7,11 +7,14 @@ typedef NS_ENUM(NSInteger, WikiTextSectionUploaderErrorType) { WikiTextSectionUploaderErrorTypeNeedsCaptcha = 2, WikiTextSectionUploaderErrorTypeAbuseFilterDisallowed = 3, WikiTextSectionUploaderErrorTypeAbuseFilterWarning = 4, - WikiTextSectionUploaderErrorTypeAbuseFilterOther = 5 + WikiTextSectionUploaderErrorTypeAbuseFilterOther = 5, + WikiTextSectionUploaderErrorTypeBlocked = 6, }; NS_ASSUME_NONNULL_BEGIN +extern NSString *const NSErrorUserInfoBlockedDisplayError; + @interface WikiTextSectionUploader : WMFLegacyFetcher // Note: "section" parameter needs to be a string because the // api returns transcluded section indexes with a "T-" prefix diff --git a/Wikipedia/Code/WikiTextSectionUploader.m b/Wikipedia/Code/WikiTextSectionUploader.m index 4e1a8f5142c..c2a553f8dd5 100644 --- a/Wikipedia/Code/WikiTextSectionUploader.m +++ b/Wikipedia/Code/WikiTextSectionUploader.m @@ -1,6 +1,8 @@ #import "WikiTextSectionUploader.h" @import WMF; +NSString *const NSErrorUserInfoBlockedDisplayError = @"blockedDisplayError"; + @implementation WikiTextSectionUploader - (void)addSectionWithSummary:(NSString *)summary @@ -71,7 +73,10 @@ - (void)prependToSectionID:(NSString *)sectionID @"prependtext": text, @"section": sectionID, @"title": articleURL.wmf_title, - @"format": @"json" + @"errorformat": @"html", + @"errorsuselocal": @"1", + @"format": @"json", + @"formatversion": @"2", } .mutableCopy; @@ -113,7 +118,10 @@ - (void)uploadWikiText:(nullable NSString *)wikiText @"summary": summary, @"section": section, @"title": articleURL.wmf_title, + @"errorformat": @"html", + @"errorsuselocal": @"1", @"format": @"json", + @"formatversion": @"2", } .mutableCopy; @@ -145,84 +153,99 @@ - (void)updateWithArticleURL: (NSURL *)articleURL parameters: (NSDictionary *)responseObject captchaWord: (nullable NSString *)captchaWord completion:(void (^)(NSDictionary * _Nullable result, NSError * _Nullable error))completion { + + NSDictionary *resultDict = responseObject[@"edit"]; + NSString *result = resultDict[@"result"]; + + NSError *error = nil; + if (responseObject[@"error"]) { + NSMutableDictionary *errorDict = [responseObject[@"error"] mutableCopy]; + errorDict[NSLocalizedDescriptionKey] = errorDict[@"info"]; + error = [NSError errorWithDomain:@"WikiText Uploader" + code:WikiTextSectionUploaderErrorTypeServer + userInfo:errorDict]; + } - if (!error && !result) { - NSMutableDictionary *errorDict = [@{} mutableCopy]; - errorDict[NSLocalizedDescriptionKey] = WMFLocalizedStringWithDefaultValue(@"wikitext-upload-result-unknown", nil, nil, @"Unable to determine wikitext upload result.", @"Alert text shown when the result of saving section wikitext changes is unknown"); + if (!error && !result) { + NSMutableDictionary *errorDict = [@{} mutableCopy]; + errorDict[NSLocalizedDescriptionKey] = WMFLocalizedStringWithDefaultValue(@"wikitext-upload-result-unknown", nil, nil, @"Unable to determine wikitext upload result.", @"Alert text shown when the result of saving section wikitext changes is unknown"); + + // Set error condition so dependent ops don't even start and so the errorBlock below will fire. + error = [NSError errorWithDomain:@"Upload Wikitext Op" code:WikiTextSectionUploaderErrorTypeUnknown userInfo:errorDict]; + } - // Set error condition so dependent ops don't even start and so the errorBlock below will fire. - error = [NSError errorWithDomain:@"Upload Wikitext Op" code:WikiTextSectionUploaderErrorTypeUnknown userInfo:errorDict]; + if (!error && result && [result isEqualToString:@"Failure"]) { + if (responseObject[@"edit"][@"captcha"]) { + NSMutableDictionary *errorDict = [@{} mutableCopy]; + + errorDict[NSLocalizedDescriptionKey] = (captchaWord && (captchaWord.length > 0)) ? WMFLocalizedStringWithDefaultValue(@"wikitext-upload-captcha-error", nil, nil, @"CAPTCHA verification error.", @"Alert text shown when section wikitext upload captcha fails") + : WMFLocalizedStringWithDefaultValue(@"wikitext-upload-captcha-needed", nil, nil, @"Need CAPTCHA verification.", @"Alert text shown when section wikitext upload captcha is required"); + + // Make the capcha id and url available from the error. + errorDict[@"captchaId"] = responseObject[@"edit"][@"captcha"][@"id"]; + errorDict[@"captchaUrl"] = responseObject[@"edit"][@"captcha"][@"url"]; + + // Set error condition so dependent ops don't even start and so the errorBlock below will fire. + error = [NSError errorWithDomain:@"Upload Wikitext Op" code:WikiTextSectionUploaderErrorTypeNeedsCaptcha userInfo:errorDict]; + } else if (responseObject[@"edit"][@"code"]) { + NSString *abuseFilterCode = responseObject[@"edit"][@"code"]; + WikiTextSectionUploaderErrorType errorType = WikiTextSectionUploaderErrorTypeUnknown; + + if ([abuseFilterCode hasPrefix:@"abusefilter-warning"]) { + errorType = WikiTextSectionUploaderErrorTypeAbuseFilterWarning; + } else if ([abuseFilterCode hasPrefix:@"abusefilter-disallowed"]) { + errorType = WikiTextSectionUploaderErrorTypeAbuseFilterDisallowed; + } else if ([abuseFilterCode hasPrefix:@"abusefilter"]) { + errorType = WikiTextSectionUploaderErrorTypeAbuseFilterOther; } - if (!error && result && [result isEqualToString:@"Failure"]) { - if (responseObject[@"edit"][@"captcha"]) { + switch (errorType) { + case WikiTextSectionUploaderErrorTypeAbuseFilterWarning: + case WikiTextSectionUploaderErrorTypeAbuseFilterDisallowed: + case WikiTextSectionUploaderErrorTypeAbuseFilterOther: { NSMutableDictionary *errorDict = [@{} mutableCopy]; - errorDict[NSLocalizedDescriptionKey] = (captchaWord && (captchaWord.length > 0)) ? WMFLocalizedStringWithDefaultValue(@"wikitext-upload-captcha-error", nil, nil, @"CAPTCHA verification error.", @"Alert text shown when section wikitext upload captcha fails") - : WMFLocalizedStringWithDefaultValue(@"wikitext-upload-captcha-needed", nil, nil, @"Need CAPTCHA verification.", @"Alert text shown when section wikitext upload captcha is required"); + errorDict[NSLocalizedDescriptionKey] = responseObject[@"edit"][@"info"]; - // Make the capcha id and url available from the error. - errorDict[@"captchaId"] = responseObject[@"edit"][@"captcha"][@"id"]; - errorDict[@"captchaUrl"] = responseObject[@"edit"][@"captcha"][@"url"]; + // Make the verbose warning available from the error. + errorDict[@"warning"] = responseObject[@"edit"][@"warning"]; + errorDict[@"code"] = abuseFilterCode; // Set error condition so dependent ops don't even start and so the errorBlock below will fire. - error = [NSError errorWithDomain:@"Upload Wikitext Op" code:WikiTextSectionUploaderErrorTypeNeedsCaptcha userInfo:errorDict]; - } else if (responseObject[@"edit"][@"code"]) { - NSString *abuseFilterCode = responseObject[@"edit"][@"code"]; - WikiTextSectionUploaderErrorType errorType = WikiTextSectionUploaderErrorTypeUnknown; - - if ([abuseFilterCode hasPrefix:@"abusefilter-warning"]) { - errorType = WikiTextSectionUploaderErrorTypeAbuseFilterWarning; - } else if ([abuseFilterCode hasPrefix:@"abusefilter-disallowed"]) { - errorType = WikiTextSectionUploaderErrorTypeAbuseFilterDisallowed; - } else if ([abuseFilterCode hasPrefix:@"abusefilter"]) { - errorType = WikiTextSectionUploaderErrorTypeAbuseFilterOther; - } - - switch (errorType) { - case WikiTextSectionUploaderErrorTypeAbuseFilterWarning: - case WikiTextSectionUploaderErrorTypeAbuseFilterDisallowed: - case WikiTextSectionUploaderErrorTypeAbuseFilterOther: { - NSMutableDictionary *errorDict = [@{} mutableCopy]; - - errorDict[NSLocalizedDescriptionKey] = responseObject[@"edit"][@"info"]; - - // Make the verbose warning available from the error. - errorDict[@"warning"] = responseObject[@"edit"][@"warning"]; - errorDict[@"code"] = abuseFilterCode; - - // Set error condition so dependent ops don't even start and so the errorBlock below will fire. - error = [NSError errorWithDomain:@"Upload Wikitext Op" code:errorType userInfo:errorDict]; - } break; - - default: - break; - } - } + error = [NSError errorWithDomain:@"Upload Wikitext Op" code:errorType userInfo:errorDict]; + } break; + + default: + break; } + } + } - completion(resultDict, error); - }]; + completion(resultDict, error); } @end From a7193f2a19499130d196253a3e98a58b3de6cd9a Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:06:49 -0600 Subject: [PATCH 05/17] Display blocked panel upon landing on section editor - Update SectionFetcher params so that we get more error info - Send blockInfo values into Fetcher helper method to resolve blocked error - Pass error information back into SectionEditorViewController - Don't configure web view until after wikitext is fetched - Display blocked panel and set editor to read only --- .../Code/SectionEditorViewController.swift | 98 ++++++++++++++----- Wikipedia/Code/SectionFetcher.swift | 96 ++++++++++++------ 2 files changed, 139 insertions(+), 55 deletions(-) diff --git a/Wikipedia/Code/SectionEditorViewController.swift b/Wikipedia/Code/SectionEditorViewController.swift index 139fba6a1cd..b30e3a5249c 100644 --- a/Wikipedia/Code/SectionEditorViewController.swift +++ b/Wikipedia/Code/SectionEditorViewController.swift @@ -1,4 +1,5 @@ import CocoaLumberjackSwift +import WMF protocol SectionEditorViewControllerDelegate: AnyObject { func sectionEditorDidCancelEditing(_ sectionEditor: SectionEditorViewController) @@ -19,7 +20,7 @@ class SectionEditorViewController: ViewController { private var selectedTextEditInfo: SelectedTextEditInfo? private var dataStore: MWKDataStore - private var webView: SectionEditorWebView! + private var webView: SectionEditorWebView? private let sectionFetcher: SectionFetcher private var inputViewsController: SectionEditorInputViewsController! @@ -83,19 +84,37 @@ class SectionEditorViewController: ViewController { } override func viewDidLoad() { - loadWikitext() navigationItemController = SectionEditorNavigationItemController(navigationItem: navigationItem) navigationItemController.delegate = self - configureWebView() - - dataStore.authenticationManager.loginWithSavedCredentials { (_) in } - - webView.scrollView.delegate = self - scrollView = webView.scrollView + loadWikitext { [weak self] blockedError in + + guard let self else { + return + } + + if let blockedError { + self.configureWebView(readOnly: true) + + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1.0) { // helps prevent flash as wikitext is loaded + self.presentErrorMessage(blockedError: blockedError) + } + + } else { + self.configureWebView(readOnly: false) + } + + self.dataStore.authenticationManager.loginWithSavedCredentials { (_) in } + + self.webView?.scrollView.delegate = self + self.scrollView = self.webView?.scrollView - setupFocusNavigationView() + self.setupFocusNavigationView() + + self.apply(theme: self.theme) + } + super.viewDidLoad() } @@ -171,7 +190,7 @@ class SectionEditorViewController: ViewController { } } - private func configureWebView() { + private func configureWebView(readOnly: Bool) { let configuration = WKWebViewConfiguration() configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs") let textSizeAdjustment = UserDefaults.standard.wmf_articleFontSizeMultiplier().intValue @@ -185,7 +204,7 @@ class SectionEditorViewController: ViewController { let layoutDirection = MWKLanguageLinkController.layoutDirection(forContentLanguageCode: contentLanguageCode) let isSyntaxHighlighted = UserDefaults.standard.wmf_IsSyntaxHighlightingEnabled - let setupUserScript = CodemirrorSetupUserScript(languageCode: languageCode, direction: CodemirrorSetupUserScript.CodemirrorDirection(rawValue: layoutDirection) ?? .ltr, theme: theme, textSizeAdjustment: textSizeAdjustment, isSyntaxHighlighted: isSyntaxHighlighted, readOnly: false) { [weak self] in + let setupUserScript = CodemirrorSetupUserScript(languageCode: languageCode, direction: CodemirrorSetupUserScript.CodemirrorDirection(rawValue: layoutDirection) ?? .ltr, theme: theme, textSizeAdjustment: textSizeAdjustment, isSyntaxHighlighted: isSyntaxHighlighted, readOnly: readOnly) { [weak self] in self?.isCodemirrorReady = true } @@ -206,7 +225,7 @@ class SectionEditorViewController: ViewController { addScriptMessageHandlers(to: contentController) configuration.userContentController = contentController - webView = SectionEditorWebView(frame: .zero, configuration: configuration) + let webView = SectionEditorWebView(frame: .zero, configuration: configuration) webView.navigationDelegate = self webView.isHidden = true // hidden until wikitext is set @@ -226,6 +245,11 @@ class SectionEditorViewController: ViewController { let bottomConstraint = view.bottomAnchor.constraint(equalTo: webView.bottomAnchor) NSLayoutConstraint.activate([leadingConstraint, trailingConstraint, webViewTopConstraint, bottomConstraint]) + + // Fixes UI glitch where web view content animates in from the top left + view.setNeedsLayout() + view.layoutIfNeeded() + let folderURL = Bundle.wmf.assetsFolderURL let fileURL = folderURL.appendingPathComponent("codemirror/codemirror-index.html") webView.loadFileURL(fileURL, allowingReadAccessTo: folderURL) @@ -236,6 +260,7 @@ class SectionEditorViewController: ViewController { menuItemsController.delegate = self webView.menuItemsDataSource = menuItemsController webView.menuItemsDelegate = menuItemsController + self.webView = webView } @objc var shouldFocusWebView = true { @@ -308,8 +333,8 @@ class SectionEditorViewController: ViewController { guard didSetWikitextToWebView else { return } - webView.isHidden = false - webView.becomeFirstResponder() + webView?.isHidden = false + webView?.becomeFirstResponder() messagingController.focus { assert(Thread.isMainThread) self.delegate?.sectionEditorDidFinishLoadingWikitext(self) @@ -327,14 +352,19 @@ class SectionEditorViewController: ViewController { messagingController.setWikitext(wikitext, completionHandler: completionHandler) } - private func loadWikitext() { + private func loadWikitext(completion: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { let isShowingStatusMessage = shouldFocusWebView if isShowingStatusMessage { let message = WMFLocalizedString("wikitext-downloading", value: "Loading content...", comment: "Alert text shown when obtaining latest revision of the section being edited") WMFAlertManager.sharedInstance.showAlert(message, sticky: true, dismissPreviousAlerts: true) } - sectionFetcher.fetchSection(with: sectionID, articleURL: articleURL) { (result) in + sectionFetcher.fetchSection(with: sectionID, articleURL: articleURL) { [weak self] (result) in DispatchQueue.main.async { + + guard let self else { + return + } + if isShowingStatusMessage { WMFAlertManager.sharedInstance.dismissAlert() } @@ -343,14 +373,30 @@ class SectionEditorViewController: ViewController { self.didFocusWebViewCompletion = { WMFAlertManager.sharedInstance.showErrorAlert(error as NSError, sticky: true, dismissPreviousAlerts: true) } + completion(nil) case .success(let response): self.wikitext = response.wikitext self.handle(protection: response.protection) + + if let blockedError = response.blockedError { + completion(blockedError) + } else { + completion(nil) + } } } } } + private func presentErrorMessage(blockedError: MediaWikiAPIBlockedDisplayError) { + + guard let currentTitle = articleURL.wmf_title else { + return + } + + wmf_showBlockedPanel(messageHtml: blockedError.messageHtml, linkBaseURL: blockedError.linkBaseURL, currentTitle: currentTitle, theme: theme) + } + private func handle(protection: [SectionFetcher.Protection]) { let allowedGroups = protection.map { $0.level } guard !allowedGroups.isEmpty else { @@ -405,10 +451,14 @@ class SectionEditorViewController: ViewController { return } view.backgroundColor = theme.colors.paperBackground - webView.scrollView.backgroundColor = theme.colors.paperBackground - webView.backgroundColor = theme.colors.paperBackground - messagingController.applyTheme(theme: theme) - inputViewsController.apply(theme: theme) + webView?.scrollView.backgroundColor = theme.colors.paperBackground + webView?.backgroundColor = theme.colors.paperBackground + + if webView != nil { + messagingController.applyTheme(theme: theme) + inputViewsController.apply(theme: theme) + } + navigationItemController.apply(theme: theme) apply(presentationTheme: theme) focusNavigationView.apply(theme: theme) @@ -433,7 +483,7 @@ extension SectionEditorViewController: SectionEditorNavigationItemControllerDele messagingController.getWikitext { [weak self] (result, error) in guard let self = self else { return } - self.webView.resignFirstResponder() + self.webView?.resignFirstResponder() if let error = error { assertionFailure(error.localizedDescription) @@ -474,7 +524,7 @@ extension SectionEditorViewController: SectionEditorNavigationItemControllerDele func sectionEditorNavigationItemController(_ sectionEditorNavigationItemController: SectionEditorNavigationItemController, didTapReadingThemesControlsButton readingThemesControlsButton: UIBarButtonItem) { - webView.resignFirstResponder() + webView?.resignFirstResponder() inputViewsController.suppressMenus = true showReadingThemesControlsPopup(on: self, responder: self, theme: theme) @@ -640,7 +690,7 @@ extension SectionEditorViewController: SectionEditorWebViewMessagingControllerSc else { return } - self.webView.scrollView.setContentOffset(newContentOffset, animated: true) + self.webView?.scrollView.setContentOffset(newContentOffset, animated: true) } } @@ -759,7 +809,7 @@ extension SectionEditorViewController { inputViewsController.textFormattingProvidingDidTapFindInPage() } - var webViewForTesting: WKWebView { + var webViewForTesting: WKWebView? { return webView } diff --git a/Wikipedia/Code/SectionFetcher.swift b/Wikipedia/Code/SectionFetcher.swift index 46ce5806419..c252cf9d485 100644 --- a/Wikipedia/Code/SectionFetcher.swift +++ b/Wikipedia/Code/SectionFetcher.swift @@ -1,35 +1,46 @@ +import WMF + class SectionFetcher: Fetcher { - struct Protection: Codable { - let type: String? - let level: String? - let expiry: String? - } + + typealias Protection = SectionFetcher.APIResponse.Query.Page.Protection struct APIResponse: Codable { struct Query: Codable { - let pages: [String: Page]? - } - struct Page: Codable { - let pageid: Int? - let ns: Int? - let title: String? - let revisions: [Revision]? - let protection: [Protection]? - } - struct Revision: Codable { - let revid: Int - let slots: [String: Slot]? - } - struct Slot: Codable { - let contentmodel: String? - let contentformat: String? - let asterisk: String? - enum CodingKeys: String, CodingKey { - case contentmodel - case contentformat - case asterisk = "*" + struct Page: Codable { + struct Revision: Codable { + struct Slot: Codable { + let contentmodel: String? + let contentformat: String? + let content: String? + enum CodingKeys: String, CodingKey { + case contentmodel + case contentformat + case content + } + } + + let revid: Int + let slots: [String: Slot]? + } + + struct Protection: Codable { + let type: String? + let level: String? + let expiry: String? + } + + let pageid: Int? + let ns: Int? + let title: String? + let revisions: [Revision]? + let protection: [Protection]? + let restrictiontypes: [String]? + let actions: [String: [MediaWikiAPIError]]? } + + let pages: [Page]? } + let query: Query? } @@ -37,6 +48,7 @@ class SectionFetcher: Fetcher { let wikitext: String let revisionID: Int let protection: [Protection] + let blockedError: MediaWikiAPIBlockedDisplayError? } func fetchSection(with sectionID: Int, articleURL: URL, completion: @escaping (Result) -> Void) { @@ -55,23 +67,45 @@ class SectionFetcher: Fetcher { "inprop": "protection", "meta": "userinfo", // we need the local user ID for event logging "continue": "", - "format": "json" + "format": "json", + "formatversion": 2, + "errorformat": "html", + "errorsuselocal": "1", + "intestactions": "edit", // needed for fully resolved protection error. + "intestactionsdetail": "full" // needed for fully resolved protection error. ] - performDecodableMediaWikiAPIGET(for: articleURL, with: parameters) { (result: Result) in + + performDecodableMediaWikiAPIGET(for: articleURL, with: parameters) { [weak self] (result: Result) in + switch result { case .failure(let error): completion(.failure(error)) case .success(let apiResponse): guard - let page = apiResponse.query?.pages?.first?.value, - let wikitext = page.revisions?.first?.slots?["main"]?.asterisk, + let self, + let page = apiResponse.query?.pages?.first, + let wikitext = page.revisions?.first?.slots?["main"]?.content, let protection = page.protection, let revisionID = page.revisions?.first?.revid else { completion(.failure(RequestError.unexpectedResponse)) return } - completion(.success(Response(wikitext: wikitext, revisionID: revisionID, protection: protection))) + + guard let editErrors = page.actions?["edit"] as? [MediaWikiAPIError] else { + completion(.success(Response(wikitext: wikitext, revisionID: revisionID, protection: protection, blockedError: nil))) + return + } + + self.resolveMediaWikiBlockedError(from: editErrors, siteURL: articleURL) { blockedError in + + guard let blockedError else { + completion(.success(Response(wikitext: wikitext, revisionID: revisionID, protection: protection, blockedError: nil))) + return + } + + completion(.success(Response(wikitext: wikitext, revisionID: revisionID, protection: protection, blockedError: blockedError))) + } } } From a2325a61d105dddd53bf665becbcb0e505cfc975 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:07:18 -0600 Subject: [PATCH 06/17] Fix tests caused by previous commit --- .../SectionEditorFindAndReplaceTests.swift | 14 +++- .../Fixtures/BarackEarlyLife.json | 69 +++++++++---------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/WikipediaUnitTests/Code/SectionEditorFindAndReplaceTests.swift b/WikipediaUnitTests/Code/SectionEditorFindAndReplaceTests.swift index 8ebe54f9d21..d004e714454 100644 --- a/WikipediaUnitTests/Code/SectionEditorFindAndReplaceTests.swift +++ b/WikipediaUnitTests/Code/SectionEditorFindAndReplaceTests.swift @@ -134,7 +134,9 @@ class SectionEditorFindAndReplaceTests: XCTestCase { func testFindResultsStartingFromMidArticleUpdateToMatchLabel() { - let webView = sectionEditorViewController.webViewForTesting + guard let webView = sectionEditorViewController.webViewForTesting else { + return + } let cursorExpectation = expectation(description: "Waiting for set cursor callback") @@ -229,7 +231,10 @@ class SectionEditorFindAndReplaceTests: XCTestCase { wait(for: [findExpectation], timeout: timeout) - let webView = sectionEditorViewController.webViewForTesting + guard let webView = sectionEditorViewController.webViewForTesting else { + return + } + let userContentController = webView.configuration.userContentController // get current search cursor before tapping next @@ -315,7 +320,10 @@ class SectionEditorFindAndReplaceTests: XCTestCase { wait(for: [findExpectation], timeout: timeout) - let webView = sectionEditorViewController.webViewForTesting + guard let webView = sectionEditorViewController.webViewForTesting else { + return + } + let userContentController = webView.configuration.userContentController // get current search cursor before tapping next diff --git a/WikipediaUnitTests/Fixtures/BarackEarlyLife.json b/WikipediaUnitTests/Fixtures/BarackEarlyLife.json index 1fef8283a2c..3e6d940d1d1 100644 --- a/WikipediaUnitTests/Fixtures/BarackEarlyLife.json +++ b/WikipediaUnitTests/Fixtures/BarackEarlyLife.json @@ -1,22 +1,31 @@ { - "continue": { - "rvcontinue": "20190330231904|890220356", - "continue": "||userinfo" - }, - "warnings": { - "main": { - "*": "Subscribe to the mediawiki-api-announce mailing list at for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application." - }, - "revisions": { - "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used." - } - }, - "query": { - "pages": { - "534366": { - "pageid": 534366, - "ns": 0, - "title": "Barack Obama", + "batchcomplete": true, + "query": { + "pages": [ + { + "pageid": 534366, + "ns": 0, + "title": "Barack Obama", + "revisions": [ + { + "revid": 890577404, + "parentid": 890220356, + "slots": { + "main": { + "contentmodel": "wikitext", + "contentformat": "text/x-wiki", + "content": "== Early life and career ==\n{{Main|Early life and career of Barack Obama}}\nObama was born on August 4, 1961,{{cite web |year = 2008 |title = President Barack Obama |publisher = The White House |url = http://www.whitehouse.gov/administration/president-obama |accessdate = December 12, 2008 |deadurl=yes | archiveurl=https://web.archive.org/web/20091026043047/http://www.whitehouse.gov/administration/president-obama |archivedate=October 26, 2009 }} at [[Kapiolani Medical Center for Women and Children]] in [[Honolulu]], Hawaii.{{cite news |author = Maraniss, David |date = August 24, 2008 |title = Though Obama had to leave to find himself, it is Hawaii that made his rise possible |newspaper = The Washington Post |page = A22 |url = https://www.washingtonpost.com/wp-dyn/content/article/2008/08/23/AR2008082301620.html |accessdate = October 28, 2008 }}{{cite news |author = Nakaso, Dan |date = December 22, 2008 |title = Twin sisters, Obama on parallel paths for years |newspaper = [[The Honolulu Advertiser]] |page = B1 |url = http://the.honoluluadvertiser.com/article/2008/Dec/22/ln/hawaii812220320.html |accessdate = January 22, 2011 }} He is the only president who was born outside of the [[contiguous United States|contiguous 48 states]].{{cite book|last1=Barreto|first1=Amílcar Antonio|author2=Richard L. O'Bryant|title=American Identity in the Age of Obama|chapter-url=https://books.google.com/books?id=5VQVAgAAQBAJ&pg=PT18|accessdate=May 8, 2017|date=November 12, 2013|publisher=Taylor & Francis|isbn=978-1-317-93715-9|pages=18–19|chapter=Introduction}} He was born to a white mother and a black father. His mother, [[Ann Dunham]] (1942–1995), was born in [[Wichita, Kansas]]; she was mostly of English descent,Obama (1995, 2004), p. 12. with some German, Irish, Scottish, Swiss, and Welsh ancestry.{{cite journal|author=Smolenyak, Megan Smolenyak |date=November–December 2008 |title=The quest for Obama's Irish roots |journal=Ancestry |volume=26 |issue=6 |pages=46–47, 49 |issn=1075-475X |url=https://books.google.com/books?id=ITgEAAAAMBAJ&pg=PA46 |accessdate=December 20, 2011 }}\n* {{cite news|author=Smolenyak, Megan |date=May 9, 2011 |title=Tracing Barack Obama's Roots to Moneygall |url=http://www.huffingtonpost.com/megan-smolenyak-smolenyak/tracing-barack-obamas-roo_b_859151.html |work=[[HuffPost]] |accessdate=May 19, 2011 }}\n* {{cite news|author=Rising, David |author2=Noelting, Christoph |agency=Associated Press |date=June 4, 2009 |title=Researchers: Obama has German roots |work=USA Today |url=https://www.usatoday.com/news/washington/2009-06-04-obama-roots_N.htm |accessdate=May 13, 2010 }}\n* {{cite news|last=Hutton |first=Brian |agency=Press Association of Ireland |last2=Nickerson |first2=Matthew |date=May 3, 2007 |title=For sure, Obama's South Side Irish; One of his roots traces back to small village |newspaper=Chicago Sun-Times |page=3 |format=paid archive |url=http://nl.newsbank.com/nl-search/we/Archives?p_product=CSTB&p_theme=cstb&p_action=search&p_maxdocs=200&s_dispstring=(For%20sure)%20(%20Obama's%20South%20Side%20Irish)%20AND%20date(all)&p_field_advanced-0=&p_text_advanced-0=(For%20sure)%20(%20Obama's%20South%20Side%20Irish)Êl_numdocs=20&p_perpage=10&p_sort=YMD_date:DÊl_useweights=no |accessdate=November 24, 2008 }}\n* {{cite news|author=Jordon, Mary |date=May 13, 2007 |title=Tiny Irish village is latest place to claim Obama as its own |newspaper=The Washington Post |page=A14 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/05/12/AR2007051201551.html |accessdate=May 13, 2007 }}\n* {{cite news|author=David Williamson |date=July 5, 2008 |url=http://www.walesonline.co.uk/news/welsh-politics/welsh-politics-news/2008/07/05/genealogists-discover-a-red-dragon-breathing-fire-in-us-presidential-candidate-s-past-91466-21266440/ |title=Wales link in US presidential candidate's past |publisher=walesonline.co.uk |accessdate=April 30, 2011 |archiveurl=https://web.archive.org/web/20110521140204/http://www.walesonline.co.uk/news/welsh-politics/welsh-politics-news/2008/07/05/genealogists-discover-a-red-dragon-breathing-fire-in-us-presidential-candidate-s-past-91466-21266440/ |archivedate=May 21, 2011 |deadurl=yes |df= }} His father, [[Barack Obama Sr.]] (1936–1982), was a [[Luo people of Kenya and Tanzania|Luo Kenyan]] from [[Nyang'oma Kogelo]]. Obama's parents met in 1960 in a [[Russian language]] class at the [[University of Hawaii at Manoa]], where his father was a foreign student on a scholarship.{{cite news |author = Jones, Tim |date = March 27, 2007 |title = Barack Obama: Mother not just a girl from Kansas; Stanley Ann Dunham shaped a future senator |newspaper = [[Chicago Tribune]] |page = 1 (Tempo) |url = http://gbppr.dyndns.org/~gbpprorg/obama/barack.mother.txt |deadurl = yes |archiveurl = https://web.archive.org/web/20170207112933/http://gbppr.dyndns.org/~gbpprorg/obama/barack.mother.txt |archivedate = February 7, 2017 |df = mdy-all }}Obama (1995, 2004), pp. 9–10.\n* Scott (2011), pp. 80–86.\n* Jacobs (2011), pp. 115–118.\n* Maraniss (2012), pp. 154–160. The couple married in [[Wailuku, Hawaii]], on February 2, 1961, six months before Obama was born.{{cite news |author = Ripley, Amanda |date = April 9, 2008 |title = The story of Barack Obama's mother |work = [[Time (magazine)|Time]] |url = http://content.time.com/time/magazine/article/0,9171,1729685,00.html |accessdate = April 9, 2007 }}Scott (2011), p. 86.\n* Jacobs (2011), pp. 125–127.\n* Maraniss (2012), pp. 160–163.\n\nIn late August 1961 (a few weeks after he was born), Barack and his mother moved to the [[University of Washington]] in [[Seattle]], where they lived for a year. During that time, the elder Obama completed his undergraduate degree in [[economics]] in Hawaii, graduating in June 1962. He then left to attend graduate school on a scholarship at [[Harvard University]], where he earned an [[Master of Arts|M.A.]] in economics. Obama's parents divorced in March 1964.Scott (2011), pp. 87–93.\n* Jacobs (2011), pp. 115–118, 125–127, 133–161.\n* Maraniss (2012), pp. 170–183, 188–189. Obama Sr. returned to Kenya in 1964, where he married for a third time and worked for the Kenyan government as the Senior Economic Analyst in the Ministry of Finance.Obama \"Dreams from My Father a Story of Race and Inheritance\" He visited his son in Hawaii only once, at Christmas time in 1971,Scott (2011), pp. 142–144.\n* Jacobs (2011), pp. 161–177, 227–230.\n* Maraniss (2012), pp. 190–194, 201–209, 227–230. before he was killed in an automobile accident in 1982, when Obama was 21 years old.{{cite news |author = Ochieng, Philip |date = November 1, 2004 |title = From home squared to the US Senate: how Barack Obama was lost and found |newspaper = [[The EastAfrican]] |location = Nairobi |url = http://www.nationmedia.com/EastAfrican/01112004/Features/PA2-11.html |archivedate = September 27, 2007 |archiveurl = https://web.archive.org/web/20070927223905/http://www.nationmedia.com/EastAfrican/01112004/Features/PA2-11.html }}\n* {{cite news |author = Merida, Kevin |date = December 14, 2007 |title = The ghost of a father |newspaper = The Washington Post |page = A12 |url = https://www.washingtonpost.com/wp-dyn/content/story/2007/12/13/ST2007121301893.html |accessdate = June 25, 2008 }}\n* Jacobs (2011), pp. 251–255.\n* Maraniss (2012), pp. 411–417. Recalling his early childhood, Obama said, \"That my father looked nothing like the people around me – that he was black as pitch, my mother white as milk – barely registered in my mind.\" He described his struggles as a young adult to reconcile social perceptions of his multiracial heritage.{{cite news |author = Serrano, Richard A. |date = March 11, 2007 |title = Obama's peers didn't see his angst |newspaper = Los Angeles Times |page = A20 |url = http://www.latimes.com/news/politics/la-na-obamahawaii11-2007mar11,0,199085,full.story |accessdate = March 13, 2007 |deadurl = yes |archiveurl = https://web.archive.org/web/20081108080115/http://www.latimes.com/news/politics/la-na-obamahawaii11-2007mar11,0,199085,full.story |archivedate = November 8, 2008 |df = mdy-all }}\n* Obama (1995, 2004), Chapters 4 and 5.\n\nIn 1963, Dunham met [[Lolo Soetoro]] at the [[University of Hawaii]]; he was an [[Native Indonesian|Indonesian]] [[East–West Center]] [[graduate student]] in [[geography]]. The couple married on [[Molokai]] on March 15, 1965.Scott (2011), pp. 97–103.\n* Maraniss (2012), pp. 195–201, 225–230. After two one-year extensions of his [[J-1 visa]], Lolo returned to [[Indonesia]] in 1966. His wife and stepson followed sixteen months later in 1967. The family initially lived in the Menteng Dalam neighborhood in the [[Tebet, South Jakarta|Tebet]] subdistrict of [[south Jakarta]]. From 1970, they lived in a wealthier neighborhood in the [[Menteng]] subdistrict of [[central Jakarta]].Maraniss (2012), pp. 195–201, 209–223, 230–244.\n\n=== Education ===\nObama started out in St. Francis Pre-Education from age three to five. From age six to ten, he then attended local [[Indonesian Language|Indonesian-language]] schools: ''Sekolah Dasar Katolik Santo Fransiskus Asisi'' (St. Francis of Assisi Catholic Elementary School) for two years and ''[[State Elementary School Menteng 01|Sekolah Dasar Negeri Menteng 01]]'' (State Elementary School Menteng 01/Besuki school) for one and a half years, supplemented by English-language [[Calvert School]] homeschooling by his mother.Maraniss (2012), pp. 216, 221, 230, 234–244.{{cite web |url = http://www.calverteducation.com/calvert/barack-obama-calvert-homeschooler |title = Barack Obama: Calvert Homeschooler? – Calvert Education Blog |publisher = calverteducation.com |accessdate = November 25, 2015 |date = January 25, 2014 }} As a result of those four years in [[Jakarta]], he was able to speak [[Indonesian language|Indonesian]] fluently as a child.{{cite web |url = https://www.youtube.com/watch?v=JYIK9QtNu3w |title = Wawancara Eksklusif RCTI dengan Barack Obama (Part 2) |date = March 2010 |website = YouTube |accessdate = February 12, 2018}}{{cite web |title = Obama's Indonesian pleasantries: the video |url = http://languagelog.ldc.upenn.edu/nll/?p=1052 |author = Zimmer, Benjamin |date = January 23, 2009 |accessdate = October 7, 2012 |website = Language Log |publisher = [[University of Pennsylvania]] }} During his time in Indonesia, Obama's step-father taught him to be resilient and gave him \"a pretty hardheaded assessment of how the world works\".{{Cite news |url=http://www.newsweek.com/what-barack-obama-learned-his-father-88011 |title=What Barack Obama Learned from His Father |last=Meacham |first=Jon |date=August 22, 2008 |newspaper=Newsweek |archive-url=https://www.webcitation.org/6nNaxJYJG?url=http://www.newsweek.com/what-barack-obama-learned-his-father-88011?rx=us |archive-date=January 9, 2017 |dead-url=no |access-date=January 9, 2017 |df= }}\n\nIn 1971, Obama returned to [[Honolulu]] to live with his maternal grandparents, [[Madelyn Dunham|Madelyn]] and [[Stanley Armour Dunham|Stanley Dunham]]. He attended [[Punahou School]]— a private [[University-preparatory school|college preparatory school]]— with the aid of a scholarship from fifth grade until he graduated from high school in 1979.{{cite news |author = Serafin, Peter |date = March 21, 2004 |title = Punahou grad stirs up Illinois politics |newspaper = [[Honolulu Star-Bulletin]] |url = http://archives.starbulletin.com/2004/03/21/news/story4.html |accessdate = March 20, 2008 }}\n* {{cite news |author = Scott, Janny |date = March 14, 2008 |title = A free-spirited wanderer who set Obama's path |work = The New York Times |page = A1 |url = https://www.nytimes.com/2008/03/14/us/politics/14obama.html |accessdate = November 18, 2011 }}\n* Obama (1995, 2004), Chapters 3 and 4.\n* Scott (2012), pp. 131–134.\n* Maraniss (2012), pp. 264–269. In his youth, Obama went by the nickname \"Barry\".{{cite web |url = http://www.newsweek.com/when-barry-became-barack-84255 |title = When Barry Became Barack |last = Wolffe |first = Richard |date = March 22, 2008 |accessdate = March 21, 2016 |website = [[Newsweek]] }} Obama lived with his mother and half-sister, [[Maya Soetoro-Ng|Maya Soetoro]], in Hawaii for three years from 1972 to 1975 while his mother was a graduate student in [[anthropology]] at the [[University of Hawaii]].Scott (2011), pp. 139–157.\n* Maraniss (2012), pp. 279–281. Obama chose to stay in Hawaii with his grandparents for high school at [[Punahou School|Punahou]] when his mother and half-sister returned to Indonesia in 1975 so his mother could begin anthropology field work.Scott (2011), pp. 157–194.\n* Maraniss (2012), pp. 279–281, 324–326. His mother spent most of the next two decades in Indonesia, divorcing Lolo in 1980 and earning a [[PhD]] degree in 1992, before dying in 1995 in Hawaii following unsuccessful treatment for [[ovarian cancer|ovarian]] and [[uterine cancer]].Scott (2011), pp. 214, 294, 317–346.\n\nObama later reflected on his years in Honolulu and wrote: \"The opportunity that Hawaii offered – to experience a variety of cultures in a climate of mutual respect – became an integral part of my world view, and a basis for the values that I hold most dear.\"{{cite news |author = Reyes, B.J. |date = February 8, 2007 |title = Punahou left lasting impression on Obama |newspaper = Honolulu Star-Bulletin |url = http://archives.starbulletin.com/2007/02/08/news/story02.html |accessdate = February 10, 2007 |quote = As a teenager, Obama went to parties and sometimes sought out gatherings on military bases or at the University of Hawaii that were mostly attended by blacks. }} Obama has also written and talked about using alcohol, [[marijuana]], and [[cocaine]] during his teenage years to \"push questions of who I was out of my mind\".{{cite news|author=Elliott, Philip |agency=Associated Press |date=November 21, 2007 |title=Obama gets blunt with N.H. students |newspaper=[[Boston Globe]] |page=8A |url=http://articles.boston.com/2007-11-21/news/29233371_1_barack-obama-education-plan-campaign-trail |accessdate=May 18, 2012 |deadurl=yes |archiveurl=https://web.archive.org/web/20120407214401/http://articles.boston.com/2007-11-21/news/29233371_1_barack-obama-education-plan-campaign-trail |archivedate=April 7, 2012 |df= }} Obama was also a member of the \"choom gang\", a self-named group of friends that spent time together and occasionally smoked marijuana.{{cite news |author = Karl, Jonathan |publisher = ABC News |date = May 25, 2012 |title = Obama and his pot-smoking \"choom gang\" |url = http://abcnews.go.com/blogs/politics/2012/05/obama-and-his-pot-smoking-choom-gang/ |accessdate = May 25, 2012 }}\n* {{cite book |first = Barack |last = Obama |year = 2004 |orig-year = 1995 |url = https://books.google.com/books?id=HRCHJp-V0QUC&pg=PA93 |title = Dreams from My Father: A Story of Race and Inheritance |pages = 93–94 |accessdate = June 3, 2016 |isbn = 9780307394125 }}\n* {{cite book |first = David |last = Maraniss |year = 2012 |url = https://books.google.com/?id=Wnna9CLtblAC&q=choom |title = Barack Obama: The Story |at = pages with \"choom gang\" |accessdate = June 3, 2016 |isbn = 9781439167533 }}\n* for analysis of the political impact of the quote and Obama's more recent admission that he smoked marijuana as a teenager (\"When I was a kid, I inhaled\"), see:\n* {{cite news |author = Seelye, Katharine Q. |date = October 24, 2006 |title = Obama offers more variations from the norm |newspaper = The New York Times |page = A21 |url = https://query.nytimes.com/gst/fullpage.html?res=9D07E2DB173FF937A15753C1A9609C8B63 |accessdate = October 29, 2006 }}\n* {{cite news |author = Romano, Lois |date = January 3, 2007 |title = Effect of Obama's candor remains to be seen |newspaper = The Washington Post |page = A1 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/01/02/AR2007010201359.html |accessdate = January 14, 2007 }}{{cite web |url = http://video.pbs.org/video/2288869682/ |title = FRONTLINE The Choice 2012 |publisher = PBS |date = October 9, 2012 |accessdate = October 29, 2012 }}\n\nAfter graduating from high school in 1979, Obama moved to Los Angeles to attend [[Occidental College]]. In February 1981, Obama made his first public speech, calling for Occidental to participate in the [[disinvestment from South Africa]] in response to that nation's policy of [[apartheid]]. In mid-1981, Obama traveled to Indonesia to visit his mother and half-sister Maya, and visited the families of college friends in Pakistan and India for three weeks. Later in 1981, he transferred as a junior to [[Columbia College, Columbia University|Columbia University]] in New York City, where he majored in [[political science]] with a specialty in [[international relations]]{{cite news |author = Boss-Bicak, Shira |date = January 2005 |title = Barack Obama '83 |magazine = Columbia College Today |issn = 0572-7820 |url = http://www.college.columbia.edu/cct_archive/jan05/cover.php |accessdate = October 1, 2006 |archive-url = https://web.archive.org/web/20080905121815/http://www.college.columbia.edu/cct_archive/jan05/cover.php |archive-date = September 5, 2008 |dead-url = yes |df = mdy-all }} and in [[English literature]]{{Cite news|url=https://www.whitehouse.gov/the-press-office/2014/06/26/remarks-president-town-hall|title=Remarks by the President in Town Hall|date=June 26, 2014|publisher=White House|access-date=October 15, 2016}} and lived off-campus on West 109th Street.{{cite news |url = http://nymag.com/arts/all/approvalmatrix/approval-matrix-2012-8-27/ |title = The Approval Matrix |date = August 27, 2012 |work = New York }} He graduated with a [[Bachelor of Arts|BA]] degree in 1983 and worked for about a year at the [[Business International Corporation]], where he was a financial researcher and writer,{{Cite web |url=https://www.npr.org/templates/story/story.php?storyId=92337754 |title=Obama's Early Brush With Financial Markets |last=Horsley |first=Scott |date=July 9, 2008 |publisher=[[NPR]] |language=en |access-date=July 17, 2017}}{{cite web |author = Obama, Barack |year = 1998 |title = Curriculum vitae |publisher = The University of Chicago Law School |url = http://www.law.uchicago.edu/faculty/obama/cv.html |archivedate = May 9, 2001 |archiveurl = https://web.archive.org/web/20010509024017/http://www.law.uchicago.edu/faculty/obama/cv.html |accessdate = October 1, 2006 }}\n* {{cite news |author = Issenberg, Sasha |date = August 6, 2008 |title = Obama shows hints of his year in global finance; Tied markets to social aid |newspaper = Boston Globe |page = 1A |url = http://www.boston.com/news/nation/articles/2008/08/06/obama_shows_hints_of_his_year_in_global_finance/ |accessdate = August 6, 2008 |archiveurl = https://web.archive.org/web/20091107145054/http://www.boston.com/news/nation/articles/2008/08/06/obama_shows_hints_of_his_year_in_global_finance?page=full |archivedate = November 7, 2009 |deadurl = yes |df = mdy-all }} then as a project coordinator for the [[New York Public Interest Research Group]] on the [[City College of New York]] campus for three months in 1985.{{cite news |author = Scott, Janny |date = July 30, 2007 |title = Obama's account of New York often differs from what others say |newspaper = The New York Times |page = B1 |url = https://www.nytimes.com/2007/10/30/us/politics/30obama.html |accessdate = July 31, 2007 }}\n* Obama (1995, 2004), pp. 133–140.\n* Mendell (2007), pp. 62–63.{{cite book |editor = Chassie, Karen |year = 2007 |title = Who's Who in America, 2008 |page = 3468 |place = New Providence, NJ |publisher = Marquis Who's Who |isbn = 978-0-8379-7011-0 }}{{cite news |url = http://www.newsday.com/news/new-york/obama-stood-out-even-during-brief-1985-nypirg-job-1.885513 |title = Obama stood out, even during brief 1985 NYPIRG job |date = November 9, 2008 |newspaper = Newsday |first = Jason |last = Fink }}\n\n=== Family and personal life ===\n{{Main|Family of Barack Obama}}\n[[File:Obama family portrait in the Green Room.jpg|thumb|Obama posing in the [[Green Room (White House)|Green Room]] of the White House with wife Michelle and daughters Sasha and Malia, 2009]]\nIn a 2006 interview, Obama highlighted the diversity of [[family of Barack Obama|his extended family]]: \"It's like a little mini-United Nations\", he said. \"I've got relatives who look like [[Bernie Mac]], and I've got relatives who look like [[Margaret Thatcher]].\"{{cite web |url = http://www.oprah.com/slideshow/oprahshow/oprahshow1_ss_20061018/10 |title = Keeping Hope Alive: Barack Obama Puts Family First |date = October 18, 2006|website = The Oprah Winfrey Show |accessdate = June 24, 2008}} Obama has a half-sister with whom he was raised (Maya Soetoro-Ng) and seven other half-siblings from his Kenyan father's family—six of them living.{{cite news |first=Scott |last=Fornek |title=Half Siblings: 'A Complicated Family' |date=September 9, 2007 |url=http://www.suntimes.com/news/politics/obama/familytree/545462,BSX-News-wotrees09.stng |archiveurl=https://www.webcitation.org/5msGZ6sKn?url=http://www.suntimes.com/news/politics/obama/familytree/545462,BSX-News-wotrees09.stng |archivedate=January 18, 2010 |work=Chicago Sun-Times |accessdate=June 24, 2008 |deadurl=yes}} See also: {{cite news |url=http://www.suntimes.com/images/cds/special/family_tree.html |archiveurl=https://web.archive.org/web/20080703042659/http://www.suntimes.com/images/cds/special/family_tree.html |archivedate=July 3, 2008 |title=Interactive Family Tree |date=September 9, 2007 |work=Chicago Sun-Times |accessdate=June 24, 2008 }} Obama's mother was survived by her Kansas-born mother, [[Madelyn Dunham]],{{cite news |first=Scott |last=Fornek |title=Madelyn Payne Dunham: 'A Trailblazer' |date=September 9, 2007 |url=http://www.suntimes.com/news/politics/obama/familytree/545449,BSX-News-wotreeee09.stng |archiveurl=https://www.webcitation.org/5gm7oJqn9?url=http://www.suntimes.com/news/politics/obama/familytree/545449,BSX-News-wotreeee09.article |archivedate=May 14, 2009 |work=Chicago Sun-Times |accessdate=June 24, 2008 |deadurl=no}} until her death on November 2, 2008,{{cite news |url = http://www.cnn.com/2008/POLITICS/11/03/obama.grandma/index.html |title = Obama's grandmother dies after battle with cancer |publisher = CNN |accessdate = November 4, 2008 |date = November 3, 2008 |archiveurl = https://web.archive.org/web/20081103235343/http://www.cnn.com/2008/POLITICS/11/03/obama.grandma/index.html |archivedate = November 3, 2008 |deadurl = no }} two days before his election to the Presidency. Obama also has roots in Ireland; he met with his Irish cousins in [[Moneygall]] in May 2011.{{cite news |url = http://www.huffingtonpost.com/megan-smolenyak-smolenyak/tracing-barack-obamas-roo_b_859151.html |title = Tracing Barack Obama's Roots to Moneygall |date = May 9, 2011 |work = HuffPost |first = Megan |last = Smolenyak }} In ''Dreams from My Father'', Obama ties his mother's family history to possible Native American ancestors and distant relatives of [[Jefferson Davis]], [[President of the Confederate States of America]] during the [[American Civil War]]. He also shares distant ancestors in common with [[George W. Bush]] and [[Dick Cheney]], among others.Obama (1995, 2004), p. 13. For reports on Obama's maternal genealogy, including slave owners, Irish connections, and common ancestors with George W. Bush, [[Dick Cheney]], and [[Harry S. Truman]], see: {{cite news|first=David |last=Nitkin |author2=Harry Merritt |title=A New Twist to an Intriguing Family History |date=March 2, 2007 |url=http://www.baltimoresun.com/news/nationworld/politics/bal-te.obama02mar02,0,3453027.story |archiveurl=https://web.archive.org/web/20070930033339/http://www.baltimoresun.com/news/nationworld/politics/bal-te.obama02mar02%2C0%2C3453027.story |archivedate=September 30, 2007 |work=The Baltimore Sun |accessdate=June 24, 2008 |deadurl=yes |df= }}{{cite news|first=Mary |last=Jordan |title=Tiny Irish Village Is Latest Place to Claim Obama as Its Own |date=May 13, 2007 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/05/12/AR2007051201551.html |work=The Washington Post |accessdate=June 24, 2008 }}{{cite news|title=Obama's Family Tree Has a Few Surprises |date=September 8, 2007 |publisher=CBS 2 (Chicago) |url=http://cbs2chicago.com/topstories/Barack.Obama.family.2.339709.html |agency=Associated Press |accessdate=June 24, 2008 |archiveurl=https://web.archive.org/web/20080602215833/http://cbs2chicago.com/topstories/Barack.Obama.family.2.339709.html |archivedate=June 2, 2008 }}\n\n[[File:BlackhawksWhiteHouse2010.jpg|thumb|Obama with [[Jonathan Toews]] and the [[Stanley Cup]] champion [[Chicago Blackhawks]], 2010]]\nObama is a supporter of the [[Chicago White Sox]], and he threw out the first pitch at the [[2005 American League Championship Series|2005 ALCS]] when he was still a senator.{{cite news |title = Barack Obama: White Sox 'serious' ball |date = August 25, 2008 |first = Mark |last = Silva |work = Chicago Tribune |url = http://www.swamppolitics.com/news/politics/blog/2008/08/barack_obama_white_sox_serious.html |archiveurl = https://web.archive.org/web/20080829134235/http://www.swamppolitics.com/news/politics/blog/2008/08/barack_obama_white_sox_serious.html |archivedate = August 29, 2008 }} In 2009, he threw out the ceremonial first pitch at the [[2009 Major League Baseball All-Star Game|All-Star Game]] while wearing a White Sox jacket.{{cite web |title = Barack Obama Explains White Sox Jacket, Talks Nats in All-Star Booth Visit |date = July 14, 2009 |publisher = MLB Fanhouse |url = http://www.yardbarker.com/all_sports/articles/barack_obama_explains_white_sox_jacket_talks_nats_in_all_star_booth_visit/803700 |accessdate = December 6, 2009 }} He is also primarily a [[Chicago Bears]] football fan in the [[National Football League|NFL]], but in his childhood and adolescence was a [[Steeler Nation|fan of the Pittsburgh Steelers]], and rooted for them ahead of their victory in [[Super Bowl XLIII]] 12 days after he took office as president.{{cite news |last = Branigin |first = William |title = Steelers Win Obama's Approval |newspaper = The Washington Post |date = January 30, 2009 |url = https://www.washingtonpost.com/wp-dyn/content/article/2009/01/29/AR2009012903196.html |quote = But other than the Bears, the Steelers are probably the team that's closest to my heart. }} In 2011, Obama invited the [[1985 Chicago Bears season|1985 Chicago Bears]] to the White House; the team had not visited the White House after their [[Super Bowl XX|Super Bowl win]] in 1986 due to the [[Space Shuttle Challenger disaster]].{{cite web |last = Mayer |first = Larry |url = http://www.chicagobears.com/news/article-1/85-Bears-honored-by-President-Obama-at-White-House/A3C494F7-6681-44BB-850A-61EEE18315E4 |title = 1985 Bears honored by President Obama |publisher = [[Chicago Bears]] |date = October 7, 2011 |accessdate = November 4, 2012 |archive-url = https://web.archive.org/web/20130507094538/http://www.chicagobears.com/news/article-1/85-Bears-honored-by-President-Obama-at-White-House/A3C494F7-6681-44BB-850A-61EEE18315E4 |archive-date = May 7, 2013 |dead-url = yes |df = mdy-all }} He plays basketball, a sport he participated in as a member of his high school's varsity team,{{cite news |first = Jodi |last = Kantor |title = One Place Where Obama Goes Elbow to Elbow |date = June 1, 2007 |url = https://www.nytimes.com/2007/06/01/us/politics/01hoops.html |work = The New York Times |accessdate = April 28, 2008 |archiveurl = https://web.archive.org/web/20090401222632/http://www.nytimes.com/2007/06/01/us/politics/01hoops.html|archivedate=April 1, 2009 |deadurl = no }} See also: {{cite news |title = The Love of the Game |format = video |date = April 15, 2008 |work = Real Sports with Bryant Gumbel |publisher = HBO |url = http://www.hbo.com/real-sports-with-bryant-gumbel/episodes#/real-sports-with-bryant-gumbel/episodes/0/133-april-15-2008/index.html |accessdate = October 12, 2011 }} and he is left-handed.{{cite news |url = https://www.nytimes.com/2009/01/22/us/politics/22obama.html |title = On First Day, Obama Quickly Sets a New Tone |last = Stolberg |first = Sheryl Gay |author2 = Kirkpatrick, David D. |author3 = Shane, Scott |date = January 22, 2009 |work = The New York Times |page = 1 |accessdate = September 7, 2012 }}\n\n[[File:Barack Obama playing basketball with members of Congress and Cabinet secretaries 2.jpg|thumb|upright|left|alt=Obama about to take a shot while three other players look at him. One of those players attempts to block Obama.|Obama taking a left-handed [[Jump shot (basketball)|jump shot]] during a [[pickup game]] on the White House basketball court, 2009]]\n\nObama lived with anthropologist [[Sheila Miyoshi Jager]] while he was a community organizer in Chicago in the 1980s.{{cite news|last1=Hosie|first1=Rachel|title=BEFORE MICHELLE: THE STORY OF BARACK OBAMA'S PROPOSAL TO SHEILA MIYOSHI JAGER|url=https://www.independent.co.uk/life-style/before-michelle-barack-obama-sheila-miyoshi-jager-engagement-chicago-us-president-david-j-garrow-a7714771.html|accessdate=May 11, 2017|work=The Independent|date=May 3, 2017}} He proposed to her twice, but both Jager and her parents turned him down.{{cite news|last1=Tobias|first1=Andrew J.|title=Oberlin College professor received unsuccessful marriage proposal from Barack Obama in 1980s, new biography reveals|url=http://www.cleveland.com/politics/index.ssf/2017/05/oberlin_college_professor_rece.html|accessdate=May 11, 2017|work=The Plain Dealer|date=May 3, 2017}} The relationship was only made public in May 2017, several months after Obama's presidency had ended.\n\nIn June 1989, Obama met [[Michelle Obama|Michelle Robinson]] when he was employed as a summer associate at the Chicago law firm of [[Sidley Austin]].Obama (2006), pp. 327–332. See also: {{cite news |first = Sarah |last = Brown |title = Obama '85 masters balancing act |work = The Daily Princetonian |url = http://www.dailyprincetonian.com/2005/12/07/14049 |date = December 7, 2005 |accessdate = February 9, 2009 |archiveurl = https://web.archive.org/web/20090220165725/http://www.dailyprincetonian.com/2005/12/07/14049/ |archivedate = February 20, 2009 }} Robinson was assigned for three months as Obama's adviser at the firm, and she joined him at several group social functions but declined his initial requests to date.Obama (2006), p. 329. They began dating later that summer, became engaged in 1991, and were married on October 3, 1992.{{cite news |author=Fornek, Scott |title=Michelle Obama: 'He Swept Me Off My Feet' |date=October 3, 2007 |url=http://www.suntimes.com/news/politics/obama/585261,CST-NWS-wedding03.stng |archiveurl=https://www.webcitation.org/5msGZDbMO?url=http://www.suntimes.com/news/politics/obama/585261,CST-NWS-wedding03.stng |archivedate=January 18, 2010 |work=Chicago Sun-Times |accessdate=April 28, 2008 |deadurl=yes}} The couple's first daughter, Malia Ann, was born in 1998,{{cite web |url = http://www.politico.com/blogs/jonathanmartin/0708/Born_on_the_4th_of_July.html |title = Born on the 4th of July |date = July 4, 2008 |accessdate = July 10, 2008 |website = Politico |author = Martin, Jonathan |archiveurl = https://web.archive.org/web/20080710073536/http://www.politico.com/blogs/jonathanmartin/0708/Born_on_the_4th_of_July.html |archivedate = July 10, 2008 |deadurl = no }} followed by a second daughter, Natasha (\"Sasha\"), in 2001.Obama (1995, 2004), p. 440, and Obama (2006), pp. 339–340. See also: {{cite web |title = Election 2008 Information Center: Barack Obama |url = http://www.gannettnewsservice.com/?cat=153 |publisher = Gannett News Service |accessdate = April 28, 2008 }} The Obama daughters attended the [[University of Chicago Laboratory Schools]]. When they moved to Washington, D.C., in January 2009, the girls started at the [[Sidwell Friends School]].{{cite web |url = http://iht.com/articles/ap/2008/11/22/america/Obama-School.php |archiveurl = https://web.archive.org/web/20090129194323/http://iht.com/articles/ap/2008/11/22/america/Obama-School.php |title = Obamas choose private Sidwell Friends School |website = International Herald Tribune |date = November 22, 2008 |accessdate = July 2, 2015 |archivedate = January 29, 2009 }} The Obamas have two [[Portuguese Water Dog]]s; the first, a male named [[Bo (dog)|Bo]], was a gift from Senator [[Ted Kennedy]].{{cite news |url = https://www.nytimes.com/2009/04/13/us/politics/13obama.html |title = One Obama Search Ends With a Puppy Named Bo |work = The New York Times |date = April 13, 2009 |accessdate = December 22, 2010 |first = Helene |last = Cooper }} In 2013, Bo was joined by [[Sunny (dog)|Sunny]], a female.{{Cite journal |last = Feldmann |first = Linda |title = New little girl arrives at White House. Meet Sunny Obama. (+video) |url = http://www.csmonitor.com/USA/DC-Decoder/Decoder-Wire/2013/0820/New-little-girl-arrives-at-White-House.-Meet-Sunny-Obama.-video |journal = Christian Science Monitor |accessdate = August 20, 2013 |date = August 20, 2013 }}\n\n[[File:DIG13623-230.jpg|thumb|upright|Obama and his wife Michelle at the Civil Rights Summit at the [[LBJ Presidential Library]], 2014]]\nIn 2005, the family applied the proceeds of a book deal and moved from a [[Hyde Park, Chicago]] condominium to a $1.6 million house (equivalent to ${{Inflation|US|1.6|2005|r=1}} million in {{Inflation-year|US}}) in neighboring [[Kenwood, Chicago]].{{cite news |first=Jeff |last=Zeleny |title=The first time around: Sen. Obama's freshman year |date=December 24, 2005 |url=http://www.chicagotribune.com/news/local/chi-051224obama,0,1779783,full.story |work=Chicago Tribune |accessdate=April 28, 2008 |archiveurl=https://web.archive.org/web/20110513214525/http://www.chicagotribune.com/news/local/chi-051224obama%2C0%2C1779783%2Cfull.story |archivedate=May 13, 2011 |deadurl=yes |df= }} The purchase of an adjacent lot—and sale of part of it to Obama by the wife of developer, campaign donor and friend [[Tony Rezko]]—attracted media attention because of Rezko's subsequent indictment and conviction on political corruption charges that were unrelated to Obama.\n\nIn December 2007, ''[[Money (magazine)|Money Magazine]]'' estimated Obama's net worth at $1.3 million (equivalent to ${{Inflation|US|1.3|2007|r=1}} million in {{Inflation-year|US}}) .{{cite news |title = Obama's Money |date = December 7, 2007 |url = http://money.cnn.com/galleries/2007/moneymag/0712/gallery.candidates.moneymag/5.html |publisher = CNNMoney.com |accessdate = April 28, 2008 |first = Marlys |last = Harris |archiveurl = https://web.archive.org/web/20080424113420/http://money.cnn.com/galleries/2007/moneymag/0712/gallery.candidates.moneymag/5.html |archivedate = April 24, 2008 |deadurl = no }}
See also:{{cite news |first = Zachary A |last = Goldfarb |title = Measuring Wealth of the '08 Candidates |date = March 24, 2007 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/03/24/AR2007032400305.html |work = The Washington Post |accessdate = April 28, 2008 }}
Their 2009 tax return showed a household income of $5.5 million—up from about $4.2 million in 2007 and $1.6 million in 2005—mostly from sales of his books.{{cite news |first = Jeff |last = Zeleny |title = Book Sales Lifted Obamas' Income in 2007 to a Total of $4.2 Million |url = https://www.nytimes.com/2008/04/17/us/politics/17obama.html |date = April 17, 2008 |work = The New York Times |accessdate = April 28, 2008 |archiveurl = https://web.archive.org/web/20090416015848/http://www.nytimes.com/2008/04/17/us/politics/17obama.html|archivedate=April 16, 2009 |deadurl = no }}{{cite news |url = https://www.washingtonpost.com/wp-dyn/content/article/2010/04/15/AR2010041504485.html |title = Obamas report $5.5 million in income on 2009 tax return |work = The Washington Post |date = April 16, 2010 |accessdate = December 22, 2010 |first1 = Michael D. |last1 = Shear |first2 = David S. |last2 = Hilzenrath }} On his 2010 income of $1.7 million, he gave 14% to non-profit organizations, including $131,000 to [[Fisher House Foundation]], a charity assisting wounded veterans' families, allowing them to reside near where the veteran is receiving medical treatments.{{cite news |url = https://www.pbs.org/newshour/businessdesk/2011/04/how-much-did-president-obama-m.html |date = April 18, 2011 |title = How Much Did President Obama Make in 2010? |work = [[PBS NewsHour]] |first = Paul |last = Solman |archive-url = https://web.archive.org/web/20110502113725/http://www.pbs.org/newshour/businessdesk/2011/04/how-much-did-president-obama-m.html |archive-date = May 2, 2011 |accessdate = January 27, 2012 }}{{cite news |url = https://www.pbs.org/newshour/rundown/2011/04/the-obamas-gave-131000-to-the-fisher-house-foundation-last-year-what-is-it.html |date = April 27, 2011 |title = The Obamas Gave $131,000 to Fisher House Foundation in 2010; What Is It? |work = [[PBS NewsHour]] |first = Paul |last = Solman |archive-url = https://web.archive.org/web/20140129072652/http://www.pbs.org/newshour/rundown/2011/04/the-obamas-gave-131000-to-the-fisher-house-foundation-last-year-what-is-it.html |archive-date = January 29, 2014 |accessdate = January 27, 2012 }} Per his 2012 financial disclosure, Obama may be worth as much as $10 million.{{cite news |url = http://content.usatoday.com/communities/theoval/post/2012/05/obama-worth-as-much-as-10-million/1 |title = Obama worth as much as $10 million |last = Wolf |first = Richard |date = May 16, 2012 |work = [[USA Today]] |accessdate = June 16, 2012 }}\n\nIn early 2010, Michelle spoke about her husband's smoking habit and said that Barack had quit smoking.Elsner, Alan (December 7, 2008). [https://www.reuters.com/article/2008/12/07/us-usa-obama-smoking-idUSTRE4B61GF20081207 Obama says he won't be smoking in White House\"]. Reuters. Retrieved February 28, 2010.Zengerle, Patricia (February 8, 2011). [https://www.reuters.com/article/2011/02/08/us-obama-smoking-idUSTRE7176EL20110208 \"Yes, he did: first lady says Obama quit smoking\"]. Reuters. Retrieved May 9, 2011.\n\nOn his 55th birthday, August 4, 2016, Obama penned an essay in [[Glamour (magazine)|''Glamour'']], in which he described how his daughters and the presidency have made him a [[feminist]].{{cite news |url=http://www.glamour.com/story/glamour-exclusive-president-barack-obama-says-this-is-what-a-feminist-looks-like |title=Glamour Exclusive: President Barack Obama Says, \"This Is What a Feminist Looks Like\" |work=Glamour |date=August 4, 2016 |first=Barack |last=Obama |accessdate=August 5, 2016}}{{cite news |url=https://www.nytimes.com/2016/08/05/us/obama-writes-feminist-essay-in-glamour.html |title=Obama Writes Feminist Essay in Glamour |work=The New York Times |date=August 4, 2016 |first=Daniel |last=Victor |accessdate=August 5, 2016}}{{cite news |url=https://www.usatoday.com/story/life/entertainthis/2016/08/04/president-obama-glamour-s-important-sasha-and-malias-dad-feminist/88061556/ |title=President Obama in 'Glamour': It's important Sasha and Malia's dad is a feminist |work=USA Today |date=August 4, 2016 |first=Cara |last=Kelly |accessdate=August 5, 2016}}\n\n==== Religious views ====\nObama is a [[Protestant]] Christian whose religious views developed in his adult life. He wrote in ''[[The Audacity of Hope]]'' that he \"was not raised in a religious household\". He described his mother, raised by non-religious parents, as being detached from religion, yet \"in many ways the most spiritually awakened person that I have ever known.\" He described his father as a \"confirmed [[Atheism|atheist]]\" by the time his parents met, and his stepfather as \"a man who saw religion as not particularly useful.\" Obama explained how, through working with [[black church]]es as a [[Community organizing|community organizer]] while in his twenties, he came to understand \"the power of the African-American religious tradition to spur social change.\"\n\n[[File:Obamas at church on Inauguration Day 2013.jpg|thumb|The Obamas worship at [[African Methodist Episcopal Church]] in Washington, D.C., January 2013]]\nIn January 2008, Obama told ''[[Christianity Today]]'': \"I am a Christian, and I am a devout Christian. I believe in the [[Redeemer (Christianity)|redemptive death]] and [[resurrection of Jesus]] Christ. I believe that faith gives me a path to be cleansed of sin and have eternal life.\"{{cite news |last1 = Pulliam |first1 = Sarah |last2 = Olsen |first2 = Ted |url = http://www.christianitytoday.com/ct/2008/januaryweb-only/104-32.0.html?start=2 |title = Q&A: Barack Obama |work = Christianity Today |date = January 23, 2008 |accessdate = January 4, 2013 }} On September 27, 2010, Obama released a statement commenting on his religious views saying, \"I'm a Christian by choice. My family didn't – frankly, they weren't folks who went to church every week. And my mother was one of the most spiritual people I knew, but she didn't raise me in the church. So I came to my Christian faith later in life, and it was because the precepts of Jesus Christ spoke to me in terms of the kind of life that I would want to lead – being my brothers' and sisters' keeper, [[Golden Rule|treating others as they would treat me]].\"{{cite news|url=http://www.huffingtonpost.com/2010/09/28/obama-christian-by-choice_n_742124.html |title=Obama 'Christian By Choice': President Responds To Questioner |author=Charles Babington |author2=Darlene Superville |agency=Associated Press |date=September 28, 2010 |work=HuffPost |deadurl=yes |archiveurl=https://web.archive.org/web/20110511232554/http://www.huffingtonpost.com/2010/09/28/obama-christian-by-choice_n_742124.html |archivedate=May 11, 2011 }}{{cite web|url=http://blogs.abcnews.com/politicalpunch/2010/09/president-obama-i-am-a-christian-by-choicethe-precepts-of-jesus-spoke-to-me.html|title=President Obama: 'I am a Christian By Choice...The Precepts of Jesus Spoke to Me'|publisher=[[ABC News]]|date=September 29, 2010|accessdate=December 27, 2016}}\n\nObama met [[Trinity United Church of Christ]] pastor Rev. [[Jeremiah Wright]] in October 1987 and became a member of Trinity in 1992. During Obama's first presidential campaign in May 2008, he resigned from Trinity after [[Jeremiah Wright controversy|some of Wright's statements were criticized]].{{cite news |agency = Associated Press |date = November 17, 2008 |title = Obama's church choice likely to be scrutinized |publisher = MSNBC |url = http://www.msnbc.msn.com/id/27775757/ |accessdate = January 20, 2009 }} Since moving to Washington, D.C., in 2009, the Obama family has attended several Protestant churches, including [[Shiloh Baptist Church (Washington, D.C.)|Shiloh Baptist Church]] and [[St. John's Episcopal Church, Lafayette Square|St. John's Episcopal Church]], as well as Evergreen Chapel at [[Camp David]], but the members of the family do not attend church on a regular basis.Parker, Ashley. \"[https://www.nytimes.com/2013/12/29/us/as-the-obamas-celebrate-christmas-rituals-of-faith-stay-on-the-sidelines.html As the Obamas Celebrate Christmas, Rituals of Faith Become Less Visible],\" ''The New York Times'', December 28, 2013. Retrieved January 15, 2017.Gilgoff, Dan. \"[https://www.usnews.com/news/blogs/god-and-country/2009/06/30/time-report-white-house-reaction-raise-more-questions-about-obamas-church-hunt TIME Report, White House Reaction Raise More Questions About Obama's Church Hunt],\" ''U.S. News & World Report'', June 30, 2009. Retrieved January 15, 2017.\"[http://washington.cbslocal.com/2014/04/22/first-lady-we-use-sundays-for-naps-if-were-not-going-to-church/ \"First Lady: We Use Sundays For Naps If We're Not Going To Church\"], CBS DC, April 22, 2014. Retrieved January 15, 2017.\n\n=== Law career ===\n\n==== Community organizer and Harvard Law School ====\nTwo years after graduating from Columbia, Obama was back in Chicago when he was hired as director of the [[Developing Communities Project]], a church-based community organization originally comprising eight Catholic parishes in [[Roseland, Chicago|Roseland]], [[West Pullman, Chicago|West Pullman]], and [[Riverdale, Chicago|Riverdale]] on Chicago's [[South Side, Chicago|South Side]]. He worked there as a community organizer from June 1985 to May 1988.{{cite magazine|author=Lizza, Ryan |date=March 19, 2007 |title=The agitator: Barack Obama's unlikely political education |magazine=The New Republic |volume=236 |issue=12 |pages=22–26, 28–29 |issn=0028-6583 |url=http://www.tnr.com/article/the-agitator-barack-obamas-unlikely-political-education |accessdate=August 21, 2007 }}\n* {{cite news|author=Bob Secter |author2=John McCormick |date=March 30, 2007 |title=Portrait of a pragmatist |newspaper=Chicago Tribune |page=1 |url=http://www.chicagotribune.com/news/nationworld/chi-0703300121mar30-archive,0,2491692,full.story |archiveurl=https://web.archive.org/web/20091214172131/http://www.chicagotribune.com/news/nationworld/chi-0703300121mar30-archive%2C0%2C2491692%2Cfull.story |accessdate=May 18, 2012 |archivedate=December 14, 2009 |deadurl=yes |df= }}\n* Obama (1995, 2004), pp. 140–295.\n* Mendell (2007), pp. 63–83. He helped set up a job training program, a college preparatory tutoring program, and a tenants' rights organization in [[Altgeld Gardens Homes (Chicago, Illinois)|Altgeld Gardens]].{{cite news |author = Matchan, Linda |date = February 15, 1990 |title = A Law Review breakthrough |newspaper = Boston Globe |page = 29 |url = http://www.boston.com/news/politics/2008/articles/1990/02/15/a_law_review_breakthrough |accessdate = June 15, 2008 }}\n* {{cite news |author = Corr, John |date = February 27, 1990 |title = From mean streets to hallowed halls |newspaper = The Philadelphia Inquirer |page = C01 |format = paid archive |url = http://nl.newsbank.com/nl-search/we/Archives?p_multi=PI%7CDN%7C&p_product=PHNP&p_theme=phnp&p_action=search&p_maxdocs=200&s_dispstring=Author%28John%20Corr%29%20AND%20date%2802/27/1990%20to%2002/27/1990%29%20AND%20date%28all%29&p_field_advanced-0=Author&p_text_advanced-0=%28John%20Corr%29&p_bool_advanced-1=AND&p_params_advanced-1=date:B,E&p_field_advanced-1=YMD_date&p_text_advanced-1=%2802/27/1990%20to%2002/27/1990%29Êl_numdocs=20&p_perpage=10&p_sort=YMD_date:DÊl_useweights=no |accessdate = June 6, 2008 }} Obama also worked as a consultant and instructor for the [[Gamaliel Foundation]], a community organizing institute.{{cite magazine |author = Obama, Barack |date = August–September 1988 |title = Why organize? Problems and promise in the inner city |magazine = Illinois Issues |volume = 14 |issue = 8–9 |pages = 40–42 |issn = 0738-9663 }} reprinted in:
{{cite book |editor = Knoepfle, Peg |year = 1990 |title = After Alinsky: community organizing in Illinois |place = Springfield, IL |publisher = Sangamon State University |pages = 35–40 |isbn = 978-0-9620873-3-2 |quote = He has also been a consultant and instructor for the Gamaliel Foundation, an organizing institute working throughout the Midwest. }}
In mid-1988, he traveled for the first time in Europe for three weeks and then for five weeks in Kenya, where he met many of his [[Family of Barack Obama#Paternal relations|paternal relatives]] for the first time.{{cite book |last = Obama |first = Auma |year = 2012 |title = And then life happens: a memoir |location = New York |publisher = St. Martin's Press |isbn = 978-1-250-01005-6 |pages = 189–208, 212–216 }}Obama (1995, 2004), pp. 299–437.\n* Maraniss (2012), pp. 564–570.\n{{external media | float = right | video1 = [http://bostonlocaltv.org/catalog/V_UDAMVZGA4JEY06N Derrick Bell threatens to leave Harvard], April 24, 1990, 11:34, [[WGBH Educational Foundation|Boston TV Digital Archive]][http://bostonlocaltv.org/catalog/V_UDAMVZGA4JEY06N \"Ten O'Clock News; Derrick Bell threatens to leave Harvard\"], April 24, 1990, 11:34, [[WGBH Educational Foundation|WGBH]], [[American Archive of Public Broadcasting]] (WGBH and the [[Library of Congress]]), Boston and Washington, D.C.. Retrieved September 23, 2016. Student Barack Obama introduces Professor Derrick Bell starting at 6:25. }}\n\nObama entered [[Harvard Law School]] in the fall of 1988, living in nearby [[Somerville, Massachusetts]].{{cite news| newspaper=Somerville Scout| issue=January/February 2014| page=26 |title=Something in the Water|author1=Joey Del Ponte |author2=Somerville Scout Staff}} \"Barack Obama lived in the big, ivy-covered brick building at 365 Broadway ... From 1988 to 1991, the future president resided in a basement apartment while attending Harvard Law School.\" He was selected as an editor of the ''[[Harvard Law Review]]'' at the end of his first year,{{cite news |author = Michael Levenson |author2 = Jonathan Saltzman |date = January 28, 2007 |title = At Harvard Law, a unifying voice |newspaper = Boston Globe |page = 1A |url = http://www.boston.com/news/local/articles/2007/01/28/at_harvard_law_a_unifying_voice/?page=full |accessdate = June 15, 2008 }}\n* {{cite news |author = Kantor, Jodi |date = January 28, 2007 |title = In law school, Obama found political voice |newspaper = The New York Times |page = A1 |url = https://www.nytimes.com/2007/01/28/us/politics/28obama.html |accessdate = June 15, 2008 }}\n* {{cite news |author = Mundy, Liza |date = August 12, 2007 |title = A series of fortunate events |newspaper = The Washington Post |page = W10 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/08/08/AR2007080802038_pf.html |accessdate = June 15, 2008 }}\n* Mendell (2007), pp. 80–92. president of the journal in his second year,{{cite news |author = Butterfield, Fox |date = February 6, 1990 |title = First black elected to head Harvard's Law Review |newspaper = The New York Times |page = A20 |url = https://www.nytimes.com/1990/02/06/us/first-black-elected-to-head-harvard-s-law-review.html |accessdate = June 15, 2008 }}\n* {{cite news |author = Ybarra, Michael J |date = February 7, 1990 |title = Activist in Chicago now heads Harvard Law Review |newspaper = Chicago Tribune |page = 3 |url = http://articles.chicagotribune.com/1990-02-07/news/9001110408_1_ann-dunham-chicago-housing-authority-barack-obama |accessdate = October 29, 2011 }}\n* {{cite news |author = Drummond, Tammerlin |date = March 12, 1990 |title = Barack Obama's law; Harvard Law Review's first black president plans a life of public service |newspaper = Los Angeles Times |page = E1 |format = paid archive |url = https://pqasb.pqarchiver.com/latimes/access/60017156.html?dids=60017156:60017156&FMT=ABS&FMTS=ABS:FT |accessdate = June 15, 2008 }}\n* {{cite magazine |author = Evans, Gaynelle |date = March 15, 1990 |title = Opening another door: The saga of Harvard's Barack H. Obama |magazine = Black Issues in Higher Education |volume = 7 |issue = 1 |page = 5 |issn = 0742-0277 |url = http://diverseeducation.com/article/11791/ |accessdate = May 18, 2012 }}\n* {{cite news |author = Pugh, Allison J. |agency = Associated Press |date = April 18, 1990 |title = Law Review's first black president aims to help poor |newspaper = The Miami Herald |page = C01 |url = http://nl.newsbank.com/nl-search/we/Archives?p_multi=MH%7C&p_product=MH&p_theme=realcities2&p_action=search&p_maxdocs=200&s_site=miami&s_search_type=keyword&s_dispstring=Law%20Review%27s%20first%20black%20president%20aims%20to%20help%20poor%20AND%20date%28all%29&p_field_advanced-0=&p_text_advanced-0=%28Law%20Review%27s%20first%20black%20president%20aims%20to%20help%20poor%29Êl_numdocs=20&p_perpage=10&p_sort=YMD_date:DÊl_useweights=no |accessdate = June 15, 2008 }} and research assistant to the constitutional scholar [[Laurence Tribe]] while at Harvard for two years.{{YouTube|wzmmBZ7i4BQ}} During his summers, he returned to Chicago, where he worked as an [[Associate attorney|associate]] at the law firms of [[Sidley Austin]] in 1989 and [[Hopkins & Sutter]] in 1990.{{cite news |author = Aguilar, Louis |date = July 11, 1990 |title = Survey: Law firms slow to add minority partners |newspaper = Chicago Tribune |page = 1 (Business) |url = https://pqasb.pqarchiver.com/chicagotribune/access/28774085.html?dids=28774085:28774085&FMT=ABS&FMTS=ABS:FT |accessdate = June 15, 2008 }} After graduating with a [[Juris Doctor|JD]] degree ''[[magna cum laude]]'' from Harvard in 1991, he returned to Chicago. Obama's election as the [[List of African-American firsts|first black president of the ''Harvard Law Review'']] gained national media attention and led to a publishing contract and advance for a book about race relations,{{cite news |author = Scott, Janny |date = May 18, 2008 |title = The story of Obama, written by Obama |newspaper = The New York Times |page = A1 |url = https://www.nytimes.com/2008/05/18/us/politics/18memoirs.html |accessdate = June 15, 2008 }}\n* Obama (1995, 2004), pp. xiii–xvii. which evolved into a personal memoir. The manuscript was published in mid-1995 as ''[[Dreams from My Father]]''.\n\n==== Chicago Law School and civil rights attorney ====\nIn 1991, Obama accepted a two-year position as Visiting Law and Government Fellow at the [[University of Chicago Law School]] to work on his first book. He then taught [[constitutional law]] at the University of Chicago Law School for twelve years, first as a [[lecturer]] from 1992 to 1996, and then as a senior lecturer from 1996 to 2004.{{cite web |date = March 27, 2008 |title = Statement regarding Barack Obama |publisher = University of Chicago Law School |url = http://www.law.uchicago.edu/media/index.html |accessdate = June 5, 2008 |archiveurl = https://web.archive.org/web/20080608225931/http://www.law.uchicago.edu/media/index.html |archivedate = June 8, 2008 |deadurl = yes |df = mdy-all }}\n* {{cite web |author = Miller, Joe |date = March 28, 2008 |title = Was Barack Obama really a constitutional law professor? |publisher = FactCheck.org |url = http://factcheck.org/2008/03/obama-a-constitutional-law-professor/ |accessdate = May 18, 2012 }}\n* {{cite web |author = Holan, Angie Drobnic |date = March 7, 2008 |title = Obama's 20 years of experience |publisher = PolitiFact.com |url = http://www.politifact.com/truth-o-meter/article/2008/mar/07/obamas-20-years-experience |accessdate = June 10, 2008 }}\n\nFrom April to October 1992, Obama directed Illinois's [[Project Vote]], a [[voter registration campaign]] with ten staffers and seven hundred volunteer registrars; it achieved its goal of registering 150,000 of 400,000 unregistered African Americans in the state, leading ''[[Crain's Chicago Business]]'' to name Obama to its 1993 list of \"40 under Forty\" powers to be.\n\nHe joined Davis, Miner, Barnhill & Galland, a 13-attorney law firm specializing in civil rights litigation and neighborhood economic development, where he was an associate for three years from 1993 to 1996, then [[of counsel]] from 1996 to 2004. In 1994, he was listed as one of the lawyers in ''Buycks-Roberson v. Citibank Fed. Sav. Bank'', 94 C 4094 (N.D. Ill.).{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-9000.pdf |title = Civil Docket for Case #: 1:94-cv-04094 |author = United States District Court: Northern District of Illinois â€“ CM/ECF LIVE, Ver 3.0 (Chicago) |date = July 6, 1994 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} This [[Class-action lawsuit|class action lawsuit]] was filed in 1994 with Selma Buycks-Roberson as lead plaintiff and alleged that Citibank Federal Savings Bank had engaged in practices forbidden under the [[Equal Credit Opportunity Act]] and the [[Fair Housing Act]].{{cite web |url = http://www.clearinghouse.net/detail.php?id=10112 |title = Buycks-Roberson v. Citibank Fed. Sav. Bank – Civil Rights Litigation Clearinghouse |publisher = clearinghouse.net |accessdate = November 25, 2015 }} The case was settled out of court.{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-0008.pdf |title = Settlement Agreement |author = United States District Court for the Northern District of Illinois Eastern Division |date = January 16, 1988 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} Final judgment was issued on May 13, 1998, with Citibank Federal Savings Bank agreeing to pay attorney fees.{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-0010.pdf |title = Final Judgment and Order of Dismissal |author = United States District Cuurt For the Northern District of Illinois Eastern Division |date = May 13, 1998 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} His law license became inactive in 2007.{{cite web |url = http://www.factcheck.org/2012/06/the-obamas-law-licenses/ |title = The Obamas' Law Licenses |publisher = FactCheck.org |date = June 14, 2012 |accessdate = July 16, 2012 |author = Gore, D'Angelo }}\n\nFrom 1994 to 2002, Obama served on the boards of directors of the [[Woods Fund of Chicago]]—which in 1985 had been the first foundation to fund the Developing Communities Project—and of the [[Joyce Foundation]]. He served on the board of directors of the [[Chicago Annenberg Challenge]] from 1995 to 2002, as founding president and chairman of the board of directors from 1995 to 1999.\n\n=== Legislative career ===\n\n==== Illinois State Senator (1997–2004) ====\n{{Main|Illinois Senate career of Barack Obama}}\n[[File:Obamamiltondavis1.jpg|thumb|right|State Senator Obama and others celebrate the naming of a street in Chicago after [[ShoreBank]] co-founder Milton Davis in 1998]]\nObama was elected to the [[Illinois Senate]] in 1996, succeeding Democratic State Senator [[Alice Palmer (politician)|Alice Palmer]] from Illinois's 13th District, which, at that time, spanned Chicago South Side neighborhoods from [[Hyde Park, Chicago|Hyde Park]]–[[Kenwood, Chicago|Kenwood]] south to [[South Shore, Chicago|South Shore]] and west to [[Chicago Lawn, Chicago|Chicago Lawn]].{{cite news |first=David |last=Jackson |author2=Ray Long |title=Obama Knows His Way Around a Ballot |date=April 3, 2007 |url=http://www.chicagotribune.com/news/politics/obama/chi-070403obama-ballot-archive,0,5693903.story |archiveurl=https://web.archive.org/web/20081011054057/http://www.chicagotribune.com/news/politics/obama/chi-070403obama-ballot-archive%2C0%2C5693903.story |work=Chicago Tribune |accessdate=May 18, 2012 |archivedate=October 11, 2008 |deadurl=yes |df= }}\n* {{cite book |author = [[Jesse White (politician)|White, Jesse]] |year = 2001 |chapter = Legislative Districts of Cook County, 1991 Reapportionment |chapterurl = https://web.archive.org/web/20080226221919/http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf |title = Illinois Blue Book 2001–2002 |place = Springfield |publisher = [[Illinois Secretary of State]] |page = 65 |accessdate = July 16, 2011 |deadurl = bot: unknown |archiveurl = https://web.archive.org/web/20080226221919/http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf |archivedate = February 26, 2008 |df = mdy-all |url = http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf }} State Sen. District 13 = State Rep. Districts 25 & 26. Once elected, Obama gained bipartisan support for legislation that reformed ethics and health care laws.{{cite news|first=Peter |last=Slevin |title=Obama Forged Political Mettle in Illinois Capitol |date=February 9, 2007 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/02/08/AR2007020802262.html |work=The Washington Post |accessdate=April 20, 2008 }}{{cite news|first=Scott |last=Helman |title=In Illinois, Obama dealt with Lobbyists |date=September 23, 2007 |url=http://www.boston.com/news/nation/articles/2007/09/23/in_illinois_obama_dealt_with_lobbyists/ |work=Boston Globe |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080416235513/http://www.boston.com/news/nation/articles/2007/09/23/in_illinois_obama_dealt_with_lobbyists/ |archivedate=April 16, 2008 |deadurl=no |df= }} See also:{{cite news|title=Obama Record May Be Gold Mine for Critics |date=January 17, 2007 |publisher=CBS News |url=http://www.cbsnews.com/stories/2007/01/17/politics/main2369157.shtml |agency=Associated Press |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080412223055/http://www.cbsnews.com/stories/2007/01/17/politics/main2369157.shtml |archivedate=April 12, 2008 |deadurl=no }} He sponsored a law that increased [[tax credit]]s for low-income workers, negotiated [[welfare reform]], and promoted increased subsidies for childcare.{{cite news |first = Janny |last = Scott |title = In Illinois, Obama Proved Pragmatic and Shrewd |date = July 30, 2007 |url = https://www.nytimes.com/2007/07/30/us/politics/30obama.html |work = The New York Times |accessdate = April 20, 2008 |archiveurl = https://web.archive.org/web/20081210135903/http://www.nytimes.com/2007/07/30/us/politics/30obama.html|archivedate=December 10, 2008 |deadurl = no }} In 2001, as co-chairman of the bipartisan Joint Committee on Administrative Rules, Obama supported Republican Governor Ryan's [[payday loan]] regulations and [[Predatory lending|predatory mortgage lending]] regulations aimed at averting home [[foreclosure]]s.{{cite news|author=Allison, Melissa |date=December 15, 2000 |title=State takes on predatory lending; Rules would halt single-premium life insurance financing |url=https://pqasb.pqarchiver.com/chicagotribune/access/65214450.html?dids=65214450:65214450&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 (Business) |accessdate=June 1, 2008 |archiveurl=https://web.archive.org/web/20080617151154/https://pqasb.pqarchiver.com/chicagotribune/access/65214450.html?dids=65214450%3A65214450&FMT=ABS&FMTS=ABS%3AFT |archivedate=June 17, 2008 |deadurl=no |df= }}{{cite news|author=Ray Long |author2=Melissa Allison |date=April 18, 2001 |title=Illinois OKs predatory loan curbs; State aims to avert home foreclosures |url=https://pqasb.pqarchiver.com/chicagotribune/access/71459393.html?dids=71459393:71459393&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 |accessdate=June 1, 2008 }}\n\nHe was reelected to the Illinois Senate in 1998, defeating Republican Yesse Yehudah in the general election, and was re-elected again in 2002.{{cite web |url = http://www.senatedem.state.il.us/obama/index.html |title = 13th District: Barack Obama |accessdate = April 20, 2008 |date = August 24, 2000 |publisher = Illinois State Senate Democrats |archiveurl = https://web.archive.org/web/20000824102110/http://www.senatedem.state.il.us/obama/index.html |archivedate = April 12, 2000 }}{{cite web |url = http://www.senatedem.state.il.us/obama/index.html |title = 13th District: Barack Obama |accessdate = April 20, 2008 |date = October 9, 2004 |publisher = Illinois State Senate Democrats |archiveurl = https://web.archive.org/web/20040802233730/http://www.senatedem.state.il.us/obama/index.html |archivedate = August 2, 2004 }} In 2000, he lost a [[Illinois's 1st congressional district election, 2000|Democratic primary race]] for [[Illinois's 1st congressional district]] in the [[United States House of Representatives]] to four-term incumbent [[Bobby Rush]] by a margin of two to one.\n\nIn January 2003, Obama became chairman of the Illinois Senate's Health and Human Services Committee when Democrats, after a decade in the minority, regained a majority.{{cite news|first=Jackie |last=Calmes |title=Statehouse Yields Clues to Obama |date=February 23, 2007 |url=https://www.wsj.com/public/article/SB117219748197216894-Sn6oV_4KLQHp_xz7CjYLuyjv3Jg_20070324.html |work=The Wall Street Journal |accessdate=April 20, 2008 |deadurl=yes |archiveurl=https://web.archive.org/web/20080918032039/http://online.wsj.com/public/article/SB117219748197216894-Sn6oV_4KLQHp_xz7CjYLuyjv3Jg_20070324.html |archivedate=September 18, 2008 }} He sponsored and led unanimous, bipartisan passage of legislation to monitor [[racial profiling]] by requiring police to record the race of drivers they detained, and legislation making Illinois the first state to mandate videotaping of homicide interrogations.{{cite news|author=Tavella, Anne Marie |date=April 14, 2003 |title=Profiling, taping plans pass Senate |url=http://nl.newsbank.com/nl-search/we/Archives?p_product=ADHB&p_theme=adhb&p_action=search&p_maxdocs=200&p_text_search-0=Profiling,%20AND%20taping%20AND%20plans%20AND%20pass%20AND%20Senate&s_dispstring=Profiling,%20taping%20plans%20pass%20Senate%20AND%20date(April_4,_2003%20to%204/4/2003)&p_field_date-0=YMD_date&p_params_date-0=date:B,E&p_text_date-0=4_April_2003%20to%204/4/2003Êl_numdocs=20&p_perpage=10&p_sort=YMD_date:DÊl_useweights=no |format=paid archive |work=Daily Herald |page=17 |accessdate=June 1, 2008 }}{{cite news|author=Haynes, V. Dion |date=June 29, 2003 |title=Fight racial profiling at local level, lawmaker says; U.S. guidelines get mixed review |url=https://pqasb.pqarchiver.com/chicagotribune/access/352884461.html?dids=352884461:352884461&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=8 |accessdate=June 1, 2008 |archiveurl=https://web.archive.org/web/20080617150449/https://pqasb.pqarchiver.com/chicagotribune/access/352884461.html?dids=352884461%3A352884461&FMT=ABS&FMTS=ABS%3AFT |archivedate=June 17, 2008 |deadurl=no |df= }}{{cite news|author=Pearson, Rick |date=July 17, 2003 |title=Taped confessions to be law; State will be 1st to pass legislation |url=https://pqasb.pqarchiver.com/chicagotribune/access/370136121.html?dids=370136121:370136121&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 (Metro) |accessdate=June 1, 2008 }} During his 2004 general election campaign for the U.S. Senate, police representatives credited Obama for his active engagement with police organizations in enacting [[Capital punishment in the United States|death penalty]] reforms.{{cite news |first = Sam |last = Youngman |author2 = Aaron Blake |title = Obama's Crime Votes Are Fodder for Rivals |date = March 14, 2007 |url = http://thehill.com/homenews/news/11316-obamas-crime-votes-are-fodder-for-rivals |work = The Hill |accessdate = May 18, 2012 }} See also: {{cite news |title = US Presidential Candidate Obama Cites Work on State Death Penalty Reforms |date = November 12, 2007 |work = International Herald Tribune |url = http://www.iht.com/articles/ap/2007/11/12/america/NA-POL-US-Obama-Death-Penalty.php |archiveurl = https://web.archive.org/web/20080607111231/http://www.iht.com/articles/ap/2007/11/12/america/NA-POL-US-Obama-Death-Penalty.php |agency = Associated Press |accessdate = May 18, 2012 |archivedate = June 7, 2008 }} Obama resigned from the Illinois Senate in November 2004 following his election to the U.S. Senate.{{cite news|first=Melanie |last=Coffee |title=Attorney Chosen to Fill Obama's State Senate Seat |date=November 6, 2004 |publisher=HPKCC |url=http://www.hydepark.org/hpkccnews/raoul.htm#ap |agency=Associated Press |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080516174431/http://www.hydepark.org/hpkccnews/raoul.htm |archivedate=May 16, 2008 |deadurl=yes |df= }}\n\n==== 2004 U.S. Senate campaign ====\n{{Main|2004 United States Senate election in Illinois}}\n[[File:Illinois Senate Election Results by County, 2004.svg|upright=.5|thumb|County results of the 2004 U.S. Senate race in Illinois. Obama won the counties in blue.]]\nIn May 2002, Obama commissioned a poll to assess his prospects in a 2004 U.S. Senate race. He created a campaign committee, began raising funds, and lined up political media consultant [[David Axelrod (political consultant)|David Axelrod]] by August 2002. Obama formally announced his candidacy in January 2003.{{cite news |author = Helman, Scott |date = October 12, 2007 |title = Early defeat launched a rapid political climb |newspaper = [[Boston Globe]] |page = 1A |url = http://www.boston.com/news/nation/articles/2007/10/12/early_defeat_launched_a_rapid_political_climb |accessdate = April 13, 2008 }}\n\nObama was an early opponent of the [[George W. Bush]] administration's [[2003 invasion of Iraq]].{{cite news |author = Strausberg, Chinta |date = September 26, 2002 |title = Opposition to war mounts |newspaper = Chicago Defender |page = 1 |url = http://www.highbeam.com/doc/1P3-220062931.html |archive-url = https://web.archive.org/web/20110511195931/http://www.highbeam.com/doc/1P3-220062931.html |dead-url = yes |archive-date = May 11, 2011 |format = paid archive |accessdate = February 3, 2008 }} On October 2, 2002, the day President Bush and Congress agreed on the [[Iraq Resolution|joint resolution]] authorizing the [[Iraq War]], Obama addressed the first high-profile Chicago [[Protests against the Iraq War|anti-Iraq War rally]], and spoke out against the war. He addressed another anti-war rally in March 2003 and told the crowd that \"it's not too late\" to stop the war.\n\nDecisions by Republican incumbent [[Peter Fitzgerald (politician)|Peter Fitzgerald]] and his Democratic predecessor [[Carol Moseley Braun]] to not participate in the election resulted in wide-open Democratic and Republican primary contests involving 15 candidates.{{cite news |author = Davey, Monica |date = March 7, 2004 |title = Closely watched Illinois Senate race attracts 7 candidates in millionaire range |url = https://www.nytimes.com/2004/03/07/politics/campaign/07ILLI.html |archiveurl = https://web.archive.org/web/20090416015834/http://www.nytimes.com/2004/03/07/politics/campaign/07ILLI.html|archivedate=April 16, 2009 |newspaper = [[The New York Times]] |page = 19 |accessdate = April 13, 2008 }} In the March 2004 primary election, Obama won in an unexpected landslide—which overnight made him a rising star within the [[Democratic National Committee|national Democratic Party]], started speculation about a presidential future, and led to the reissue of his memoir, ''Dreams from My Father''. In July 2004, Obama delivered the keynote address at the [[2004 Democratic National Convention]],{{cite news |author = Bernstein, David |date = June 2007 |title = The Speech |magazine = Chicago Magazine |url = http://www.chicagomag.com/Chicago-Magazine/June-2007/The-Speech |accessdate = April 13, 2008 }} seen by 9.1 million viewers. His speech was well received and elevated his status within the Democratic Party.\n\nObama's expected opponent in the general election, Republican primary winner [[Jack Ryan (politician)|Jack Ryan]], withdrew from the race in June 2004.{{cite news |date = June 25, 2004 |title = Ryan drops out of Senate race in Illinois |publisher = CNN |url = http://www.cnn.com/2004/ALLPOLITICS/06/25/il.ryan/ |accessdate = May 18, 2012 }}\n* Mendell (2007), pp. 260–271. Six weeks later, [[Alan Keyes]] accepted the Republican nomination to replace Ryan.{{cite news |author = Lannan, Maura Kelly |agency = Associated Press |date = August 9, 2004 |title = Alan Keyes enters U.S. Senate race in Illinois against rising Democratic star |newspaper = Union-Tribune |url = http://legacy.signonsandiego.com/news/politics/20040809-0849-illinoissenate.html |accessdate = April 13, 2008 }} In the [[United States Senate election in Illinois, 2004|November 2004 general election]], Obama won with 70% of the vote.\n\n==== U.S. Senator from Illinois (2005–08) ====\n{{Main|United States Senate career of Barack Obama}}\n[[File:BarackObamaportrait.jpg|thumb|left|upright|The official portrait of Obama as a member of the United States Senate]]\nObama was sworn in as a senator on January 3, 2005,{{CongBio|o000167|inline=1|date=October 12, 2011}} becoming the only Senate member of the [[Congressional Black Caucus]].{{cite web |title = Member Info |url = http://www.house.gov/kilpatrick/cbc/member_info.html |archiveurl = https://web.archive.org/web/20080709114659/http://www.house.gov/kilpatrick/cbc/member_info.html |archivedate = July 9, 2008 |publisher = Congressional Black Caucus |accessdate = June 25, 2008 }} ''[[Congressional Quarterly|CQ Weekly]]'' characterized him as a \"loyal Democrat\" based on analysis of all Senate votes from 2005 to 2007. Obama announced on November 13, 2008, that he would [[resignation from the United States Senate|resign his Senate seat]] on November 16, 2008, before the start of the [[lame duck (politics)|lame-duck]] session, to focus on his transition period for the presidency.\n\n===== Legislation =====\n{{See also|List of bills sponsored by Barack Obama in the United States Senate}}\nObama [[Sponsor (legislative)|cosponsored]] the [[Secure America and Orderly Immigration Act]].{{cite web |first = 109th Congress, 1st Session |last = U.S. Senate |title = S. 1033, Secure America and Orderly Immigration Act |date = May 12, 2005 |url = https://www.congress.gov/bill/109th-congress/senate-bill/1033/cosponsors |publisher = Library of Congress |accessdate = February 25, 2017}} He introduced two initiatives that bore his name: Lugar–Obama, which expanded the [[Nunn–Lugar Cooperative Threat Reduction]] concept to conventional weapons;{{cite web |url = http://obama.senate.gov/press/070111-lugar-obama_non/ |title = Lugar–Obama Nonproliferation Legislation Signed into Law by the President |date = January 11, 2007 |publisher = Richard Lugar U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154746/http://obama.senate.gov/press/070111-lugar-obama_non/ |archivedate = December 18, 2008 }} See also: {{cite news |first = Richard G. |last = Lugar |author2 = Barack Obama |title = Junkyard Dogs of War |date = December 3, 2005 |url = https://www.washingtonpost.com/wp-dyn/content/article/2005/12/02/AR2005120201509.html |work = The Washington Post |accessdate = April 27, 2008 }} and the [[Federal Funding Accountability and Transparency Act of 2006]], which authorized the establishment of USAspending.gov, a web search engine on federal spending.{{cite news |first = John |last = McCormack |title = Google Government Gone Viral |date = December 21, 2007 |url = http://www.weeklystandard.com/Content/Public/Articles/000/000/014/502njiqx.asp |work = Weekly Standard |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20080423235240/http://www.weeklystandard.com/Content/Public/Articles/000/000/014/502njiqx.asp |archivedate = April 23, 2008 |deadurl = no }} See also: {{cite web |title = President Bush Signs Coburn–Obama Transparency Act |date = September 26, 2006 |url = http://coburn.senate.gov/ffm/index.cfm?FuseAction=LegislativeFloorAction.Home&ContentRecord_id=eb582f19-802a-23ad-41db-7a7cb464cfdb |archiveurl = https://web.archive.org/web/20080501233103/http://coburn.senate.gov/ffm/index.cfm?FuseAction=LegislativeFloorAction.Home&ContentRecord_id=eb582f19-802a-23ad-41db-7a7cb464cfdb |archivedate = May 1, 2008 |publisher = Tom Coburn U.S. Senate Office |accessdate = April 27, 2008 }} On June 3, 2008, Senator Obama—along with Senators [[Tom Carper]], [[Tom Coburn]], and [[John McCain]]—introduced follow-up legislation: Strengthening Transparency and Accountability in Federal Spending Act of 2008.{{cite web |url = http://www.govtrack.us/congress/bills/110/s3077 |title = S. 3077: Strengthening Transparency and Accountability in Federal Spending Act of 2008: 2007–2008 (110th Congress) |publisher = Govtrack.us |date = June 3, 2008 |accessdate = May 18, 2012 }}\n\nObama sponsored legislation that would have required nuclear plant owners to notify state and local authorities of radioactive leaks, but the bill failed to pass in the full Senate after being heavily modified in committee.{{cite news |last = McIntire |first = Mike |url = https://www.nytimes.com/2008/02/03/us/politics/03exelon.html |title = Nuclear Leaks and Response Tested Obama in Senate |date = February 3, 2008 |work = The New York Times |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081209065950/http://www.nytimes.com/2008/02/03/us/politics/03exelon.html|archivedate=December 9, 2008 |deadurl = no }} Regarding [[tort reform]], Obama voted for the [[Class Action Fairness Act of 2005]] and the [[Foreign Intelligence Surveillance Act of 1978 Amendments Act of 2008|FISA Amendments Act of 2008]], which grants immunity from civil liability to telecommunications companies complicit with [[NSA warrantless surveillance (2001–07)|NSA warrantless wiretapping]] operations.{{cite news |url = https://www.forbes.com/2008/08/08/obama-mccain-torts-biz-beltway-cz_df_0811torts.html |title = November Election A Lawyer's Delight |author = Fisher, Daniel |work = Forbes |date = August 11, 2008 |accessdate = January 11, 2009 }}\n[[File:Lugar-Obama.jpg|thumb|alt=Gray-haired man and Obama stand, wearing casual polo shirts. Obama wears sunglasses and holds something slung over his right shoulder.|left|Obama and U.S. Senator [[Richard Lugar]] (R-IN) visit a Russian facility for dismantling mobile missiles (August 2005){{cite web |title = Nunn–Lugar Report |date = August 2005 |publisher = Richard Lugar U.S. Senate Office |url = http://lugar.senate.gov/nunnlugar/pdf/trip_report_2005.pdf |archiveurl = https://web.archive.org/web/20080501002134/http://lugar.senate.gov/nunnlugar/pdf/trip_report_2005.pdf |archivedate = May 1, 2008 |accessdate = April 30, 2008 }}]]\n\nIn December 2006, President Bush signed into law the [[Democratic Republic of the Congo]] Relief, Security, and Democracy Promotion Act, marking the first federal legislation to be enacted with Obama as its primary sponsor.{{cite web |title = Democratic Republic of the Congo |date = April 2006 |url = http://www.usccb.org/sdwp/international/drc0406.shtml |publisher = United States Conference of Catholic Bishops |accessdate = January 26, 2012 |archiveurl = https://web.archive.org/web/20110108193726/http://www.usccb.org/sdwp/international/drc0406.shtml |archivedate = January 8, 2011 }}{{cite web |title = The IRC Welcomes New U.S. Law on Congo |date = January 5, 2007 |url = http://www.theirc.org/news/the-irc-welcomes-new-us-law.html |publisher = International Rescue Committee |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20110807061958/http://www.rescue.org/news/the-irc-welcomes-new-us-law.html |archivedate = August 7, 2011 }} In January 2007, Obama and Senator Feingold introduced a corporate jet provision to the [[Honest Leadership and Open Government Act]], which was signed into law in September 2007.{{cite news|first=Nathaniel |last=Weixel |title=Feingold, Obama Go After Corporate Jet Travel |date=November 15, 2007 |url=http://thehill.com/leading-the-news/feingold-obama-go-after-corporate-jet-travel-2007-11-15.html |work=The Hill |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080515201902/http://thehill.com/leading-the-news/feingold-obama-go-after-corporate-jet-travel-2007-11-15.html |archivedate=May 15, 2008 |deadurl=no }}{{cite news|first=Nathaniel |last=Weixel |title=Lawmakers Press FEC on Bundling Regulation |date=December 5, 2007 |url=http://thehill.com/leading-the-news/lawmakers-press-fec-on-bundling-regulation-2007-12-05.html |work=The Hill |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080416162108/http://thehill.com/leading-the-news/lawmakers-press-fec-on-bundling-regulation-2007-12-05.html |archivedate=April 16, 2008 |deadurl=no }} See also: {{cite news|title=Federal Election Commission Announces Plans to Issue New Regulations to Implement the Honest Leadership and Open Government Act of 2007 |date=September 24, 2007 |publisher=Federal Election Commission |url=http://www.fec.gov/press/press2007/20070924travel.shtml |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080411220016/http://www.fec.gov/press/press2007/20070924travel.shtml |archivedate=April 11, 2008 |deadurl=yes }} Obama also introduced two unsuccessful bills: the [[Deceptive Practices and Voter Intimidation Prevention Act]] to criminalize deceptive practices in federal elections,{{cite news |first = Seth |last = Stern |title = Obama–Schumer Bill Proposal Would Criminalize Voter Intimidation |date = January 31, 2007 |publisher = CQPolitics.com |url = https://www.nytimes.com/cq/2007/01/31/cq_2213.html |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20080516104256/http://www.nytimes.com/cq/2007/01/31/cq_2213.html |archivedate = May 16, 2008 |deadurl = no }}{{cite web |first = 110th Congress, 1st Session |last = U.S. Senate |title = S. 453, Deceptive Practices and Voter Intimidation Prevention Act of 2007 |date = January 31, 2007 |url = https://www.congress.gov/bill/110th-congress/senate-bill/453 |publisher = Library of Congress |accessdate = February 25, 2017}} See also: {{cite news |title = Honesty in Elections |date = January 31, 2007 |url = https://www.nytimes.com/2007/01/31/opinion/31wed1.html |work = The New York Times |format = editorial |accessdate = April 27, 2008 }} and the [[Iraq War De-Escalation Act of 2007]].{{cite news |first = E. Kasak |last = Krystin |title = Obama Introduces Measure to Bring Troops Home |date = February 7, 2007 |publisher = Medill News Service |url = http://www.nwitimes.com/news/local/article_c7147a5d-31bc-5497-abdd-a99c0cd6c189.html |accessdate = April 27, 2008 }}\n\nLater in 2007, Obama sponsored an amendment to the Defense Authorization Act to add safeguards for personality-disorder military discharges.{{cite web |title = Obama, Bond Hail New Safeguards on Military Personality Disorder Discharges, Urge Further Action |date = October 1, 2007 |url = http://bond.senate.gov/public/index.cfm?FuseAction=PressRoom.NewsReleases&ContentRecord_id=5C1EBFEB-1321-0E36-BA7D-04630AEFAD31 |publisher = Kit Bond U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20101205075008/http://bond.senate.gov/public/index.cfm?FuseAction=PressRoom.NewsReleases&ContentRecord_id=5C1EBFEB-1321-0E36-BA7D-04630AEFAD31 |archivedate = December 5, 2010 }} This amendment passed the full Senate in the spring of 2008.{{cite web |title = Obama, Bond Applaud Senate Passage of Amendment to Expedite the Review of Personality Disorder Discharge Cases |url = http://obama.senate.gov/press/080314-obama_bond_appl/ |archiveurl = https://web.archive.org/web/20081218154824/http://obama.senate.gov/press/080314-obama_bond_appl/ |archivedate = December 18, 2008 |date = March 14, 2008 }} He sponsored the [[Disinvestment from Iran|Iran Sanctions Enabling Act]] supporting divestment of state pension funds from Iran's oil and gas industry, which was never enacted but later incorporated in the [[Comprehensive Iran Sanctions, Accountability, and Divestment Act of 2010]];{{Cite web|url=https://www.govtrack.us/congress/bills/111/s1065|title=Iran Sanctions Enabling Act of 2009 (2009 – S. 1065)|website=GovTrack.us|language=en|access-date=August 27, 2018}} and co-sponsored legislation to reduce risks of nuclear terrorism. Obama also sponsored a Senate amendment to the [[State Children's Health Insurance Program]], providing one year of job protection for family members caring for soldiers with combat-related injuries.{{cite web |title = Senate Passes Obama, McCaskill Legislation to Provide Safety Net for Families of Wounded Service Members |date = August 2, 2007 |url = http://obama.senate.gov/press/070802-senate_passes_o_1/ |publisher = Barack Obama U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154819/http://obama.senate.gov/press/070802-senate_passes_o_1/ |archivedate = December 18, 2008 }}\n\n===== Committees =====\n[[File:Barack Obama Iraq 2006.jpg|thumb|Obama speaking with a soldier stationed in Iraq, 2006]]\nObama held assignments on the Senate Committees for [[United States Senate Committee on Foreign Relations|Foreign Relations]], [[United States Senate Committee on Environment and Public Works|Environment and Public Works]] and [[United States Senate Committee on Veterans' Affairs|Veterans' Affairs]] through December 2006.{{cite web |url = http://obama.senate.gov/committees/ |date = December 9, 2006 |title = Committee Assignments |accessdate = April 27, 2008 |publisher = Barack Obama U.S. Senate Office |archiveurl = https://web.archive.org/web/20061209190827/http://obama.senate.gov/committees/ |archivedate = December 9, 2006 }} In January 2007, he left the Environment and Public Works committee and took additional assignments with [[United States Senate Committee on Health, Education, Labor and Pensions|Health, Education, Labor and Pensions]] and [[United States Senate Committee on Homeland Security and Governmental Affairs|Homeland Security and Governmental Affairs]].{{cite news |title = Obama Gets New Committee Assignments |date = November 15, 2006 |publisher = Barack Obama U.S. Senate Office |url = http://obama.senate.gov/news/061115-obama_gets_new/ |agency = Associated Press |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154741/http://obama.senate.gov/news/061115-obama_gets_new/ |archivedate = December 18, 2008 }} He also became Chairman of the Senate's subcommittee on [[United States Senate Foreign Relations Subcommittee on Europe and Regional Security Cooperation|European Affairs]].{{cite news |first = Tom |last = Baldwin |title = Stay-At-Home Barack Obama Comes Under Fire for a Lack of Foreign Experience |date = December 21, 2007 |url = http://www.timesonline.co.uk/tol/news/world/us_and_americas/article3080794.ece |work = Sunday Times (UK) |accessdate = April 27, 2008 }} As a member of the Senate Foreign Relations Committee, Obama made official trips to Eastern Europe, the Middle East, Central Asia and Africa. He met with [[Mahmoud Abbas]] before Abbas became [[President of the Palestinian National Authority]], and gave a speech at the [[University of Nairobi]] in which he condemned corruption within the Kenyan government." + } + } + } + ], + "contentmodel": "wikitext", + "pagelanguage": "en", + "pagelanguagehtmlcode": "en", + "pagelanguagedir": "ltr", + "touched": "2023-01-27T15:33:50Z", + "lastrevid": 1135873781, + "length": 356834, "protection": [ { "type": "edit", @@ -33,22 +42,10 @@ "edit", "move" ], - "revisions": [{ - "revid": 1011021542, - "parentid": 1011006280, - "slots": { - "main": { - "contentformat": "text/x-wiki", - "contentmodel": "wikitext", - "*": "== Early life and career ==\n{{Main|Early life and career of Barack Obama}}\nObama was born on August 4, 1961,{{cite web |year = 2008 |title = President Barack Obama |publisher = The White House |url = http://www.whitehouse.gov/administration/president-obama |accessdate = December 12, 2008 |deadurl=yes | archiveurl=https://web.archive.org/web/20091026043047/http://www.whitehouse.gov/administration/president-obama |archivedate=October 26, 2009 }} at [[Kapiolani Medical Center for Women and Children]] in [[Honolulu]], Hawaii.{{cite news |author = Maraniss, David |date = August 24, 2008 |title = Though Obama had to leave to find himself, it is Hawaii that made his rise possible |newspaper = The Washington Post |page = A22 |url = https://www.washingtonpost.com/wp-dyn/content/article/2008/08/23/AR2008082301620.html |accessdate = October 28, 2008 }}{{cite news |author = Nakaso, Dan |date = December 22, 2008 |title = Twin sisters, Obama on parallel paths for years |newspaper = [[The Honolulu Advertiser]] |page = B1 |url = http://the.honoluluadvertiser.com/article/2008/Dec/22/ln/hawaii812220320.html |accessdate = January 22, 2011 }} He is the only president who was born outside of the [[contiguous United States|contiguous 48 states]].{{cite book|last1=Barreto|first1=Am\u00edlcar Antonio|author2=Richard L. O'Bryant|title=American Identity in the Age of Obama|chapter-url=https://books.google.com/books?id=5VQVAgAAQBAJ&pg=PT18|accessdate=May 8, 2017|date=November 12, 2013|publisher=Taylor & Francis|isbn=978-1-317-93715-9|pages=18\u201319|chapter=Introduction}} He was born to a white mother and a black father. His mother, [[Ann Dunham]] (1942\u20131995), was born in [[Wichita, Kansas]]; she was mostly of English descent,Obama (1995, 2004), p. 12. with some German, Irish, Scottish, Swiss, and Welsh ancestry.{{cite journal|author=Smolenyak, Megan Smolenyak |date=November\u2013December 2008 |title=The quest for Obama's Irish roots |journal=Ancestry |volume=26 |issue=6 |pages=46\u201347, 49 |issn=1075-475X |url=https://books.google.com/books?id=ITgEAAAAMBAJ&pg=PA46 |accessdate=December 20, 2011 }}\n* {{cite news|author=Smolenyak, Megan |date=May 9, 2011 |title=Tracing Barack Obama's Roots to Moneygall |url=http://www.huffingtonpost.com/megan-smolenyak-smolenyak/tracing-barack-obamas-roo_b_859151.html |work=[[HuffPost]] |accessdate=May 19, 2011 }}\n* {{cite news|author=Rising, David |author2=Noelting, Christoph |agency=Associated Press |date=June 4, 2009 |title=Researchers: Obama has German roots |work=USA Today |url=https://www.usatoday.com/news/washington/2009-06-04-obama-roots_N.htm |accessdate=May 13, 2010 }}\n* {{cite news|last=Hutton |first=Brian |agency=Press Association of Ireland |last2=Nickerson |first2=Matthew |date=May 3, 2007 |title=For sure, Obama's South Side Irish; One of his roots traces back to small village |newspaper=Chicago Sun-Times |page=3 |format=paid archive |url=http://nl.newsbank.com/nl-search/we/Archives?p_product=CSTB&p_theme=cstb&p_action=search&p_maxdocs=200&s_dispstring=(For%20sure)%20(%20Obama's%20South%20Side%20Irish)%20AND%20date(all)&p_field_advanced-0=&p_text_advanced-0=(For%20sure)%20(%20Obama's%20South%20Side%20Irish)\u00cal_numdocs=20&p_perpage=10&p_sort=YMD_date:D\u00cal_useweights=no |accessdate=November 24, 2008 }}\n* {{cite news|author=Jordon, Mary |date=May 13, 2007 |title=Tiny Irish village is latest place to claim Obama as its own |newspaper=The Washington Post |page=A14 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/05/12/AR2007051201551.html |accessdate=May 13, 2007 }}\n* {{cite news|author=David Williamson |date=July 5, 2008 |url=http://www.walesonline.co.uk/news/welsh-politics/welsh-politics-news/2008/07/05/genealogists-discover-a-red-dragon-breathing-fire-in-us-presidential-candidate-s-past-91466-21266440/ |title=Wales link in US presidential candidate's past |publisher=walesonline.co.uk |accessdate=April 30, 2011 |archiveurl=https://web.archive.org/web/20110521140204/http://www.walesonline.co.uk/news/welsh-politics/welsh-politics-news/2008/07/05/genealogists-discover-a-red-dragon-breathing-fire-in-us-presidential-candidate-s-past-91466-21266440/ |archivedate=May 21, 2011 |deadurl=yes |df= }} His father, [[Barack Obama Sr.]] (1936\u20131982), was a [[Luo people of Kenya and Tanzania|Luo Kenyan]] from [[Nyang'oma Kogelo]]. Obama's parents met in 1960 in a [[Russian language]] class at the [[University of Hawaii at Manoa]], where his father was a foreign student on a scholarship.{{cite news |author = Jones, Tim |date = March 27, 2007 |title = Barack Obama: Mother not just a girl from Kansas; Stanley Ann Dunham shaped a future senator |newspaper = [[Chicago Tribune]] |page = 1 (Tempo) |url = http://gbppr.dyndns.org/~gbpprorg/obama/barack.mother.txt |deadurl = yes |archiveurl = https://web.archive.org/web/20170207112933/http://gbppr.dyndns.org/~gbpprorg/obama/barack.mother.txt |archivedate = February 7, 2017 |df = mdy-all }}Obama (1995, 2004), pp. 9\u201310.\n* Scott (2011), pp. 80\u201386.\n* Jacobs (2011), pp. 115\u2013118.\n* Maraniss (2012), pp. 154\u2013160. The couple married in [[Wailuku, Hawaii]], on February 2, 1961, six months before Obama was born.{{cite news |author = Ripley, Amanda |date = April 9, 2008 |title = The story of Barack Obama's mother |work = [[Time (magazine)|Time]] |url = http://content.time.com/time/magazine/article/0,9171,1729685,00.html |accessdate = April 9, 2007 }}Scott (2011), p. 86.\n* Jacobs (2011), pp. 125\u2013127.\n* Maraniss (2012), pp. 160\u2013163.\n\nIn late August 1961 (a few weeks after he was born), Barack and his mother moved to the [[University of Washington]] in [[Seattle]], where they lived for a year. During that time, the elder Obama completed his undergraduate degree in [[economics]] in Hawaii, graduating in June 1962. He then left to attend graduate school on a scholarship at [[Harvard University]], where he earned an [[Master of Arts|M.A.]] in economics. Obama's parents divorced in March 1964.Scott (2011), pp. 87\u201393.\n* Jacobs (2011), pp. 115\u2013118, 125\u2013127, 133\u2013161.\n* Maraniss (2012), pp. 170\u2013183, 188\u2013189. Obama Sr. returned to Kenya in 1964, where he married for a third time and worked for the Kenyan government as the Senior Economic Analyst in the Ministry of Finance.Obama \"Dreams from My Father a Story of Race and Inheritance\" He visited his son in Hawaii only once, at Christmas time in 1971,Scott (2011), pp. 142\u2013144.\n* Jacobs (2011), pp. 161\u2013177, 227\u2013230.\n* Maraniss (2012), pp. 190\u2013194, 201\u2013209, 227\u2013230. before he was killed in an automobile accident in 1982, when Obama was 21 years old.{{cite news |author = Ochieng, Philip |date = November 1, 2004 |title = From home squared to the US Senate: how Barack Obama was lost and found |newspaper = [[The EastAfrican]] |location = Nairobi |url = http://www.nationmedia.com/EastAfrican/01112004/Features/PA2-11.html |archivedate = September 27, 2007 |archiveurl = https://web.archive.org/web/20070927223905/http://www.nationmedia.com/EastAfrican/01112004/Features/PA2-11.html }}\n* {{cite news |author = Merida, Kevin |date = December 14, 2007 |title = The ghost of a father |newspaper = The Washington Post |page = A12 |url = https://www.washingtonpost.com/wp-dyn/content/story/2007/12/13/ST2007121301893.html |accessdate = June 25, 2008 }}\n* Jacobs (2011), pp. 251\u2013255.\n* Maraniss (2012), pp. 411\u2013417. Recalling his early childhood, Obama said, \"That my father looked nothing like the people around me \u2013 that he was black as pitch, my mother white as milk \u2013 barely registered in my mind.\" He described his struggles as a young adult to reconcile social perceptions of his multiracial heritage.{{cite news |author = Serrano, Richard A. |date = March 11, 2007 |title = Obama's peers didn't see his angst |newspaper = Los Angeles Times |page = A20 |url = http://www.latimes.com/news/politics/la-na-obamahawaii11-2007mar11,0,199085,full.story |accessdate = March 13, 2007 |deadurl = yes |archiveurl = https://web.archive.org/web/20081108080115/http://www.latimes.com/news/politics/la-na-obamahawaii11-2007mar11,0,199085,full.story |archivedate = November 8, 2008 |df = mdy-all }}\n* Obama (1995, 2004), Chapters 4 and 5.\n\nIn 1963, Dunham met [[Lolo Soetoro]] at the [[University of Hawaii]]; he was an [[Native Indonesian|Indonesian]] [[East\u2013West Center]] [[graduate student]] in [[geography]]. The couple married on [[Molokai]] on March 15, 1965.Scott (2011), pp. 97\u2013103.\n* Maraniss (2012), pp. 195\u2013201, 225\u2013230. After two one-year extensions of his [[J-1 visa]], Lolo returned to [[Indonesia]] in 1966. His wife and stepson followed sixteen months later in 1967. The family initially lived in the Menteng Dalam neighborhood in the [[Tebet, South Jakarta|Tebet]] subdistrict of [[south Jakarta]]. From 1970, they lived in a wealthier neighborhood in the [[Menteng]] subdistrict of [[central Jakarta]].Maraniss (2012), pp. 195\u2013201, 209\u2013223, 230\u2013244.\n\n=== Education ===\nObama started out in St. Francis Pre-Education from age three to five. From age six to ten, he then attended local [[Indonesian Language|Indonesian-language]] schools: ''Sekolah Dasar Katolik Santo Fransiskus Asisi'' (St. Francis of Assisi Catholic Elementary School) for two years and ''[[State Elementary School Menteng 01|Sekolah Dasar Negeri Menteng 01]]'' (State Elementary School Menteng 01/Besuki school) for one and a half years, supplemented by English-language [[Calvert School]] homeschooling by his mother.Maraniss (2012), pp. 216, 221, 230, 234\u2013244.{{cite web |url = http://www.calverteducation.com/calvert/barack-obama-calvert-homeschooler |title = Barack Obama: Calvert Homeschooler? \u2013 Calvert Education Blog |publisher = calverteducation.com |accessdate = November 25, 2015 |date = January 25, 2014 }} As a result of those four years in [[Jakarta]], he was able to speak [[Indonesian language|Indonesian]] fluently as a child.{{cite web |url = https://www.youtube.com/watch?v=JYIK9QtNu3w |title = Wawancara Eksklusif RCTI dengan Barack Obama (Part 2) |date = March 2010 |website = YouTube |accessdate = February 12, 2018}}{{cite web |title = Obama's Indonesian pleasantries: the video |url = http://languagelog.ldc.upenn.edu/nll/?p=1052 |author = Zimmer, Benjamin |date = January 23, 2009 |accessdate = October 7, 2012 |website = Language Log |publisher = [[University of Pennsylvania]] }} During his time in Indonesia, Obama's step-father taught him to be resilient and gave him \"a pretty hardheaded assessment of how the world works\".{{Cite news |url=http://www.newsweek.com/what-barack-obama-learned-his-father-88011 |title=What Barack Obama Learned from His Father |last=Meacham |first=Jon |date=August 22, 2008 |newspaper=Newsweek |archive-url=https://www.webcitation.org/6nNaxJYJG?url=http://www.newsweek.com/what-barack-obama-learned-his-father-88011?rx=us |archive-date=January 9, 2017 |dead-url=no |access-date=January 9, 2017 |df= }}\n\nIn 1971, Obama returned to [[Honolulu]] to live with his maternal grandparents, [[Madelyn Dunham|Madelyn]] and [[Stanley Armour Dunham|Stanley Dunham]]. He attended [[Punahou School]]\u2014 a private [[University-preparatory school|college preparatory school]]\u2014 with the aid of a scholarship from fifth grade until he graduated from high school in 1979.{{cite news |author = Serafin, Peter |date = March 21, 2004 |title = Punahou grad stirs up Illinois politics |newspaper = [[Honolulu Star-Bulletin]] |url = http://archives.starbulletin.com/2004/03/21/news/story4.html |accessdate = March 20, 2008 }}\n* {{cite news |author = Scott, Janny |date = March 14, 2008 |title = A free-spirited wanderer who set Obama's path |work = The New York Times |page = A1 |url = https://www.nytimes.com/2008/03/14/us/politics/14obama.html |accessdate = November 18, 2011 }}\n* Obama (1995, 2004), Chapters 3 and 4.\n* Scott (2012), pp. 131\u2013134.\n* Maraniss (2012), pp. 264\u2013269. In his youth, Obama went by the nickname \"Barry\".{{cite web |url = http://www.newsweek.com/when-barry-became-barack-84255 |title = When Barry Became Barack |last = Wolffe |first = Richard |date = March 22, 2008 |accessdate = March 21, 2016 |website = [[Newsweek]] }} Obama lived with his mother and half-sister, [[Maya Soetoro-Ng|Maya Soetoro]], in Hawaii for three years from 1972 to 1975 while his mother was a graduate student in [[anthropology]] at the [[University of Hawaii]].Scott (2011), pp. 139\u2013157.\n* Maraniss (2012), pp. 279\u2013281. Obama chose to stay in Hawaii with his grandparents for high school at [[Punahou School|Punahou]] when his mother and half-sister returned to Indonesia in 1975 so his mother could begin anthropology field work.Scott (2011), pp. 157\u2013194.\n* Maraniss (2012), pp. 279\u2013281, 324\u2013326. His mother spent most of the next two decades in Indonesia, divorcing Lolo in 1980 and earning a [[PhD]] degree in 1992, before dying in 1995 in Hawaii following unsuccessful treatment for [[ovarian cancer|ovarian]] and [[uterine cancer]].Scott (2011), pp. 214, 294, 317\u2013346.\n\nObama later reflected on his years in Honolulu and wrote: \"The opportunity that Hawaii offered \u2013 to experience a variety of cultures in a climate of mutual respect \u2013 became an integral part of my world view, and a basis for the values that I hold most dear.\"{{cite news |author = Reyes, B.J. |date = February 8, 2007 |title = Punahou left lasting impression on Obama |newspaper = Honolulu Star-Bulletin |url = http://archives.starbulletin.com/2007/02/08/news/story02.html |accessdate = February 10, 2007 |quote = As a teenager, Obama went to parties and sometimes sought out gatherings on military bases or at the University of Hawaii that were mostly attended by blacks. }} Obama has also written and talked about using alcohol, [[marijuana]], and [[cocaine]] during his teenage years to \"push questions of who I was out of my mind\".{{cite news|author=Elliott, Philip |agency=Associated Press |date=November 21, 2007 |title=Obama gets blunt with N.H. students |newspaper=[[Boston Globe]] |page=8A |url=http://articles.boston.com/2007-11-21/news/29233371_1_barack-obama-education-plan-campaign-trail |accessdate=May 18, 2012 |deadurl=yes |archiveurl=https://web.archive.org/web/20120407214401/http://articles.boston.com/2007-11-21/news/29233371_1_barack-obama-education-plan-campaign-trail |archivedate=April 7, 2012 |df= }} Obama was also a member of the \"choom gang\", a self-named group of friends that spent time together and occasionally smoked marijuana.{{cite news |author = Karl, Jonathan |publisher = ABC News |date = May 25, 2012 |title = Obama and his pot-smoking \"choom gang\" |url = http://abcnews.go.com/blogs/politics/2012/05/obama-and-his-pot-smoking-choom-gang/ |accessdate = May 25, 2012 }}\n* {{cite book |first = Barack |last = Obama |year = 2004 |orig-year = 1995 |url = https://books.google.com/books?id=HRCHJp-V0QUC&pg=PA93 |title = Dreams from My Father: A Story of Race and Inheritance |pages = 93\u201394 |accessdate = June 3, 2016 |isbn = 9780307394125 }}\n* {{cite book |first = David |last = Maraniss |year = 2012 |url = https://books.google.com/?id=Wnna9CLtblAC&q=choom |title = Barack Obama: The Story |at = pages with \"choom gang\" |accessdate = June 3, 2016 |isbn = 9781439167533 }}\n* for analysis of the political impact of the quote and Obama's more recent admission that he smoked marijuana as a teenager (\"When I was a kid, I inhaled\"), see:\n* {{cite news |author = Seelye, Katharine Q. |date = October 24, 2006 |title = Obama offers more variations from the norm |newspaper = The New York Times |page = A21 |url = https://query.nytimes.com/gst/fullpage.html?res=9D07E2DB173FF937A15753C1A9609C8B63 |accessdate = October 29, 2006 }}\n* {{cite news |author = Romano, Lois |date = January 3, 2007 |title = Effect of Obama's candor remains to be seen |newspaper = The Washington Post |page = A1 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/01/02/AR2007010201359.html |accessdate = January 14, 2007 }}{{cite web |url = http://video.pbs.org/video/2288869682/ |title = FRONTLINE The Choice 2012 |publisher = PBS |date = October 9, 2012 |accessdate = October 29, 2012 }}\n\nAfter graduating from high school in 1979, Obama moved to Los Angeles to attend [[Occidental College]]. In February 1981, Obama made his first public speech, calling for Occidental to participate in the [[disinvestment from South Africa]] in response to that nation's policy of [[apartheid]]. In mid-1981, Obama traveled to Indonesia to visit his mother and half-sister Maya, and visited the families of college friends in Pakistan and India for three weeks. Later in 1981, he transferred as a junior to [[Columbia College, Columbia University|Columbia University]] in New York City, where he majored in [[political science]] with a specialty in [[international relations]]{{cite news |author = Boss-Bicak, Shira |date = January 2005 |title = Barack Obama '83 |magazine = Columbia College Today |issn = 0572-7820 |url = http://www.college.columbia.edu/cct_archive/jan05/cover.php |accessdate = October 1, 2006 |archive-url = https://web.archive.org/web/20080905121815/http://www.college.columbia.edu/cct_archive/jan05/cover.php |archive-date = September 5, 2008 |dead-url = yes |df = mdy-all }} and in [[English literature]]{{Cite news|url=https://www.whitehouse.gov/the-press-office/2014/06/26/remarks-president-town-hall|title=Remarks by the President in Town Hall|date=June 26, 2014|publisher=White House|access-date=October 15, 2016}} and lived off-campus on West 109th Street.{{cite news |url = http://nymag.com/arts/all/approvalmatrix/approval-matrix-2012-8-27/ |title = The Approval Matrix |date = August 27, 2012 |work = New York }} He graduated with a [[Bachelor of Arts|BA]] degree in 1983 and worked for about a year at the [[Business International Corporation]], where he was a financial researcher and writer,{{Cite web |url=https://www.npr.org/templates/story/story.php?storyId=92337754 |title=Obama's Early Brush With Financial Markets |last=Horsley |first=Scott |date=July 9, 2008 |publisher=[[NPR]] |language=en |access-date=July 17, 2017}}{{cite web |author = Obama, Barack |year = 1998 |title = Curriculum vitae |publisher = The University of Chicago Law School |url = http://www.law.uchicago.edu/faculty/obama/cv.html |archivedate = May 9, 2001 |archiveurl = https://web.archive.org/web/20010509024017/http://www.law.uchicago.edu/faculty/obama/cv.html |accessdate = October 1, 2006 }}\n* {{cite news |author = Issenberg, Sasha |date = August 6, 2008 |title = Obama shows hints of his year in global finance; Tied markets to social aid |newspaper = Boston Globe |page = 1A |url = http://www.boston.com/news/nation/articles/2008/08/06/obama_shows_hints_of_his_year_in_global_finance/ |accessdate = August 6, 2008 |archiveurl = https://web.archive.org/web/20091107145054/http://www.boston.com/news/nation/articles/2008/08/06/obama_shows_hints_of_his_year_in_global_finance?page=full |archivedate = November 7, 2009 |deadurl = yes |df = mdy-all }} then as a project coordinator for the [[New York Public Interest Research Group]] on the [[City College of New York]] campus for three months in 1985.{{cite news |author = Scott, Janny |date = July 30, 2007 |title = Obama's account of New York often differs from what others say |newspaper = The New York Times |page = B1 |url = https://www.nytimes.com/2007/10/30/us/politics/30obama.html |accessdate = July 31, 2007 }}\n* Obama (1995, 2004), pp. 133\u2013140.\n* Mendell (2007), pp. 62\u201363.{{cite book |editor = Chassie, Karen |year = 2007 |title = Who's Who in America, 2008 |page = 3468 |place = New Providence, NJ |publisher = Marquis Who's Who |isbn = 978-0-8379-7011-0 }}{{cite news |url = http://www.newsday.com/news/new-york/obama-stood-out-even-during-brief-1985-nypirg-job-1.885513 |title = Obama stood out, even during brief 1985 NYPIRG job |date = November 9, 2008 |newspaper = Newsday |first = Jason |last = Fink }}\n\n=== Family and personal life ===\n{{Main|Family of Barack Obama}}\n[[File:Obama family portrait in the Green Room.jpg|thumb|Obama posing in the [[Green Room (White House)|Green Room]] of the White House with wife Michelle and daughters Sasha and Malia, 2009]]\nIn a 2006 interview, Obama highlighted the diversity of [[family of Barack Obama|his extended family]]: \"It's like a little mini-United Nations\", he said. \"I've got relatives who look like [[Bernie Mac]], and I've got relatives who look like [[Margaret Thatcher]].\"{{cite web |url = http://www.oprah.com/slideshow/oprahshow/oprahshow1_ss_20061018/10 |title = Keeping Hope Alive: Barack Obama Puts Family First |date = October 18, 2006|website = The Oprah Winfrey Show |accessdate = June 24, 2008}} Obama has a half-sister with whom he was raised (Maya Soetoro-Ng) and seven other half-siblings from his Kenyan father's family\u2014six of them living.{{cite news |first=Scott |last=Fornek |title=Half Siblings: 'A Complicated Family' |date=September 9, 2007 |url=http://www.suntimes.com/news/politics/obama/familytree/545462,BSX-News-wotrees09.stng |archiveurl=https://www.webcitation.org/5msGZ6sKn?url=http://www.suntimes.com/news/politics/obama/familytree/545462,BSX-News-wotrees09.stng |archivedate=January 18, 2010 |work=Chicago Sun-Times |accessdate=June 24, 2008 |deadurl=yes}} See also: {{cite news |url=http://www.suntimes.com/images/cds/special/family_tree.html |archiveurl=https://web.archive.org/web/20080703042659/http://www.suntimes.com/images/cds/special/family_tree.html |archivedate=July 3, 2008 |title=Interactive Family Tree |date=September 9, 2007 |work=Chicago Sun-Times |accessdate=June 24, 2008 }} Obama's mother was survived by her Kansas-born mother, [[Madelyn Dunham]],{{cite news |first=Scott |last=Fornek |title=Madelyn Payne Dunham: 'A Trailblazer' |date=September 9, 2007 |url=http://www.suntimes.com/news/politics/obama/familytree/545449,BSX-News-wotreeee09.stng |archiveurl=https://www.webcitation.org/5gm7oJqn9?url=http://www.suntimes.com/news/politics/obama/familytree/545449,BSX-News-wotreeee09.article |archivedate=May 14, 2009 |work=Chicago Sun-Times |accessdate=June 24, 2008 |deadurl=no}} until her death on November 2, 2008,{{cite news |url = http://www.cnn.com/2008/POLITICS/11/03/obama.grandma/index.html |title = Obama's grandmother dies after battle with cancer |publisher = CNN |accessdate = November 4, 2008 |date = November 3, 2008 |archiveurl = https://web.archive.org/web/20081103235343/http://www.cnn.com/2008/POLITICS/11/03/obama.grandma/index.html |archivedate = November 3, 2008 |deadurl = no }} two days before his election to the Presidency. Obama also has roots in Ireland; he met with his Irish cousins in [[Moneygall]] in May 2011.{{cite news |url = http://www.huffingtonpost.com/megan-smolenyak-smolenyak/tracing-barack-obamas-roo_b_859151.html |title = Tracing Barack Obama's Roots to Moneygall |date = May 9, 2011 |work = HuffPost |first = Megan |last = Smolenyak }} In ''Dreams from My Father'', Obama ties his mother's family history to possible Native American ancestors and distant relatives of [[Jefferson Davis]], [[President of the Confederate States of America]] during the [[American Civil War]]. He also shares distant ancestors in common with [[George W. Bush]] and [[Dick Cheney]], among others.Obama (1995, 2004), p. 13. For reports on Obama's maternal genealogy, including slave owners, Irish connections, and common ancestors with George W. Bush, [[Dick Cheney]], and [[Harry S. Truman]], see: {{cite news|first=David |last=Nitkin |author2=Harry Merritt |title=A New Twist to an Intriguing Family History |date=March 2, 2007 |url=http://www.baltimoresun.com/news/nationworld/politics/bal-te.obama02mar02,0,3453027.story |archiveurl=https://web.archive.org/web/20070930033339/http://www.baltimoresun.com/news/nationworld/politics/bal-te.obama02mar02%2C0%2C3453027.story |archivedate=September 30, 2007 |work=The Baltimore Sun |accessdate=June 24, 2008 |deadurl=yes |df= }}{{cite news|first=Mary |last=Jordan |title=Tiny Irish Village Is Latest Place to Claim Obama as Its Own |date=May 13, 2007 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/05/12/AR2007051201551.html |work=The Washington Post |accessdate=June 24, 2008 }}{{cite news|title=Obama's Family Tree Has a Few Surprises |date=September 8, 2007 |publisher=CBS 2 (Chicago) |url=http://cbs2chicago.com/topstories/Barack.Obama.family.2.339709.html |agency=Associated Press |accessdate=June 24, 2008 |archiveurl=https://web.archive.org/web/20080602215833/http://cbs2chicago.com/topstories/Barack.Obama.family.2.339709.html |archivedate=June 2, 2008 }}\n\n[[File:BlackhawksWhiteHouse2010.jpg|thumb|Obama with [[Jonathan Toews]] and the [[Stanley Cup]] champion [[Chicago Blackhawks]], 2010]]\nObama is a supporter of the [[Chicago White Sox]], and he threw out the first pitch at the [[2005 American League Championship Series|2005 ALCS]] when he was still a senator.{{cite news |title = Barack Obama: White Sox 'serious' ball |date = August 25, 2008 |first = Mark |last = Silva |work = Chicago Tribune |url = http://www.swamppolitics.com/news/politics/blog/2008/08/barack_obama_white_sox_serious.html |archiveurl = https://web.archive.org/web/20080829134235/http://www.swamppolitics.com/news/politics/blog/2008/08/barack_obama_white_sox_serious.html |archivedate = August 29, 2008 }} In 2009, he threw out the ceremonial first pitch at the [[2009 Major League Baseball All-Star Game|All-Star Game]] while wearing a White Sox jacket.{{cite web |title = Barack Obama Explains White Sox Jacket, Talks Nats in All-Star Booth Visit |date = July 14, 2009 |publisher = MLB Fanhouse |url = http://www.yardbarker.com/all_sports/articles/barack_obama_explains_white_sox_jacket_talks_nats_in_all_star_booth_visit/803700 |accessdate = December 6, 2009 }} He is also primarily a [[Chicago Bears]] football fan in the [[National Football League|NFL]], but in his childhood and adolescence was a [[Steeler Nation|fan of the Pittsburgh Steelers]], and rooted for them ahead of their victory in [[Super Bowl XLIII]] 12 days after he took office as president.{{cite news |last = Branigin |first = William |title = Steelers Win Obama's Approval |newspaper = The Washington Post |date = January 30, 2009 |url = https://www.washingtonpost.com/wp-dyn/content/article/2009/01/29/AR2009012903196.html |quote = But other than the Bears, the Steelers are probably the team that's closest to my heart. }} In 2011, Obama invited the [[1985 Chicago Bears season|1985 Chicago Bears]] to the White House; the team had not visited the White House after their [[Super Bowl XX|Super Bowl win]] in 1986 due to the [[Space Shuttle Challenger disaster]].{{cite web |last = Mayer |first = Larry |url = http://www.chicagobears.com/news/article-1/85-Bears-honored-by-President-Obama-at-White-House/A3C494F7-6681-44BB-850A-61EEE18315E4 |title = 1985 Bears honored by President Obama |publisher = [[Chicago Bears]] |date = October 7, 2011 |accessdate = November 4, 2012 |archive-url = https://web.archive.org/web/20130507094538/http://www.chicagobears.com/news/article-1/85-Bears-honored-by-President-Obama-at-White-House/A3C494F7-6681-44BB-850A-61EEE18315E4 |archive-date = May 7, 2013 |dead-url = yes |df = mdy-all }} He plays basketball, a sport he participated in as a member of his high school's varsity team,{{cite news |first = Jodi |last = Kantor |title = One Place Where Obama Goes Elbow to Elbow |date = June 1, 2007 |url = https://www.nytimes.com/2007/06/01/us/politics/01hoops.html |work = The New York Times |accessdate = April 28, 2008 |archiveurl = https://web.archive.org/web/20090401222632/http://www.nytimes.com/2007/06/01/us/politics/01hoops.html|archivedate=April 1, 2009 |deadurl = no }} See also: {{cite news |title = The Love of the Game |format = video |date = April 15, 2008 |work = Real Sports with Bryant Gumbel |publisher = HBO |url = http://www.hbo.com/real-sports-with-bryant-gumbel/episodes#/real-sports-with-bryant-gumbel/episodes/0/133-april-15-2008/index.html |accessdate = October 12, 2011 }} and he is left-handed.{{cite news |url = https://www.nytimes.com/2009/01/22/us/politics/22obama.html |title = On First Day, Obama Quickly Sets a New Tone |last = Stolberg |first = Sheryl Gay |author2 = Kirkpatrick, David D. |author3 = Shane, Scott |date = January 22, 2009 |work = The New York Times |page = 1 |accessdate = September 7, 2012 }}\n\n[[File:Barack Obama playing basketball with members of Congress and Cabinet secretaries 2.jpg|thumb|upright|left|alt=Obama about to take a shot while three other players look at him. One of those players attempts to block Obama.|Obama taking a left-handed [[Jump shot (basketball)|jump shot]] during a [[pickup game]] on the White House basketball court, 2009]]\n\nObama lived with anthropologist [[Sheila Miyoshi Jager]] while he was a community organizer in Chicago in the 1980s.{{cite news|last1=Hosie|first1=Rachel|title=BEFORE MICHELLE: THE STORY OF BARACK OBAMA'S PROPOSAL TO SHEILA MIYOSHI JAGER|url=https://www.independent.co.uk/life-style/before-michelle-barack-obama-sheila-miyoshi-jager-engagement-chicago-us-president-david-j-garrow-a7714771.html|accessdate=May 11, 2017|work=The Independent|date=May 3, 2017}} He proposed to her twice, but both Jager and her parents turned him down.{{cite news|last1=Tobias|first1=Andrew J.|title=Oberlin College professor received unsuccessful marriage proposal from Barack Obama in 1980s, new biography reveals|url=http://www.cleveland.com/politics/index.ssf/2017/05/oberlin_college_professor_rece.html|accessdate=May 11, 2017|work=The Plain Dealer|date=May 3, 2017}} The relationship was only made public in May 2017, several months after Obama's presidency had ended.\n\nIn June 1989, Obama met [[Michelle Obama|Michelle Robinson]] when he was employed as a summer associate at the Chicago law firm of [[Sidley Austin]].Obama (2006), pp. 327\u2013332. See also: {{cite news |first = Sarah |last = Brown |title = Obama '85 masters balancing act |work = The Daily Princetonian |url = http://www.dailyprincetonian.com/2005/12/07/14049 |date = December 7, 2005 |accessdate = February 9, 2009 |archiveurl = https://web.archive.org/web/20090220165725/http://www.dailyprincetonian.com/2005/12/07/14049/ |archivedate = February 20, 2009 }} Robinson was assigned for three months as Obama's adviser at the firm, and she joined him at several group social functions but declined his initial requests to date.Obama (2006), p. 329. They began dating later that summer, became engaged in 1991, and were married on October 3, 1992.{{cite news |author=Fornek, Scott |title=Michelle Obama: 'He Swept Me Off My Feet' |date=October 3, 2007 |url=http://www.suntimes.com/news/politics/obama/585261,CST-NWS-wedding03.stng |archiveurl=https://www.webcitation.org/5msGZDbMO?url=http://www.suntimes.com/news/politics/obama/585261,CST-NWS-wedding03.stng |archivedate=January 18, 2010 |work=Chicago Sun-Times |accessdate=April 28, 2008 |deadurl=yes}} The couple's first daughter, Malia Ann, was born in 1998,{{cite web |url = http://www.politico.com/blogs/jonathanmartin/0708/Born_on_the_4th_of_July.html |title = Born on the 4th of July |date = July 4, 2008 |accessdate = July 10, 2008 |website = Politico |author = Martin, Jonathan |archiveurl = https://web.archive.org/web/20080710073536/http://www.politico.com/blogs/jonathanmartin/0708/Born_on_the_4th_of_July.html |archivedate = July 10, 2008 |deadurl = no }} followed by a second daughter, Natasha (\"Sasha\"), in 2001.Obama (1995, 2004), p. 440, and Obama (2006), pp. 339\u2013340. See also: {{cite web |title = Election 2008 Information Center: Barack Obama |url = http://www.gannettnewsservice.com/?cat=153 |publisher = Gannett News Service |accessdate = April 28, 2008 }} The Obama daughters attended the [[University of Chicago Laboratory Schools]]. When they moved to Washington, D.C., in January 2009, the girls started at the [[Sidwell Friends School]].{{cite web |url = http://iht.com/articles/ap/2008/11/22/america/Obama-School.php |archiveurl = https://web.archive.org/web/20090129194323/http://iht.com/articles/ap/2008/11/22/america/Obama-School.php |title = Obamas choose private Sidwell Friends School |website = International Herald Tribune |date = November 22, 2008 |accessdate = July 2, 2015 |archivedate = January 29, 2009 }} The Obamas have two [[Portuguese Water Dog]]s; the first, a male named [[Bo (dog)|Bo]], was a gift from Senator [[Ted Kennedy]].{{cite news |url = https://www.nytimes.com/2009/04/13/us/politics/13obama.html |title = One Obama Search Ends With a Puppy Named Bo |work = The New York Times |date = April 13, 2009 |accessdate = December 22, 2010 |first = Helene |last = Cooper }} In 2013, Bo was joined by [[Sunny (dog)|Sunny]], a female.{{Cite journal |last = Feldmann |first = Linda |title = New little girl arrives at White House. Meet Sunny Obama. (+video) |url = http://www.csmonitor.com/USA/DC-Decoder/Decoder-Wire/2013/0820/New-little-girl-arrives-at-White-House.-Meet-Sunny-Obama.-video |journal = Christian Science Monitor |accessdate = August 20, 2013 |date = August 20, 2013 }}\n\n[[File:DIG13623-230.jpg|thumb|upright|Obama and his wife Michelle at the Civil Rights Summit at the [[LBJ Presidential Library]], 2014]]\nIn 2005, the family applied the proceeds of a book deal and moved from a [[Hyde Park, Chicago]] condominium to a $1.6 million house (equivalent to ${{Inflation|US|1.6|2005|r=1}} million in {{Inflation-year|US}}) in neighboring [[Kenwood, Chicago]].{{cite news |first=Jeff |last=Zeleny |title=The first time around: Sen. Obama's freshman year |date=December 24, 2005 |url=http://www.chicagotribune.com/news/local/chi-051224obama,0,1779783,full.story |work=Chicago Tribune |accessdate=April 28, 2008 |archiveurl=https://web.archive.org/web/20110513214525/http://www.chicagotribune.com/news/local/chi-051224obama%2C0%2C1779783%2Cfull.story |archivedate=May 13, 2011 |deadurl=yes |df= }} The purchase of an adjacent lot\u2014and sale of part of it to Obama by the wife of developer, campaign donor and friend [[Tony Rezko]]\u2014attracted media attention because of Rezko's subsequent indictment and conviction on political corruption charges that were unrelated to Obama.\n\nIn December 2007, ''[[Money (magazine)|Money Magazine]]'' estimated Obama's net worth at $1.3 million (equivalent to ${{Inflation|US|1.3|2007|r=1}} million in {{Inflation-year|US}}) .{{cite news |title = Obama's Money |date = December 7, 2007 |url = http://money.cnn.com/galleries/2007/moneymag/0712/gallery.candidates.moneymag/5.html |publisher = CNNMoney.com |accessdate = April 28, 2008 |first = Marlys |last = Harris |archiveurl = https://web.archive.org/web/20080424113420/http://money.cnn.com/galleries/2007/moneymag/0712/gallery.candidates.moneymag/5.html |archivedate = April 24, 2008 |deadurl = no }}
See also:{{cite news |first = Zachary A |last = Goldfarb |title = Measuring Wealth of the '08 Candidates |date = March 24, 2007 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/03/24/AR2007032400305.html |work = The Washington Post |accessdate = April 28, 2008 }}
Their 2009 tax return showed a household income of $5.5 million\u2014up from about $4.2 million in 2007 and $1.6 million in 2005\u2014mostly from sales of his books.{{cite news |first = Jeff |last = Zeleny |title = Book Sales Lifted Obamas' Income in 2007 to a Total of $4.2 Million |url = https://www.nytimes.com/2008/04/17/us/politics/17obama.html |date = April 17, 2008 |work = The New York Times |accessdate = April 28, 2008 |archiveurl = https://web.archive.org/web/20090416015848/http://www.nytimes.com/2008/04/17/us/politics/17obama.html|archivedate=April 16, 2009 |deadurl = no }}{{cite news |url = https://www.washingtonpost.com/wp-dyn/content/article/2010/04/15/AR2010041504485.html |title = Obamas report $5.5 million in income on 2009 tax return |work = The Washington Post |date = April 16, 2010 |accessdate = December 22, 2010 |first1 = Michael D. |last1 = Shear |first2 = David S. |last2 = Hilzenrath }} On his 2010 income of $1.7 million, he gave 14% to non-profit organizations, including $131,000 to [[Fisher House Foundation]], a charity assisting wounded veterans' families, allowing them to reside near where the veteran is receiving medical treatments.{{cite news |url = https://www.pbs.org/newshour/businessdesk/2011/04/how-much-did-president-obama-m.html |date = April 18, 2011 |title = How Much Did President Obama Make in 2010? |work = [[PBS NewsHour]] |first = Paul |last = Solman |archive-url = https://web.archive.org/web/20110502113725/http://www.pbs.org/newshour/businessdesk/2011/04/how-much-did-president-obama-m.html |archive-date = May 2, 2011 |accessdate = January 27, 2012 }}{{cite news |url = https://www.pbs.org/newshour/rundown/2011/04/the-obamas-gave-131000-to-the-fisher-house-foundation-last-year-what-is-it.html |date = April 27, 2011 |title = The Obamas Gave $131,000 to Fisher House Foundation in 2010; What Is It? |work = [[PBS NewsHour]] |first = Paul |last = Solman |archive-url = https://web.archive.org/web/20140129072652/http://www.pbs.org/newshour/rundown/2011/04/the-obamas-gave-131000-to-the-fisher-house-foundation-last-year-what-is-it.html |archive-date = January 29, 2014 |accessdate = January 27, 2012 }} Per his 2012 financial disclosure, Obama may be worth as much as $10 million.{{cite news |url = http://content.usatoday.com/communities/theoval/post/2012/05/obama-worth-as-much-as-10-million/1 |title = Obama worth as much as $10 million |last = Wolf |first = Richard |date = May 16, 2012 |work = [[USA Today]] |accessdate = June 16, 2012 }}\n\nIn early 2010, Michelle spoke about her husband's smoking habit and said that Barack had quit smoking.Elsner, Alan (December 7, 2008). [https://www.reuters.com/article/2008/12/07/us-usa-obama-smoking-idUSTRE4B61GF20081207 Obama says he won't be smoking in White House\"]. Reuters. Retrieved February 28, 2010.Zengerle, Patricia (February 8, 2011). [https://www.reuters.com/article/2011/02/08/us-obama-smoking-idUSTRE7176EL20110208 \"Yes, he did: first lady says Obama quit smoking\"]. Reuters. Retrieved May 9, 2011.\n\nOn his 55th birthday, August 4, 2016, Obama penned an essay in [[Glamour (magazine)|''Glamour'']], in which he described how his daughters and the presidency have made him a [[feminist]].{{cite news |url=http://www.glamour.com/story/glamour-exclusive-president-barack-obama-says-this-is-what-a-feminist-looks-like |title=Glamour Exclusive: President Barack Obama Says, \"This Is What a Feminist Looks Like\" |work=Glamour |date=August 4, 2016 |first=Barack |last=Obama |accessdate=August 5, 2016}}{{cite news |url=https://www.nytimes.com/2016/08/05/us/obama-writes-feminist-essay-in-glamour.html |title=Obama Writes Feminist Essay in Glamour |work=The New York Times |date=August 4, 2016 |first=Daniel |last=Victor |accessdate=August 5, 2016}}{{cite news |url=https://www.usatoday.com/story/life/entertainthis/2016/08/04/president-obama-glamour-s-important-sasha-and-malias-dad-feminist/88061556/ |title=President Obama in 'Glamour': It's important Sasha and Malia's dad is a feminist |work=USA Today |date=August 4, 2016 |first=Cara |last=Kelly |accessdate=August 5, 2016}}\n\n==== Religious views ====\nObama is a [[Protestant]] Christian whose religious views developed in his adult life. He wrote in ''[[The Audacity of Hope]]'' that he \"was not raised in a religious household\". He described his mother, raised by non-religious parents, as being detached from religion, yet \"in many ways the most spiritually awakened person that I have ever known.\" He described his father as a \"confirmed [[Atheism|atheist]]\" by the time his parents met, and his stepfather as \"a man who saw religion as not particularly useful.\" Obama explained how, through working with [[black church]]es as a [[Community organizing|community organizer]] while in his twenties, he came to understand \"the power of the African-American religious tradition to spur social change.\"\n\n[[File:Obamas at church on Inauguration Day 2013.jpg|thumb|The Obamas worship at [[African Methodist Episcopal Church]] in Washington, D.C., January 2013]]\nIn January 2008, Obama told ''[[Christianity Today]]'': \"I am a Christian, and I am a devout Christian. I believe in the [[Redeemer (Christianity)|redemptive death]] and [[resurrection of Jesus]] Christ. I believe that faith gives me a path to be cleansed of sin and have eternal life.\"{{cite news |last1 = Pulliam |first1 = Sarah |last2 = Olsen |first2 = Ted |url = http://www.christianitytoday.com/ct/2008/januaryweb-only/104-32.0.html?start=2 |title = Q&A: Barack Obama |work = Christianity Today |date = January 23, 2008 |accessdate = January 4, 2013 }} On September 27, 2010, Obama released a statement commenting on his religious views saying, \"I'm a Christian by choice. My family didn't \u2013 frankly, they weren't folks who went to church every week. And my mother was one of the most spiritual people I knew, but she didn't raise me in the church. So I came to my Christian faith later in life, and it was because the precepts of Jesus Christ spoke to me in terms of the kind of life that I would want to lead \u2013 being my brothers' and sisters' keeper, [[Golden Rule|treating others as they would treat me]].\"{{cite news|url=http://www.huffingtonpost.com/2010/09/28/obama-christian-by-choice_n_742124.html |title=Obama 'Christian By Choice': President Responds To Questioner |author=Charles Babington |author2=Darlene Superville |agency=Associated Press |date=September 28, 2010 |work=HuffPost |deadurl=yes |archiveurl=https://web.archive.org/web/20110511232554/http://www.huffingtonpost.com/2010/09/28/obama-christian-by-choice_n_742124.html |archivedate=May 11, 2011 }}{{cite web|url=http://blogs.abcnews.com/politicalpunch/2010/09/president-obama-i-am-a-christian-by-choicethe-precepts-of-jesus-spoke-to-me.html|title=President Obama: 'I am a Christian By Choice...The Precepts of Jesus Spoke to Me'|publisher=[[ABC News]]|date=September 29, 2010|accessdate=December 27, 2016}}\n\nObama met [[Trinity United Church of Christ]] pastor Rev. [[Jeremiah Wright]] in October 1987 and became a member of Trinity in 1992. During Obama's first presidential campaign in May 2008, he resigned from Trinity after [[Jeremiah Wright controversy|some of Wright's statements were criticized]].{{cite news |agency = Associated Press |date = November 17, 2008 |title = Obama's church choice likely to be scrutinized |publisher = MSNBC |url = http://www.msnbc.msn.com/id/27775757/ |accessdate = January 20, 2009 }} Since moving to Washington, D.C., in 2009, the Obama family has attended several Protestant churches, including [[Shiloh Baptist Church (Washington, D.C.)|Shiloh Baptist Church]] and [[St. John's Episcopal Church, Lafayette Square|St. John's Episcopal Church]], as well as Evergreen Chapel at [[Camp David]], but the members of the family do not attend church on a regular basis.Parker, Ashley. \"[https://www.nytimes.com/2013/12/29/us/as-the-obamas-celebrate-christmas-rituals-of-faith-stay-on-the-sidelines.html As the Obamas Celebrate Christmas, Rituals of Faith Become Less Visible],\" ''The New York Times'', December 28, 2013. Retrieved January 15, 2017.Gilgoff, Dan. \"[https://www.usnews.com/news/blogs/god-and-country/2009/06/30/time-report-white-house-reaction-raise-more-questions-about-obamas-church-hunt TIME Report, White House Reaction Raise More Questions About Obama's Church Hunt],\" ''U.S. News & World Report'', June 30, 2009. Retrieved January 15, 2017.\"[http://washington.cbslocal.com/2014/04/22/first-lady-we-use-sundays-for-naps-if-were-not-going-to-church/ \"First Lady: We Use Sundays For Naps If We're Not Going To Church\"], CBS DC, April 22, 2014. Retrieved January 15, 2017.\n\n=== Law career ===\n\n==== Community organizer and Harvard Law School ====\nTwo years after graduating from Columbia, Obama was back in Chicago when he was hired as director of the [[Developing Communities Project]], a church-based community organization originally comprising eight Catholic parishes in [[Roseland, Chicago|Roseland]], [[West Pullman, Chicago|West Pullman]], and [[Riverdale, Chicago|Riverdale]] on Chicago's [[South Side, Chicago|South Side]]. He worked there as a community organizer from June 1985 to May 1988.{{cite magazine|author=Lizza, Ryan |date=March 19, 2007 |title=The agitator: Barack Obama's unlikely political education |magazine=The New Republic |volume=236 |issue=12 |pages=22\u201326, 28\u201329 |issn=0028-6583 |url=http://www.tnr.com/article/the-agitator-barack-obamas-unlikely-political-education |accessdate=August 21, 2007 }}\n* {{cite news|author=Bob Secter |author2=John McCormick |date=March 30, 2007 |title=Portrait of a pragmatist |newspaper=Chicago Tribune |page=1 |url=http://www.chicagotribune.com/news/nationworld/chi-0703300121mar30-archive,0,2491692,full.story |archiveurl=https://web.archive.org/web/20091214172131/http://www.chicagotribune.com/news/nationworld/chi-0703300121mar30-archive%2C0%2C2491692%2Cfull.story |accessdate=May 18, 2012 |archivedate=December 14, 2009 |deadurl=yes |df= }}\n* Obama (1995, 2004), pp. 140\u2013295.\n* Mendell (2007), pp. 63\u201383. He helped set up a job training program, a college preparatory tutoring program, and a tenants' rights organization in [[Altgeld Gardens Homes (Chicago, Illinois)|Altgeld Gardens]].{{cite news |author = Matchan, Linda |date = February 15, 1990 |title = A Law Review breakthrough |newspaper = Boston Globe |page = 29 |url = http://www.boston.com/news/politics/2008/articles/1990/02/15/a_law_review_breakthrough |accessdate = June 15, 2008 }}\n* {{cite news |author = Corr, John |date = February 27, 1990 |title = From mean streets to hallowed halls |newspaper = The Philadelphia Inquirer |page = C01 |format = paid archive |url = http://nl.newsbank.com/nl-search/we/Archives?p_multi=PI%7CDN%7C&p_product=PHNP&p_theme=phnp&p_action=search&p_maxdocs=200&s_dispstring=Author%28John%20Corr%29%20AND%20date%2802/27/1990%20to%2002/27/1990%29%20AND%20date%28all%29&p_field_advanced-0=Author&p_text_advanced-0=%28John%20Corr%29&p_bool_advanced-1=AND&p_params_advanced-1=date:B,E&p_field_advanced-1=YMD_date&p_text_advanced-1=%2802/27/1990%20to%2002/27/1990%29\u00cal_numdocs=20&p_perpage=10&p_sort=YMD_date:D\u00cal_useweights=no |accessdate = June 6, 2008 }} Obama also worked as a consultant and instructor for the [[Gamaliel Foundation]], a community organizing institute.{{cite magazine |author = Obama, Barack |date = August\u2013September 1988 |title = Why organize? Problems and promise in the inner city |magazine = Illinois Issues |volume = 14 |issue = 8\u20139 |pages = 40\u201342 |issn = 0738-9663 }} reprinted in:
{{cite book |editor = Knoepfle, Peg |year = 1990 |title = After Alinsky: community organizing in Illinois |place = Springfield, IL |publisher = Sangamon State University |pages = 35\u201340 |isbn = 978-0-9620873-3-2 |quote = He has also been a consultant and instructor for the Gamaliel Foundation, an organizing institute working throughout the Midwest. }}
In mid-1988, he traveled for the first time in Europe for three weeks and then for five weeks in Kenya, where he met many of his [[Family of Barack Obama#Paternal relations|paternal relatives]] for the first time.{{cite book |last = Obama |first = Auma |year = 2012 |title = And then life happens: a memoir |location = New York |publisher = St. Martin's Press |isbn = 978-1-250-01005-6 |pages = 189\u2013208, 212\u2013216 }}Obama (1995, 2004), pp. 299\u2013437.\n* Maraniss (2012), pp. 564\u2013570.\n{{external media | float = right | video1 = [http://bostonlocaltv.org/catalog/V_UDAMVZGA4JEY06N Derrick Bell threatens to leave Harvard], April 24, 1990, 11:34, [[WGBH Educational Foundation|Boston TV Digital Archive]][http://bostonlocaltv.org/catalog/V_UDAMVZGA4JEY06N \"Ten O'Clock News; Derrick Bell threatens to leave Harvard\"], April 24, 1990, 11:34, [[WGBH Educational Foundation|WGBH]], [[American Archive of Public Broadcasting]] (WGBH and the [[Library of Congress]]), Boston and Washington, D.C.. Retrieved September 23, 2016. Student Barack Obama introduces Professor Derrick Bell starting at 6:25. }}\n\nObama entered [[Harvard Law School]] in the fall of 1988, living in nearby [[Somerville, Massachusetts]].{{cite news| newspaper=Somerville Scout| issue=January/February 2014| page=26 |title=Something in the Water|author1=Joey Del Ponte |author2=Somerville Scout Staff}} \"Barack Obama lived in the big, ivy-covered brick building at 365 Broadway ... From 1988 to 1991, the future president resided in a basement apartment while attending Harvard Law School.\" He was selected as an editor of the ''[[Harvard Law Review]]'' at the end of his first year,{{cite news |author = Michael Levenson |author2 = Jonathan Saltzman |date = January 28, 2007 |title = At Harvard Law, a unifying voice |newspaper = Boston Globe |page = 1A |url = http://www.boston.com/news/local/articles/2007/01/28/at_harvard_law_a_unifying_voice/?page=full |accessdate = June 15, 2008 }}\n* {{cite news |author = Kantor, Jodi |date = January 28, 2007 |title = In law school, Obama found political voice |newspaper = The New York Times |page = A1 |url = https://www.nytimes.com/2007/01/28/us/politics/28obama.html |accessdate = June 15, 2008 }}\n* {{cite news |author = Mundy, Liza |date = August 12, 2007 |title = A series of fortunate events |newspaper = The Washington Post |page = W10 |url = https://www.washingtonpost.com/wp-dyn/content/article/2007/08/08/AR2007080802038_pf.html |accessdate = June 15, 2008 }}\n* Mendell (2007), pp. 80\u201392. president of the journal in his second year,{{cite news |author = Butterfield, Fox |date = February 6, 1990 |title = First black elected to head Harvard's Law Review |newspaper = The New York Times |page = A20 |url = https://www.nytimes.com/1990/02/06/us/first-black-elected-to-head-harvard-s-law-review.html |accessdate = June 15, 2008 }}\n* {{cite news |author = Ybarra, Michael J |date = February 7, 1990 |title = Activist in Chicago now heads Harvard Law Review |newspaper = Chicago Tribune |page = 3 |url = http://articles.chicagotribune.com/1990-02-07/news/9001110408_1_ann-dunham-chicago-housing-authority-barack-obama |accessdate = October 29, 2011 }}\n* {{cite news |author = Drummond, Tammerlin |date = March 12, 1990 |title = Barack Obama's law; Harvard Law Review's first black president plans a life of public service |newspaper = Los Angeles Times |page = E1 |format = paid archive |url = https://pqasb.pqarchiver.com/latimes/access/60017156.html?dids=60017156:60017156&FMT=ABS&FMTS=ABS:FT |accessdate = June 15, 2008 }}\n* {{cite magazine |author = Evans, Gaynelle |date = March 15, 1990 |title = Opening another door: The saga of Harvard's Barack H. Obama |magazine = Black Issues in Higher Education |volume = 7 |issue = 1 |page = 5 |issn = 0742-0277 |url = http://diverseeducation.com/article/11791/ |accessdate = May 18, 2012 }}\n* {{cite news |author = Pugh, Allison J. |agency = Associated Press |date = April 18, 1990 |title = Law Review's first black president aims to help poor |newspaper = The Miami Herald |page = C01 |url = http://nl.newsbank.com/nl-search/we/Archives?p_multi=MH%7C&p_product=MH&p_theme=realcities2&p_action=search&p_maxdocs=200&s_site=miami&s_search_type=keyword&s_dispstring=Law%20Review%27s%20first%20black%20president%20aims%20to%20help%20poor%20AND%20date%28all%29&p_field_advanced-0=&p_text_advanced-0=%28Law%20Review%27s%20first%20black%20president%20aims%20to%20help%20poor%29\u00cal_numdocs=20&p_perpage=10&p_sort=YMD_date:D\u00cal_useweights=no |accessdate = June 15, 2008 }} and research assistant to the constitutional scholar [[Laurence Tribe]] while at Harvard for two years.{{YouTube|wzmmBZ7i4BQ}} During his summers, he returned to Chicago, where he worked as an [[Associate attorney|associate]] at the law firms of [[Sidley Austin]] in 1989 and [[Hopkins & Sutter]] in 1990.{{cite news |author = Aguilar, Louis |date = July 11, 1990 |title = Survey: Law firms slow to add minority partners |newspaper = Chicago Tribune |page = 1 (Business) |url = https://pqasb.pqarchiver.com/chicagotribune/access/28774085.html?dids=28774085:28774085&FMT=ABS&FMTS=ABS:FT |accessdate = June 15, 2008 }} After graduating with a [[Juris Doctor|JD]] degree ''[[magna cum laude]]'' from Harvard in 1991, he returned to Chicago. Obama's election as the [[List of African-American firsts|first black president of the ''Harvard Law Review'']] gained national media attention and led to a publishing contract and advance for a book about race relations,{{cite news |author = Scott, Janny |date = May 18, 2008 |title = The story of Obama, written by Obama |newspaper = The New York Times |page = A1 |url = https://www.nytimes.com/2008/05/18/us/politics/18memoirs.html |accessdate = June 15, 2008 }}\n* Obama (1995, 2004), pp. xiii\u2013xvii. which evolved into a personal memoir. The manuscript was published in mid-1995 as ''[[Dreams from My Father]]''.\n\n==== Chicago Law School and civil rights attorney ====\nIn 1991, Obama accepted a two-year position as Visiting Law and Government Fellow at the [[University of Chicago Law School]] to work on his first book. He then taught [[constitutional law]] at the University of Chicago Law School for twelve years, first as a [[lecturer]] from 1992 to 1996, and then as a senior lecturer from 1996 to 2004.{{cite web |date = March 27, 2008 |title = Statement regarding Barack Obama |publisher = University of Chicago Law School |url = http://www.law.uchicago.edu/media/index.html |accessdate = June 5, 2008 |archiveurl = https://web.archive.org/web/20080608225931/http://www.law.uchicago.edu/media/index.html |archivedate = June 8, 2008 |deadurl = yes |df = mdy-all }}\n* {{cite web |author = Miller, Joe |date = March 28, 2008 |title = Was Barack Obama really a constitutional law professor? |publisher = FactCheck.org |url = http://factcheck.org/2008/03/obama-a-constitutional-law-professor/ |accessdate = May 18, 2012 }}\n* {{cite web |author = Holan, Angie Drobnic |date = March 7, 2008 |title = Obama's 20 years of experience |publisher = PolitiFact.com |url = http://www.politifact.com/truth-o-meter/article/2008/mar/07/obamas-20-years-experience |accessdate = June 10, 2008 }}\n\nFrom April to October 1992, Obama directed Illinois's [[Project Vote]], a [[voter registration campaign]] with ten staffers and seven hundred volunteer registrars; it achieved its goal of registering 150,000 of 400,000 unregistered African Americans in the state, leading ''[[Crain's Chicago Business]]'' to name Obama to its 1993 list of \"40 under Forty\" powers to be.\n\nHe joined Davis, Miner, Barnhill & Galland, a 13-attorney law firm specializing in civil rights litigation and neighborhood economic development, where he was an associate for three years from 1993 to 1996, then [[of counsel]] from 1996 to 2004. In 1994, he was listed as one of the lawyers in ''Buycks-Roberson v. Citibank Fed. Sav. Bank'', 94 C 4094 (N.D. Ill.).{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-9000.pdf |title = Civil Docket for Case #: 1:94-cv-04094 |author = United States District Court: Northern District of Illinois \u2013 CM/ECF LIVE, Ver 3.0 (Chicago) |date = July 6, 1994 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} This [[Class-action lawsuit|class action lawsuit]] was filed in 1994 with Selma Buycks-Roberson as lead plaintiff and alleged that Citibank Federal Savings Bank had engaged in practices forbidden under the [[Equal Credit Opportunity Act]] and the [[Fair Housing Act]].{{cite web |url = http://www.clearinghouse.net/detail.php?id=10112 |title = Buycks-Roberson v. Citibank Fed. Sav. Bank \u2013 Civil Rights Litigation Clearinghouse |publisher = clearinghouse.net |accessdate = November 25, 2015 }} The case was settled out of court.{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-0008.pdf |title = Settlement Agreement |author = United States District Court for the Northern District of Illinois Eastern Division |date = January 16, 1988 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} Final judgment was issued on May 13, 1998, with Citibank Federal Savings Bank agreeing to pay attorney fees.{{cite web |url = http://www.clearinghouse.net/chDocs/public/FH-IL-0011-0010.pdf |title = Final Judgment and Order of Dismissal |author = United States District Cuurt For the Northern District of Illinois Eastern Division |date = May 13, 1998 |publisher = clearinghouse.net |accessdate = June 3, 2016 }} His law license became inactive in 2007.{{cite web |url = http://www.factcheck.org/2012/06/the-obamas-law-licenses/ |title = The Obamas' Law Licenses |publisher = FactCheck.org |date = June 14, 2012 |accessdate = July 16, 2012 |author = Gore, D'Angelo }}\n\nFrom 1994 to 2002, Obama served on the boards of directors of the [[Woods Fund of Chicago]]\u2014which in 1985 had been the first foundation to fund the Developing Communities Project\u2014and of the [[Joyce Foundation]]. He served on the board of directors of the [[Chicago Annenberg Challenge]] from 1995 to 2002, as founding president and chairman of the board of directors from 1995 to 1999.\n\n=== Legislative career ===\n\n==== Illinois State Senator (1997\u20132004) ====\n{{Main|Illinois Senate career of Barack Obama}}\n[[File:Obamamiltondavis1.jpg|thumb|right|State Senator Obama and others celebrate the naming of a street in Chicago after [[ShoreBank]] co-founder Milton Davis in 1998]]\nObama was elected to the [[Illinois Senate]] in 1996, succeeding Democratic State Senator [[Alice Palmer (politician)|Alice Palmer]] from Illinois's 13th District, which, at that time, spanned Chicago South Side neighborhoods from [[Hyde Park, Chicago|Hyde Park]]\u2013[[Kenwood, Chicago|Kenwood]] south to [[South Shore, Chicago|South Shore]] and west to [[Chicago Lawn, Chicago|Chicago Lawn]].{{cite news |first=David |last=Jackson |author2=Ray Long |title=Obama Knows His Way Around a Ballot |date=April 3, 2007 |url=http://www.chicagotribune.com/news/politics/obama/chi-070403obama-ballot-archive,0,5693903.story |archiveurl=https://web.archive.org/web/20081011054057/http://www.chicagotribune.com/news/politics/obama/chi-070403obama-ballot-archive%2C0%2C5693903.story |work=Chicago Tribune |accessdate=May 18, 2012 |archivedate=October 11, 2008 |deadurl=yes |df= }}\n* {{cite book |author = [[Jesse White (politician)|White, Jesse]] |year = 2001 |chapter = Legislative Districts of Cook County, 1991 Reapportionment |chapterurl = https://web.archive.org/web/20080226221919/http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf |title = Illinois Blue Book 2001\u20132002 |place = Springfield |publisher = [[Illinois Secretary of State]] |page = 65 |accessdate = July 16, 2011 |deadurl = bot: unknown |archiveurl = https://web.archive.org/web/20080226221919/http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf |archivedate = February 26, 2008 |df = mdy-all |url = http://www.sos.state.il.us/publications/02bluebook/legislative_branch/legdistrictmaps.pdf }} State Sen. District 13 = State Rep. Districts 25 & 26. Once elected, Obama gained bipartisan support for legislation that reformed ethics and health care laws.{{cite news|first=Peter |last=Slevin |title=Obama Forged Political Mettle in Illinois Capitol |date=February 9, 2007 |url=https://www.washingtonpost.com/wp-dyn/content/article/2007/02/08/AR2007020802262.html |work=The Washington Post |accessdate=April 20, 2008 }}{{cite news|first=Scott |last=Helman |title=In Illinois, Obama dealt with Lobbyists |date=September 23, 2007 |url=http://www.boston.com/news/nation/articles/2007/09/23/in_illinois_obama_dealt_with_lobbyists/ |work=Boston Globe |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080416235513/http://www.boston.com/news/nation/articles/2007/09/23/in_illinois_obama_dealt_with_lobbyists/ |archivedate=April 16, 2008 |deadurl=no |df= }} See also:{{cite news|title=Obama Record May Be Gold Mine for Critics |date=January 17, 2007 |publisher=CBS News |url=http://www.cbsnews.com/stories/2007/01/17/politics/main2369157.shtml |agency=Associated Press |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080412223055/http://www.cbsnews.com/stories/2007/01/17/politics/main2369157.shtml |archivedate=April 12, 2008 |deadurl=no }} He sponsored a law that increased [[tax credit]]s for low-income workers, negotiated [[welfare reform]], and promoted increased subsidies for childcare.{{cite news |first = Janny |last = Scott |title = In Illinois, Obama Proved Pragmatic and Shrewd |date = July 30, 2007 |url = https://www.nytimes.com/2007/07/30/us/politics/30obama.html |work = The New York Times |accessdate = April 20, 2008 |archiveurl = https://web.archive.org/web/20081210135903/http://www.nytimes.com/2007/07/30/us/politics/30obama.html|archivedate=December 10, 2008 |deadurl = no }} In 2001, as co-chairman of the bipartisan Joint Committee on Administrative Rules, Obama supported Republican Governor Ryan's [[payday loan]] regulations and [[Predatory lending|predatory mortgage lending]] regulations aimed at averting home [[foreclosure]]s.{{cite news|author=Allison, Melissa |date=December 15, 2000 |title=State takes on predatory lending; Rules would halt single-premium life insurance financing |url=https://pqasb.pqarchiver.com/chicagotribune/access/65214450.html?dids=65214450:65214450&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 (Business) |accessdate=June 1, 2008 |archiveurl=https://web.archive.org/web/20080617151154/https://pqasb.pqarchiver.com/chicagotribune/access/65214450.html?dids=65214450%3A65214450&FMT=ABS&FMTS=ABS%3AFT |archivedate=June 17, 2008 |deadurl=no |df= }}{{cite news|author=Ray Long |author2=Melissa Allison |date=April 18, 2001 |title=Illinois OKs predatory loan curbs; State aims to avert home foreclosures |url=https://pqasb.pqarchiver.com/chicagotribune/access/71459393.html?dids=71459393:71459393&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 |accessdate=June 1, 2008 }}\n\nHe was reelected to the Illinois Senate in 1998, defeating Republican Yesse Yehudah in the general election, and was re-elected again in 2002.{{cite web |url = http://www.senatedem.state.il.us/obama/index.html |title = 13th District: Barack Obama |accessdate = April 20, 2008 |date = August 24, 2000 |publisher = Illinois State Senate Democrats |archiveurl = https://web.archive.org/web/20000824102110/http://www.senatedem.state.il.us/obama/index.html |archivedate = April 12, 2000 }}{{cite web |url = http://www.senatedem.state.il.us/obama/index.html |title = 13th District: Barack Obama |accessdate = April 20, 2008 |date = October 9, 2004 |publisher = Illinois State Senate Democrats |archiveurl = https://web.archive.org/web/20040802233730/http://www.senatedem.state.il.us/obama/index.html |archivedate = August 2, 2004 }} In 2000, he lost a [[Illinois's 1st congressional district election, 2000|Democratic primary race]] for [[Illinois's 1st congressional district]] in the [[United States House of Representatives]] to four-term incumbent [[Bobby Rush]] by a margin of two to one.\n\nIn January 2003, Obama became chairman of the Illinois Senate's Health and Human Services Committee when Democrats, after a decade in the minority, regained a majority.{{cite news|first=Jackie |last=Calmes |title=Statehouse Yields Clues to Obama |date=February 23, 2007 |url=https://www.wsj.com/public/article/SB117219748197216894-Sn6oV_4KLQHp_xz7CjYLuyjv3Jg_20070324.html |work=The Wall Street Journal |accessdate=April 20, 2008 |deadurl=yes |archiveurl=https://web.archive.org/web/20080918032039/http://online.wsj.com/public/article/SB117219748197216894-Sn6oV_4KLQHp_xz7CjYLuyjv3Jg_20070324.html |archivedate=September 18, 2008 }} He sponsored and led unanimous, bipartisan passage of legislation to monitor [[racial profiling]] by requiring police to record the race of drivers they detained, and legislation making Illinois the first state to mandate videotaping of homicide interrogations.{{cite news|author=Tavella, Anne Marie |date=April 14, 2003 |title=Profiling, taping plans pass Senate |url=http://nl.newsbank.com/nl-search/we/Archives?p_product=ADHB&p_theme=adhb&p_action=search&p_maxdocs=200&p_text_search-0=Profiling,%20AND%20taping%20AND%20plans%20AND%20pass%20AND%20Senate&s_dispstring=Profiling,%20taping%20plans%20pass%20Senate%20AND%20date(April_4,_2003%20to%204/4/2003)&p_field_date-0=YMD_date&p_params_date-0=date:B,E&p_text_date-0=4_April_2003%20to%204/4/2003\u00cal_numdocs=20&p_perpage=10&p_sort=YMD_date:D\u00cal_useweights=no |format=paid archive |work=Daily Herald |page=17 |accessdate=June 1, 2008 }}{{cite news|author=Haynes, V. Dion |date=June 29, 2003 |title=Fight racial profiling at local level, lawmaker says; U.S. guidelines get mixed review |url=https://pqasb.pqarchiver.com/chicagotribune/access/352884461.html?dids=352884461:352884461&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=8 |accessdate=June 1, 2008 |archiveurl=https://web.archive.org/web/20080617150449/https://pqasb.pqarchiver.com/chicagotribune/access/352884461.html?dids=352884461%3A352884461&FMT=ABS&FMTS=ABS%3AFT |archivedate=June 17, 2008 |deadurl=no |df= }}{{cite news|author=Pearson, Rick |date=July 17, 2003 |title=Taped confessions to be law; State will be 1st to pass legislation |url=https://pqasb.pqarchiver.com/chicagotribune/access/370136121.html?dids=370136121:370136121&FMT=ABS&FMTS=ABS:FT |format=paid archive |work=Chicago Tribune |page=1 (Metro) |accessdate=June 1, 2008 }} During his 2004 general election campaign for the U.S. Senate, police representatives credited Obama for his active engagement with police organizations in enacting [[Capital punishment in the United States|death penalty]] reforms.{{cite news |first = Sam |last = Youngman |author2 = Aaron Blake |title = Obama's Crime Votes Are Fodder for Rivals |date = March 14, 2007 |url = http://thehill.com/homenews/news/11316-obamas-crime-votes-are-fodder-for-rivals |work = The Hill |accessdate = May 18, 2012 }} See also: {{cite news |title = US Presidential Candidate Obama Cites Work on State Death Penalty Reforms |date = November 12, 2007 |work = International Herald Tribune |url = http://www.iht.com/articles/ap/2007/11/12/america/NA-POL-US-Obama-Death-Penalty.php |archiveurl = https://web.archive.org/web/20080607111231/http://www.iht.com/articles/ap/2007/11/12/america/NA-POL-US-Obama-Death-Penalty.php |agency = Associated Press |accessdate = May 18, 2012 |archivedate = June 7, 2008 }} Obama resigned from the Illinois Senate in November 2004 following his election to the U.S. Senate.{{cite news|first=Melanie |last=Coffee |title=Attorney Chosen to Fill Obama's State Senate Seat |date=November 6, 2004 |publisher=HPKCC |url=http://www.hydepark.org/hpkccnews/raoul.htm#ap |agency=Associated Press |accessdate=April 20, 2008 |archiveurl=https://web.archive.org/web/20080516174431/http://www.hydepark.org/hpkccnews/raoul.htm |archivedate=May 16, 2008 |deadurl=yes |df= }}\n\n==== 2004 U.S. Senate campaign ====\n{{Main|2004 United States Senate election in Illinois}}\n[[File:Illinois Senate Election Results by County, 2004.svg|upright=.5|thumb|County results of the 2004 U.S. Senate race in Illinois. Obama won the counties in blue.]]\nIn May 2002, Obama commissioned a poll to assess his prospects in a 2004 U.S. Senate race. He created a campaign committee, began raising funds, and lined up political media consultant [[David Axelrod (political consultant)|David Axelrod]] by August 2002. Obama formally announced his candidacy in January 2003.{{cite news |author = Helman, Scott |date = October 12, 2007 |title = Early defeat launched a rapid political climb |newspaper = [[Boston Globe]] |page = 1A |url = http://www.boston.com/news/nation/articles/2007/10/12/early_defeat_launched_a_rapid_political_climb |accessdate = April 13, 2008 }}\n\nObama was an early opponent of the [[George W. Bush]] administration's [[2003 invasion of Iraq]].{{cite news |author = Strausberg, Chinta |date = September 26, 2002 |title = Opposition to war mounts |newspaper = Chicago Defender |page = 1 |url = http://www.highbeam.com/doc/1P3-220062931.html |archive-url = https://web.archive.org/web/20110511195931/http://www.highbeam.com/doc/1P3-220062931.html |dead-url = yes |archive-date = May 11, 2011 |format = paid archive |accessdate = February 3, 2008 }} On October 2, 2002, the day President Bush and Congress agreed on the [[Iraq Resolution|joint resolution]] authorizing the [[Iraq War]], Obama addressed the first high-profile Chicago [[Protests against the Iraq War|anti-Iraq War rally]], and spoke out against the war. He addressed another anti-war rally in March 2003 and told the crowd that \"it's not too late\" to stop the war.\n\nDecisions by Republican incumbent [[Peter Fitzgerald (politician)|Peter Fitzgerald]] and his Democratic predecessor [[Carol Moseley Braun]] to not participate in the election resulted in wide-open Democratic and Republican primary contests involving 15 candidates.{{cite news |author = Davey, Monica |date = March 7, 2004 |title = Closely watched Illinois Senate race attracts 7 candidates in millionaire range |url = https://www.nytimes.com/2004/03/07/politics/campaign/07ILLI.html |archiveurl = https://web.archive.org/web/20090416015834/http://www.nytimes.com/2004/03/07/politics/campaign/07ILLI.html|archivedate=April 16, 2009 |newspaper = [[The New York Times]] |page = 19 |accessdate = April 13, 2008 }} In the March 2004 primary election, Obama won in an unexpected landslide\u2014which overnight made him a rising star within the [[Democratic National Committee|national Democratic Party]], started speculation about a presidential future, and led to the reissue of his memoir, ''Dreams from My Father''. In July 2004, Obama delivered the keynote address at the [[2004 Democratic National Convention]],{{cite news |author = Bernstein, David |date = June 2007 |title = The Speech |magazine = Chicago Magazine |url = http://www.chicagomag.com/Chicago-Magazine/June-2007/The-Speech |accessdate = April 13, 2008 }} seen by 9.1 million viewers. His speech was well received and elevated his status within the Democratic Party.\n\nObama's expected opponent in the general election, Republican primary winner [[Jack Ryan (politician)|Jack Ryan]], withdrew from the race in June 2004.{{cite news |date = June 25, 2004 |title = Ryan drops out of Senate race in Illinois |publisher = CNN |url = http://www.cnn.com/2004/ALLPOLITICS/06/25/il.ryan/ |accessdate = May 18, 2012 }}\n* Mendell (2007), pp. 260\u2013271. Six weeks later, [[Alan Keyes]] accepted the Republican nomination to replace Ryan.{{cite news |author = Lannan, Maura Kelly |agency = Associated Press |date = August 9, 2004 |title = Alan Keyes enters U.S. Senate race in Illinois against rising Democratic star |newspaper = Union-Tribune |url = http://legacy.signonsandiego.com/news/politics/20040809-0849-illinoissenate.html |accessdate = April 13, 2008 }} In the [[United States Senate election in Illinois, 2004|November 2004 general election]], Obama won with 70% of the vote.\n\n==== U.S. Senator from Illinois (2005\u201308) ====\n{{Main|United States Senate career of Barack Obama}}\n[[File:BarackObamaportrait.jpg|thumb|left|upright|The official portrait of Obama as a member of the United States Senate]]\nObama was sworn in as a senator on January 3, 2005,{{CongBio|o000167|inline=1|date=October 12, 2011}} becoming the only Senate member of the [[Congressional Black Caucus]].{{cite web |title = Member Info |url = http://www.house.gov/kilpatrick/cbc/member_info.html |archiveurl = https://web.archive.org/web/20080709114659/http://www.house.gov/kilpatrick/cbc/member_info.html |archivedate = July 9, 2008 |publisher = Congressional Black Caucus |accessdate = June 25, 2008 }} ''[[Congressional Quarterly|CQ Weekly]]'' characterized him as a \"loyal Democrat\" based on analysis of all Senate votes from 2005 to 2007. Obama announced on November 13, 2008, that he would [[resignation from the United States Senate|resign his Senate seat]] on November 16, 2008, before the start of the [[lame duck (politics)|lame-duck]] session, to focus on his transition period for the presidency.\n\n===== Legislation =====\n{{See also|List of bills sponsored by Barack Obama in the United States Senate}}\nObama [[Sponsor (legislative)|cosponsored]] the [[Secure America and Orderly Immigration Act]].{{cite web |first = 109th Congress, 1st Session |last = U.S. Senate |title = S. 1033, Secure America and Orderly Immigration Act |date = May 12, 2005 |url = https://www.congress.gov/bill/109th-congress/senate-bill/1033/cosponsors |publisher = Library of Congress |accessdate = February 25, 2017}} He introduced two initiatives that bore his name: Lugar\u2013Obama, which expanded the [[Nunn\u2013Lugar Cooperative Threat Reduction]] concept to conventional weapons;{{cite web |url = http://obama.senate.gov/press/070111-lugar-obama_non/ |title = Lugar\u2013Obama Nonproliferation Legislation Signed into Law by the President |date = January 11, 2007 |publisher = Richard Lugar U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154746/http://obama.senate.gov/press/070111-lugar-obama_non/ |archivedate = December 18, 2008 }} See also: {{cite news |first = Richard G. |last = Lugar |author2 = Barack Obama |title = Junkyard Dogs of War |date = December 3, 2005 |url = https://www.washingtonpost.com/wp-dyn/content/article/2005/12/02/AR2005120201509.html |work = The Washington Post |accessdate = April 27, 2008 }} and the [[Federal Funding Accountability and Transparency Act of 2006]], which authorized the establishment of USAspending.gov, a web search engine on federal spending.{{cite news |first = John |last = McCormack |title = Google Government Gone Viral |date = December 21, 2007 |url = http://www.weeklystandard.com/Content/Public/Articles/000/000/014/502njiqx.asp |work = Weekly Standard |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20080423235240/http://www.weeklystandard.com/Content/Public/Articles/000/000/014/502njiqx.asp |archivedate = April 23, 2008 |deadurl = no }} See also: {{cite web |title = President Bush Signs Coburn\u2013Obama Transparency Act |date = September 26, 2006 |url = http://coburn.senate.gov/ffm/index.cfm?FuseAction=LegislativeFloorAction.Home&ContentRecord_id=eb582f19-802a-23ad-41db-7a7cb464cfdb |archiveurl = https://web.archive.org/web/20080501233103/http://coburn.senate.gov/ffm/index.cfm?FuseAction=LegislativeFloorAction.Home&ContentRecord_id=eb582f19-802a-23ad-41db-7a7cb464cfdb |archivedate = May 1, 2008 |publisher = Tom Coburn U.S. Senate Office |accessdate = April 27, 2008 }} On June 3, 2008, Senator Obama\u2014along with Senators [[Tom Carper]], [[Tom Coburn]], and [[John McCain]]\u2014introduced follow-up legislation: Strengthening Transparency and Accountability in Federal Spending Act of 2008.{{cite web |url = http://www.govtrack.us/congress/bills/110/s3077 |title = S. 3077: Strengthening Transparency and Accountability in Federal Spending Act of 2008: 2007\u20132008 (110th Congress) |publisher = Govtrack.us |date = June 3, 2008 |accessdate = May 18, 2012 }}\n\nObama sponsored legislation that would have required nuclear plant owners to notify state and local authorities of radioactive leaks, but the bill failed to pass in the full Senate after being heavily modified in committee.{{cite news |last = McIntire |first = Mike |url = https://www.nytimes.com/2008/02/03/us/politics/03exelon.html |title = Nuclear Leaks and Response Tested Obama in Senate |date = February 3, 2008 |work = The New York Times |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081209065950/http://www.nytimes.com/2008/02/03/us/politics/03exelon.html|archivedate=December 9, 2008 |deadurl = no }} Regarding [[tort reform]], Obama voted for the [[Class Action Fairness Act of 2005]] and the [[Foreign Intelligence Surveillance Act of 1978 Amendments Act of 2008|FISA Amendments Act of 2008]], which grants immunity from civil liability to telecommunications companies complicit with [[NSA warrantless surveillance (2001\u201307)|NSA warrantless wiretapping]] operations.{{cite news |url = https://www.forbes.com/2008/08/08/obama-mccain-torts-biz-beltway-cz_df_0811torts.html |title = November Election A Lawyer's Delight |author = Fisher, Daniel |work = Forbes |date = August 11, 2008 |accessdate = January 11, 2009 }}\n[[File:Lugar-Obama.jpg|thumb|alt=Gray-haired man and Obama stand, wearing casual polo shirts. Obama wears sunglasses and holds something slung over his right shoulder.|left|Obama and U.S. Senator [[Richard Lugar]] (R-IN) visit a Russian facility for dismantling mobile missiles (August 2005){{cite web |title = Nunn\u2013Lugar Report |date = August 2005 |publisher = Richard Lugar U.S. Senate Office |url = http://lugar.senate.gov/nunnlugar/pdf/trip_report_2005.pdf |archiveurl = https://web.archive.org/web/20080501002134/http://lugar.senate.gov/nunnlugar/pdf/trip_report_2005.pdf |archivedate = May 1, 2008 |accessdate = April 30, 2008 }}]]\n\nIn December 2006, President Bush signed into law the [[Democratic Republic of the Congo]] Relief, Security, and Democracy Promotion Act, marking the first federal legislation to be enacted with Obama as its primary sponsor.{{cite web |title = Democratic Republic of the Congo |date = April 2006 |url = http://www.usccb.org/sdwp/international/drc0406.shtml |publisher = United States Conference of Catholic Bishops |accessdate = January 26, 2012 |archiveurl = https://web.archive.org/web/20110108193726/http://www.usccb.org/sdwp/international/drc0406.shtml |archivedate = January 8, 2011 }}{{cite web |title = The IRC Welcomes New U.S. Law on Congo |date = January 5, 2007 |url = http://www.theirc.org/news/the-irc-welcomes-new-us-law.html |publisher = International Rescue Committee |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20110807061958/http://www.rescue.org/news/the-irc-welcomes-new-us-law.html |archivedate = August 7, 2011 }} In January 2007, Obama and Senator Feingold introduced a corporate jet provision to the [[Honest Leadership and Open Government Act]], which was signed into law in September 2007.{{cite news|first=Nathaniel |last=Weixel |title=Feingold, Obama Go After Corporate Jet Travel |date=November 15, 2007 |url=http://thehill.com/leading-the-news/feingold-obama-go-after-corporate-jet-travel-2007-11-15.html |work=The Hill |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080515201902/http://thehill.com/leading-the-news/feingold-obama-go-after-corporate-jet-travel-2007-11-15.html |archivedate=May 15, 2008 |deadurl=no }}{{cite news|first=Nathaniel |last=Weixel |title=Lawmakers Press FEC on Bundling Regulation |date=December 5, 2007 |url=http://thehill.com/leading-the-news/lawmakers-press-fec-on-bundling-regulation-2007-12-05.html |work=The Hill |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080416162108/http://thehill.com/leading-the-news/lawmakers-press-fec-on-bundling-regulation-2007-12-05.html |archivedate=April 16, 2008 |deadurl=no }} See also: {{cite news|title=Federal Election Commission Announces Plans to Issue New Regulations to Implement the Honest Leadership and Open Government Act of 2007 |date=September 24, 2007 |publisher=Federal Election Commission |url=http://www.fec.gov/press/press2007/20070924travel.shtml |accessdate=April 27, 2008 |archiveurl=https://web.archive.org/web/20080411220016/http://www.fec.gov/press/press2007/20070924travel.shtml |archivedate=April 11, 2008 |deadurl=yes }} Obama also introduced two unsuccessful bills: the [[Deceptive Practices and Voter Intimidation Prevention Act]] to criminalize deceptive practices in federal elections,{{cite news |first = Seth |last = Stern |title = Obama\u2013Schumer Bill Proposal Would Criminalize Voter Intimidation |date = January 31, 2007 |publisher = CQPolitics.com |url = https://www.nytimes.com/cq/2007/01/31/cq_2213.html |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20080516104256/http://www.nytimes.com/cq/2007/01/31/cq_2213.html |archivedate = May 16, 2008 |deadurl = no }}{{cite web |first = 110th Congress, 1st Session |last = U.S. Senate |title = S. 453, Deceptive Practices and Voter Intimidation Prevention Act of 2007 |date = January 31, 2007 |url = https://www.congress.gov/bill/110th-congress/senate-bill/453 |publisher = Library of Congress |accessdate = February 25, 2017}} See also: {{cite news |title = Honesty in Elections |date = January 31, 2007 |url = https://www.nytimes.com/2007/01/31/opinion/31wed1.html |work = The New York Times |format = editorial |accessdate = April 27, 2008 }} and the [[Iraq War De-Escalation Act of 2007]].{{cite news |first = E. Kasak |last = Krystin |title = Obama Introduces Measure to Bring Troops Home |date = February 7, 2007 |publisher = Medill News Service |url = http://www.nwitimes.com/news/local/article_c7147a5d-31bc-5497-abdd-a99c0cd6c189.html |accessdate = April 27, 2008 }}\n\nLater in 2007, Obama sponsored an amendment to the Defense Authorization Act to add safeguards for personality-disorder military discharges.{{cite web |title = Obama, Bond Hail New Safeguards on Military Personality Disorder Discharges, Urge Further Action |date = October 1, 2007 |url = http://bond.senate.gov/public/index.cfm?FuseAction=PressRoom.NewsReleases&ContentRecord_id=5C1EBFEB-1321-0E36-BA7D-04630AEFAD31 |publisher = Kit Bond U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20101205075008/http://bond.senate.gov/public/index.cfm?FuseAction=PressRoom.NewsReleases&ContentRecord_id=5C1EBFEB-1321-0E36-BA7D-04630AEFAD31 |archivedate = December 5, 2010 }} This amendment passed the full Senate in the spring of 2008.{{cite web |title = Obama, Bond Applaud Senate Passage of Amendment to Expedite the Review of Personality Disorder Discharge Cases |url = http://obama.senate.gov/press/080314-obama_bond_appl/ |archiveurl = https://web.archive.org/web/20081218154824/http://obama.senate.gov/press/080314-obama_bond_appl/ |archivedate = December 18, 2008 |date = March 14, 2008 }} He sponsored the [[Disinvestment from Iran|Iran Sanctions Enabling Act]] supporting divestment of state pension funds from Iran's oil and gas industry, which was never enacted but later incorporated in the [[Comprehensive Iran Sanctions, Accountability, and Divestment Act of 2010]];{{Cite web|url=https://www.govtrack.us/congress/bills/111/s1065|title=Iran Sanctions Enabling Act of 2009 (2009 \u2013 S. 1065)|website=GovTrack.us|language=en|access-date=August 27, 2018}} and co-sponsored legislation to reduce risks of nuclear terrorism. Obama also sponsored a Senate amendment to the [[State Children's Health Insurance Program]], providing one year of job protection for family members caring for soldiers with combat-related injuries.{{cite web |title = Senate Passes Obama, McCaskill Legislation to Provide Safety Net for Families of Wounded Service Members |date = August 2, 2007 |url = http://obama.senate.gov/press/070802-senate_passes_o_1/ |publisher = Barack Obama U.S. Senate Office |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154819/http://obama.senate.gov/press/070802-senate_passes_o_1/ |archivedate = December 18, 2008 }}\n\n===== Committees =====\n[[File:Barack Obama Iraq 2006.jpg|thumb|Obama speaking with a soldier stationed in Iraq, 2006]]\nObama held assignments on the Senate Committees for [[United States Senate Committee on Foreign Relations|Foreign Relations]], [[United States Senate Committee on Environment and Public Works|Environment and Public Works]] and [[United States Senate Committee on Veterans' Affairs|Veterans' Affairs]] through December 2006.{{cite web |url = http://obama.senate.gov/committees/ |date = December 9, 2006 |title = Committee Assignments |accessdate = April 27, 2008 |publisher = Barack Obama U.S. Senate Office |archiveurl = https://web.archive.org/web/20061209190827/http://obama.senate.gov/committees/ |archivedate = December 9, 2006 }} In January 2007, he left the Environment and Public Works committee and took additional assignments with [[United States Senate Committee on Health, Education, Labor and Pensions|Health, Education, Labor and Pensions]] and [[United States Senate Committee on Homeland Security and Governmental Affairs|Homeland Security and Governmental Affairs]].{{cite news |title = Obama Gets New Committee Assignments |date = November 15, 2006 |publisher = Barack Obama U.S. Senate Office |url = http://obama.senate.gov/news/061115-obama_gets_new/ |agency = Associated Press |accessdate = April 27, 2008 |archiveurl = https://web.archive.org/web/20081218154741/http://obama.senate.gov/news/061115-obama_gets_new/ |archivedate = December 18, 2008 }} He also became Chairman of the Senate's subcommittee on [[United States Senate Foreign Relations Subcommittee on Europe and Regional Security Cooperation|European Affairs]].{{cite news |first = Tom |last = Baldwin |title = Stay-At-Home Barack Obama Comes Under Fire for a Lack of Foreign Experience |date = December 21, 2007 |url = http://www.timesonline.co.uk/tol/news/world/us_and_americas/article3080794.ece |work = Sunday Times (UK) |accessdate = April 27, 2008 }} As a member of the Senate Foreign Relations Committee, Obama made official trips to Eastern Europe, the Middle East, Central Asia and Africa. He met with [[Mahmoud Abbas]] before Abbas became [[President of the Palestinian National Authority]], and gave a speech at the [[University of Nairobi]] in which he condemned corruption within the Kenyan government." - } - } - }] - } - }, - "userinfo": { - "id": 35425575, - "name": "Tsevener" - } - } + "actions": { + "edit": [] + } + } + ] + } } From 3b83c730b7944fe875893805950c0b9c6f7fd13c Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:08:11 -0600 Subject: [PATCH 07/17] Allow short description template editing through native view for Test Wikipedia --- WMF Framework/Configuration.swift | 1 + Wikipedia/Code/ArticleViewController+Editing.swift | 2 +- Wikipedia/Code/URL+LinkParsing.swift | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/WMF Framework/Configuration.swift b/WMF Framework/Configuration.swift index bd6658486f1..20293843f7d 100644 --- a/WMF Framework/Configuration.swift +++ b/WMF Framework/Configuration.swift @@ -166,6 +166,7 @@ public class Configuration: NSObject { public static let appsLabs = "mobileapps.wmflabs.org" // Product Infrastructure team's labs instance public static let localhost = "localhost" public static let englishWikipedia = "en.wikipedia.org" + public static let testWikipedia = "test.wikipedia.org" public static let wikimedia = "wikimedia.org" public static let metaWiki = "meta.wikimedia.org" public static let wikimediafoundation = "wikimediafoundation.org" diff --git a/Wikipedia/Code/ArticleViewController+Editing.swift b/Wikipedia/Code/ArticleViewController+Editing.swift index 1f281ee0f23..1e2ddaf45b8 100644 --- a/Wikipedia/Code/ArticleViewController+Editing.swift +++ b/Wikipedia/Code/ArticleViewController+Editing.swift @@ -46,7 +46,7 @@ extension ArticleViewController { editFunnel.logTitleDescriptionEditingStart(from: funnelSource, language: articleLanguageCode) - let maybeDescriptionController: ArticleDescriptionControlling? = articleURL.wmf_isEnglishWikipedia ? ShortDescriptionController(article: article, articleLanguageCode: articleLanguageCode, articleURL: articleURL, descriptionSource: descriptionSource, delegate: self) : WikidataDescriptionController(article: article, articleLanguageCode: articleLanguageCode, descriptionSource: descriptionSource) + let maybeDescriptionController: ArticleDescriptionControlling? = (articleURL.wmf_isEnglishWikipedia || articleURL.wmf_isTestWikipedia) ? ShortDescriptionController(article: article, articleLanguageCode: articleLanguageCode, articleURL: articleURL, descriptionSource: descriptionSource, delegate: self) : WikidataDescriptionController(article: article, articleLanguageCode: articleLanguageCode, descriptionSource: descriptionSource) guard let descriptionController = maybeDescriptionController else { showGenericError() diff --git a/Wikipedia/Code/URL+LinkParsing.swift b/Wikipedia/Code/URL+LinkParsing.swift index c76e8a313e5..a46215fd230 100644 --- a/Wikipedia/Code/URL+LinkParsing.swift +++ b/Wikipedia/Code/URL+LinkParsing.swift @@ -97,6 +97,10 @@ extension URL { public var wmf_isEnglishWikipedia: Bool { host == Configuration.Domain.englishWikipedia } + + public var wmf_isTestWikipedia: Bool { + host == Configuration.Domain.testWikipedia + } public var wmf_wiki: String? { return wmf_languageCode?.replacingOccurrences(of: "-", with: "_").appending("wiki") From 68f3ea6ba8a3720bd64383370cdc1ee815df5371 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:11:16 -0600 Subject: [PATCH 08/17] Display blocked panel for EN article description edits - DescriptionEditViewController - evaluate error upon publish, display blocked panel if needed - ShortDescriptionController - fetch block information upon landing and pass back to view controller - DescriptionEditViewController - display block panel upon landing and disable controls. - Minor renaming for clarity --- .../ArticleDescriptionControlling.swift | 5 +- .../ShortDescriptionController.swift | 37 ++++++++++- .../Code/DescriptionEditViewController.swift | 64 +++++++++++++++++-- 3 files changed, 95 insertions(+), 11 deletions(-) diff --git a/Wikipedia/Code/Controllers/ArticleDescriptionControlling.swift b/Wikipedia/Code/Controllers/ArticleDescriptionControlling.swift index 6491e279da0..4598ac3ed6c 100644 --- a/Wikipedia/Code/Controllers/ArticleDescriptionControlling.swift +++ b/Wikipedia/Code/Controllers/ArticleDescriptionControlling.swift @@ -1,4 +1,5 @@ import Foundation +import WMF struct ArticleDescriptionWarningTypes: OptionSet { let rawValue: Int @@ -17,8 +18,8 @@ protocol ArticleDescriptionControlling { var article: WMFArticle { get } var articleLanguageCode: String { get } func publishDescription(_ description: String, completion: @escaping (Result) -> Void) - func currentDescription(completion: @escaping (String?) -> Void) - func errorTextFromError(_ error: Error) -> String + func currentDescription(completion: @escaping (String?, MediaWikiAPIBlockedDisplayError?) -> Void) + func errorCodeFromError(_ error: Error) -> String func learnMoreViewControllerWithTheme(_ theme: Theme) -> UIViewController? func warningTypesForDescription(_ description: String?) -> ArticleDescriptionWarningTypes } diff --git a/Wikipedia/Code/Controllers/ShortDescriptionController.swift b/Wikipedia/Code/Controllers/ShortDescriptionController.swift index a036597abb8..5affd930c6f 100644 --- a/Wikipedia/Code/Controllers/ShortDescriptionController.swift +++ b/Wikipedia/Code/Controllers/ShortDescriptionController.swift @@ -74,11 +74,42 @@ class ShortDescriptionController: ArticleDescriptionControlling { } } - func currentDescription(completion: @escaping (String?) -> Void) { - delegate?.currentDescription(completion: completion) + func currentDescription(completion: @escaping (String?, MediaWikiAPIBlockedDisplayError?) -> Void) { + + let group = DispatchGroup() + + var blockedError: MediaWikiAPIBlockedDisplayError? + var currentDescription: String? + + // Populate current description + group.enter() + delegate?.currentDescription(completion: { description in + currentDescription = description + group.leave() + }) + + // Populate blocked error + group.enter() + sectionFetcher.fetchSection(with: sectionID, articleURL: articleURL) { (result) in + + defer { + group.leave() + } + + switch result { + case .success(let result): + blockedError = result.blockedError + case .failure: + break + } + } + + group.notify(queue: DispatchQueue.main) { + completion(currentDescription, blockedError) + } } - func errorTextFromError(_ error: Error) -> String { + func errorCodeFromError(_ error: Error) -> String { let errorText = "\((error as NSError).domain)-\((error as NSError).code)" return errorText } diff --git a/Wikipedia/Code/DescriptionEditViewController.swift b/Wikipedia/Code/DescriptionEditViewController.swift index 87bb562d595..08d4d48afbc 100644 --- a/Wikipedia/Code/DescriptionEditViewController.swift +++ b/Wikipedia/Code/DescriptionEditViewController.swift @@ -61,7 +61,8 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { apply(theme: theme) isPlaceholderLabelHidden = false - articleDescriptionController.currentDescription { [weak self] (description) in + hideAllWarningLabels() + articleDescriptionController.currentDescription { [weak self] (description, blockedError) in guard let self = self else { return @@ -76,7 +77,11 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { self.isPlaceholderLabelHidden = self.shouldHidePlaceholder() self.updateWarningLabels() - + + if let blockedError { + self.disableTextFieldAndPublish() + self.presentBlockedPanel(blockedError: blockedError) + } } descriptionTextView.textContainer.lineFragmentPadding = 0 @@ -231,8 +236,14 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { return } - articleDescriptionController.publishDescription(descriptionToSave) { (result) in + articleDescriptionController.publishDescription(descriptionToSave) { [weak self] (result) in + DispatchQueue.main.async { + + guard let self else { + return + } + let presentingVC = self.presentingViewController self.enableProgressiveButton(true) switch result { @@ -244,14 +255,50 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { NotificationCenter.default.post(name: DescriptionEditViewController.didPublishNotification, object: nil) } case .failure(let error): - let errorText = self.articleDescriptionController.errorTextFromError(error) - self.editFunnel?.logTitleDescriptionSaveError(source: self.editFunnelSource, isAddingNewTitleDescription: self.isAddingNewTitleDescription, language: self.articleDescriptionController.articleLanguageCode, errorText: errorText) - WMFAlertManager.sharedInstance.showErrorAlert(error as NSError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil) + + let nsError = error as NSError + let errorCode = self.articleDescriptionController.errorCodeFromError(nsError) + self.editFunnel?.logTitleDescriptionSaveError(source: self.editFunnelSource, isAddingNewTitleDescription: self.isAddingNewTitleDescription, language: self.articleDescriptionController.articleLanguageCode, errorText: errorCode) + + let errorType = WikiTextSectionUploaderErrorType.init(rawValue: nsError.code) ?? .unknown + switch errorType { + case .blocked: + self.presentBlockedPanelFromError(nsError) + return + default: + break + } + + WMFAlertManager.sharedInstance.showErrorAlert(nsError as NSError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil) } } } } + private func presentBlockedPanelFromError(_ nsError: NSError) { + guard let blockedError = nsError.userInfo[NSErrorUserInfoBlockedDisplayError] as? MediaWikiAPIBlockedDisplayError else { + return + } + + presentBlockedPanel(blockedError: blockedError) + } + + private func presentBlockedPanel(blockedError: MediaWikiAPIBlockedDisplayError) { + + guard let currentTitle = self.articleDescriptionController?.articleDisplayTitle else { + return + } + + wmf_showBlockedPanel(messageHtml: blockedError.messageHtml, linkBaseURL: blockedError.linkBaseURL, currentTitle: currentTitle, theme: theme) + + } + + private func hideAllWarningLabels() { + warningCharacterCountLabel.isHidden = true + lengthWarningLabel.isHidden = true + casingWarningLabel.isHidden = true + } + private func updateWarningLabels() { warningCharacterCountLabel.text = characterCountWarningString(for: descriptionTextView.nilTextSafeCount()) @@ -263,6 +310,11 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { casingWarningLabel.isHidden = !warningTypes.contains(.casing) } + private func disableTextFieldAndPublish() { + self.descriptionTextView.isEditable = false + self.publishDescriptionButton.isEnabled = false + } + public func textViewDidChange(_ textView: UITextView) { let hasText = !descriptionTextView.text.isEmpty enableProgressiveButton(hasText) From 84a6e280a10457bf035e927def1505887373f4a7 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:13:11 -0600 Subject: [PATCH 09/17] Display blocked panel for non-EN article description edits - WikidataFetcher - Add method to fetch block information upon landing - WikidataFetcher - Adjust publish parameters & codable response to capture block information - WikidataFetcher - Resolve blocked error, pass back to view controller - WikidataFetcher - General model reordering / cleanup - DescriptionEditViewController - evaluate error upon publish, display blocked panel if needed - WikidataDescriptionController - fetch block information upon landing and pass back to view controller --- .../WikidataDescriptionController.swift | 24 +- .../Code/DescriptionEditViewController.swift | 10 + Wikipedia/Code/WikidataFetcher.swift | 218 +++++++++++++----- 3 files changed, 192 insertions(+), 60 deletions(-) diff --git a/Wikipedia/Code/Controllers/WikidataDescriptionController.swift b/Wikipedia/Code/Controllers/WikidataDescriptionController.swift index be37579dfc2..e6c3c2095cf 100644 --- a/Wikipedia/Code/Controllers/WikidataDescriptionController.swift +++ b/Wikipedia/Code/Controllers/WikidataDescriptionController.swift @@ -1,4 +1,5 @@ import Foundation +import WMF class WikidataDescriptionController: ArticleDescriptionControlling { @@ -23,8 +24,13 @@ class WikidataDescriptionController: ArticleDescriptionControlling { self.wikiDataID = wikiDataID } - func currentDescription(completion: @escaping (String?) -> Void) { - completion(wikidataDescription) + func currentDescription(completion: @escaping (String?, MediaWikiAPIBlockedDisplayError?) -> Void) { + + fetcher.wikidataBlockedInfo(forEntity: wikiDataID) { blockedError in + DispatchQueue.main.async { + completion(self.wikidataDescription, blockedError) + } + } } func publishDescription(_ description: String, completion: @escaping (Result) -> Void) { @@ -39,8 +45,18 @@ class WikidataDescriptionController: ArticleDescriptionControlling { } } - func errorTextFromError(_ error: Error) -> String { - let apiErrorCode = (error as? WikidataAPIResult.APIError)?.code + func errorCodeFromError(_ error: Error) -> String { + var apiErrorCode: String? + if let publishError = error as? WikidataFetcher.WikidataPublishingError { + switch publishError { + case .apiOther(let error): + apiErrorCode = error.code + case .apiBlocked(let blockedError): + apiErrorCode = blockedError.code + default: + break + } + } let errorText = apiErrorCode ?? "\((error as NSError).domain)-\((error as NSError).code)" return errorText } diff --git a/Wikipedia/Code/DescriptionEditViewController.swift b/Wikipedia/Code/DescriptionEditViewController.swift index 08d4d48afbc..ea85542f4a6 100644 --- a/Wikipedia/Code/DescriptionEditViewController.swift +++ b/Wikipedia/Code/DescriptionEditViewController.swift @@ -260,6 +260,16 @@ protocol DescriptionEditViewControllerDelegate: AnyObject { let errorCode = self.articleDescriptionController.errorCodeFromError(nsError) self.editFunnel?.logTitleDescriptionSaveError(source: self.editFunnelSource, isAddingNewTitleDescription: self.isAddingNewTitleDescription, language: self.articleDescriptionController.articleLanguageCode, errorText: errorCode) + if let wikidataError = error as? WikidataFetcher.WikidataPublishingError { + switch wikidataError { + case .apiBlocked(let blockedError): + self.presentBlockedPanel(blockedError: blockedError) + return + default: + break + } + } + let errorType = WikiTextSectionUploaderErrorType.init(rawValue: nsError.code) ?? .unknown switch errorType { case .blocked: diff --git a/Wikipedia/Code/WikidataFetcher.swift b/Wikipedia/Code/WikidataFetcher.swift index 89796bfd337..583ccfffdb5 100644 --- a/Wikipedia/Code/WikidataFetcher.swift +++ b/Wikipedia/Code/WikidataFetcher.swift @@ -1,38 +1,3 @@ -public struct WikidataAPIResult: Decodable { - public struct APIError: Error, Decodable { - public let code, info: String? - - public var localizedDescription: String { - return info ?? CommonStrings.unknownError - } - } - let error: APIError? - let success: Int? -} - -struct MediaWikiSiteInfoResult: Decodable { - struct MediaWikiQueryResult: Decodable { - struct MediaWikiGeneralResult: Decodable { - let lang: String - } - let general: MediaWikiGeneralResult - } - let query: MediaWikiQueryResult -} - -extension WikidataAPIResult { - var succeeded: Bool { - return success == 1 - } -} - -enum WikidataPublishingError: LocalizedError { - case invalidArticleURL - case apiResultNotParsedCorrectly - case notEditable - case unknown -} - public enum ArticleDescriptionSource: String { case none case unknown @@ -51,7 +16,115 @@ public enum ArticleDescriptionSource: String { } @objc public final class WikidataFetcher: Fetcher { + +// MARK: Get Blocked Info Models & Methods + + public struct WikidataErrorsResult: Decodable { + + struct Query: Codable { + struct Page: Codable { + let pageid: Int? + let ns: Int? + let title: String? + let actions: [String: [MediaWikiAPIError]]? + } + + let pages: [Page]? + } + + let query: Query? + } + + public func wikidataBlockedInfo(forEntity entity: String, completion: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { + + let parameters: [String: Any] = [ + "action": "query", + "prop": "revisions|info", + "rvprop": "content|ids", + "rvlimit": 1, + "rvslots": "main", + "titles": entity, + "inprop": "protection", + "meta": "userinfo", // we need the local user ID for event logging + "continue": "", + "format": "json", + "formatversion": 2, + "errorformat": "html", + "errorsuselocal": "1", + "intestactions": "edit", // needed for fully resolved protection error. + "intestactionsdetail": "full" // needed for fully resolved protection error. + ] + + let components = configuration.wikidataAPIURLComponents(with: parameters) + let wikidataURL = components.url + + performDecodableMediaWikiAPIGET(for: wikidataURL, with: parameters) { [weak self] (result: Result) in + + switch result { + case .success(let result): + guard + let self, + let siteURL = wikidataURL?.wmf_site, + let page = result.query?.pages?.first else { + completion(nil) + return + } + + guard let editErrors = page.actions?["edit"] as? [MediaWikiAPIError] else { + completion(nil) + return + } + + self.resolveMediaWikiBlockedError(from: editErrors, siteURL: siteURL, completion: completion) + default: + completion(nil) + } + } + } + +// MARK: Publish New Description Models & Methods + static let DidMakeAuthorizedWikidataDescriptionEditNotification = NSNotification.Name(rawValue: "WMFDidMakeAuthorizedWikidataDescriptionEdit") + + public enum WikidataPublishingError: LocalizedError { + case invalidArticleURL + case apiResultNotParsedCorrectly + case notEditable + case apiBlocked(blockedError: MediaWikiAPIBlockedDisplayError) + case apiOther(error: MediaWikiAPIError) + case unknown + + public var errorDescription: String? { + switch self { + case .apiBlocked(let blockedError): + return blockedError.messageHtml + case .apiOther(let error): + return error.html + default: + return CommonStrings.unknownError + } + } + } + + public struct WikidataAPIPublishResult: Decodable { + let errors: [MediaWikiAPIError]? + let success: Int? + + var succeeded: Bool { + return success == 1 + } + } + + struct MediaWikiSiteInfoResult: Decodable { + struct MediaWikiQueryResult: Decodable { + struct MediaWikiGeneralResult: Decodable { + let lang: String + } + let general: MediaWikiGeneralResult + } + let query: MediaWikiQueryResult + } + /// Publish new wikidata description. /// /// - Parameters: @@ -60,39 +133,29 @@ public enum ArticleDescriptionSource: String { /// - wikidataID: id for the Wikidata entity including the prefix /// - languageCode: language code of the page's wiki, e.g., "en". /// - completion: completion block called when operation is completed. + public func publish(newWikidataDescription: String, from source: ArticleDescriptionSource, forWikidataID wikidataID: String, languageCode: String, completion: @escaping (Error?) -> Void) { guard source != .local else { completion(WikidataPublishingError.notEditable) return } - let requestWithCSRFCompletion: (WikidataAPIResult?, URLResponse?, Bool?, Error?) -> Void = { result, response, authorized, error in - if let error = error { - completion(error) - } - guard let result = result else { - completion(WikidataPublishingError.apiResultNotParsedCorrectly) - return - } - - completion(result.error) - - if let authorized = authorized, authorized, result.error == nil { - DispatchQueue.main.async { - NotificationCenter.default.post(name: WikidataFetcher.DidMakeAuthorizedWikidataDescriptionEditNotification, object: nil) - } - } - } let languageCodeParameters = WikipediaSiteInfo.defaultRequestParameters let languageCodeComponents = configuration.mediaWikiAPIURLForLanguageCode(languageCode, queryParameters: languageCodeParameters) - session.jsonDecodableTask(with: languageCodeComponents.url) { (siteInfo: MediaWikiSiteInfoResult?, response, error) in + + session.jsonDecodableTask(with: languageCodeComponents.url) { (siteInfo: MediaWikiSiteInfoResult?, _, _) in + let normalizedLanguage = siteInfo?.query.general.lang ?? "en" let queryParameters = ["action": "wbsetdescription", + "errorformat": "html", + "erroruselocal": 1, "format": "json", "formatversion": "2"] + let components = self.configuration.wikidataAPIURLComponents(with: queryParameters) - self.requestMediaWikiAPIAuthToken(for: components.url, type: .csrf) { (result) in + let wikidataURL = components.url + self.requestMediaWikiAPIAuthToken(for: wikidataURL, type: .csrf) { (result) in switch result { case .failure(let error): completion(error) @@ -102,11 +165,54 @@ public enum ArticleDescriptionSource: String { "id": wikidataID, "value": newWikidataDescription, "token": token.value] - self.session.jsonDecodableTask(with: components.url, method: .post, bodyParameters: bodyParameters, bodyEncoding: .form) { (result: WikidataAPIResult?, response, error) in - requestWithCSRFCompletion(result, response, token.isAuthorized, error) + self.session.jsonDecodableTask(with: wikidataURL, method: .post, bodyParameters: bodyParameters, bodyEncoding: .form) { (result: WikidataAPIPublishResult?, response, networkError) in + + self.processResponse(result: result, response: response, isAuthorized: token.isAuthorized, networkError: networkError, siteURL: wikidataURL?.wmf_site, completion: completion) } } } } } + + private func processResponse(result: WikidataAPIPublishResult?, response: URLResponse?, isAuthorized: Bool?, networkError: Error?, siteURL: URL?, completion: @escaping (Error?) -> Void) { + + if let networkError = networkError { + completion(networkError) + return + } + + guard let result = result else { + completion(WikidataPublishingError.apiResultNotParsedCorrectly) + return + } + + if let errors = result.errors, + let siteURL = siteURL { + + self.resolveMediaWikiBlockedError(from: errors, siteURL: siteURL) { displayError in + + guard let displayError else { + if let firstError = errors.first { + completion(WikidataPublishingError.apiOther(error: firstError)) + } else { + completion(WikidataPublishingError.unknown) + } + + return + } + + completion(WikidataPublishingError.apiBlocked(blockedError: displayError)) + } + + return + } + + completion(nil) + + if (isAuthorized ?? false), (result.errors ?? []).count == 0 { + DispatchQueue.main.async { + NotificationCenter.default.post(name: WikidataFetcher.DidMakeAuthorizedWikidataDescriptionEditNotification, object: nil) + } + } + } } From 31e31cb66bf5f8fd5111ca249bfe42e8a3d2a28b Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:13:56 -0600 Subject: [PATCH 10/17] Temporary fix for Special pages routing in some error messages --- WMF Framework/Router.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/WMF Framework/Router.swift b/WMF Framework/Router.swift index 46732f12cdd..4153e22ffea 100644 --- a/WMF Framework/Router.swift +++ b/WMF Framework/Router.swift @@ -59,6 +59,7 @@ public class Router: NSObject { let namespaceAndTitle = path.namespaceAndTitleOfWikiResourcePath(with: language) let namespace = namespaceAndTitle.0 let title = namespaceAndTitle.1 + switch namespace { case .talk: if FeatureFlags.needsNewTalkPage && project.supportsNativeUserTalkPages { @@ -70,6 +71,22 @@ public class Router: NSObject { return project.supportsNativeUserTalkPages ? .userTalk(url) : nil case .special: + // TODO: Fix to work across languages, not just EN. Fetch special page aliases per site and add to a set of local json files. + // https://en.wikipedia.org/w/api.php?action=query&format=json&meta=siteinfo&formatversion=2&siprop=specialpagealiases + if language.uppercased() == "EN" || language.uppercased() == "TEST", + title == "MyTalk", + let username = MWKDataStore.shared().authenticationManager.loggedInUsername, + let newURL = url.wmf_URL(withTitle: "User_talk:\(username)") { + return .userTalk(newURL) + } + + if language.uppercased() == "EN" || language.uppercased() == "TEST", + title == "MyContributions", + let username = MWKDataStore.shared().authenticationManager.loggedInUsername, + let newURL = url.wmf_URL(withPath: "/wiki/Special:Contributions/\(username)", isMobile: true) { + return .inAppLink(newURL) + } + if title == "ReadingLists", let components = URLComponents(url: url, resolvingAgainstBaseURL: false), let firstQueryItem = components.queryItems?.first, From 5eadc3fed21c9944844619f4fed1be59034eb58a Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Wed, 1 Feb 2023 17:15:05 -0600 Subject: [PATCH 11/17] Show blocked messages when creating account - Adjust parameters to get html in response - Pass back html to view controller as failure - Present blocked panel from account creation view controller --- .../WMFAccountCreationViewController.swift | 18 +++++++++++++++++- Wikipedia/Code/WMFAccountCreator.swift | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Wikipedia/Code/WMFAccountCreationViewController.swift b/Wikipedia/Code/WMFAccountCreationViewController.swift index d177c4f7ff1..14771a75dc7 100644 --- a/Wikipedia/Code/WMFAccountCreationViewController.swift +++ b/Wikipedia/Code/WMFAccountCreationViewController.swift @@ -294,6 +294,8 @@ class WMFAccountCreationViewController: WMFScrollViewController, WMFCaptchaViewC fileprivate func createAccount() { WMFAlertManager.sharedInstance.showAlert(WMFLocalizedString("account-creation-saving", value:"Saving...", comment:"Alert shown when user saves account creation form. {{Identical|Saving}}"), sticky: true, canBeDismissedByUser: false, dismissPreviousAlerts: true, tapCallBack: nil) + let siteURL = dataStore.primarySiteURL + let creationFailure: WMFErrorHandler = {error in DispatchQueue.main.async { self.setViewControllerUserInteraction(enabled: true) @@ -313,6 +315,21 @@ class WMFAccountCreationViewController: WMFScrollViewController, WMFCaptchaViewC return case .wrongCaptcha: self.captchaViewController?.captchaTextFieldBecomeFirstResponder() + case .blockedError(let parsedMessage): + + guard let linkBaseURL = siteURL else { + break + } + + WMFAlertManager.sharedInstance.dismissAlert() + + self.wmf_showBlockedPanel(messageHtml: parsedMessage, linkBaseURL: linkBaseURL, currentTitle: "Special:CreateAccount", theme: self.theme) + + self.funnel?.logError(error.localizedDescription) + self.enableProgressiveButtonIfNecessary() + return + + default: break } } @@ -324,7 +341,6 @@ class WMFAccountCreationViewController: WMFScrollViewController, WMFCaptchaViewC } self.setViewControllerUserInteraction(enabled: false) - let siteURL = dataStore.primarySiteURL accountCreator.createAccount(username: usernameField.text!, password: passwordField.text!, retypePassword: passwordRepeatField.text!, email: emailField.text!, captchaID: captchaViewController?.captcha?.captchaID, captchaWord: captchaViewController?.solution, siteURL: siteURL!, success: {_ in DispatchQueue.main.async { self.login() diff --git a/Wikipedia/Code/WMFAccountCreator.swift b/Wikipedia/Code/WMFAccountCreator.swift index c48c147c381..f937efce899 100644 --- a/Wikipedia/Code/WMFAccountCreator.swift +++ b/Wikipedia/Code/WMFAccountCreator.swift @@ -1,6 +1,7 @@ public enum WMFAccountCreatorError: LocalizedError { case cannotExtractStatus case statusNotPass(String?) + case blockedError(String) case wrongCaptcha case usernameUnavailable public var errorDescription: String? { @@ -8,6 +9,8 @@ public enum WMFAccountCreatorError: LocalizedError { case .cannotExtractStatus: return "Could not extract status" case .statusNotPass(let message?): + return message.removingHTML + case .blockedError(let message): return message case .wrongCaptcha: return WMFLocalizedString("field-alert-captcha-invalid", value:"Invalid CAPTCHA", comment:"Alert shown if CAPTCHA is not correct") @@ -40,6 +43,7 @@ public class WMFAccountCreator: Fetcher { "password": password, "retype": retypePassword, "createreturnurl": "https://www.wikipedia.org", + "createmessageformat": "html", "format": "json" ] if let email = email { @@ -53,6 +57,7 @@ public class WMFAccountCreator: Fetcher { } performTokenizedMediaWikiAPIPOST(tokenType: .createAccount, to: siteURL, with: parameters) { (result, response, error) in + if let error = error { failure(error) return @@ -76,6 +81,11 @@ public class WMFAccountCreator: Fetcher { return default: break } + + if messageCode.contains("block") { + failure(WMFAccountCreatorError.blockedError(message)) + return + } } failure(WMFAccountCreatorError.statusNotPass(message)) return From 58824631224e31e167b3cd590b1b6c4a517e5325 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Thu, 9 Feb 2023 16:32:16 -0600 Subject: [PATCH 12/17] PR Feedback - fix indention --- Wikipedia/assets/codemirror/codemirror-index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wikipedia/assets/codemirror/codemirror-index.html b/Wikipedia/assets/codemirror/codemirror-index.html index 8200de7afa4..e5591abc1bc 100644 --- a/Wikipedia/assets/codemirror/codemirror-index.html +++ b/Wikipedia/assets/codemirror/codemirror-index.html @@ -453,7 +453,7 @@ }, inputStyle: 'contenteditable', direction: direction, - readOnly: setupReadOnly(readOnly), + readOnly: setupReadOnly(readOnly), autocorrect: true, autocapitalize: true, spellcheck: false, From a59eec0c137d73c233ddb962c9c8ab4fd9a79889 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Thu, 9 Feb 2023 16:32:37 -0600 Subject: [PATCH 13/17] PR Feedback - use linkTextAttributes --- Wikipedia/Code/ScrollableEducationPanelViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wikipedia/Code/ScrollableEducationPanelViewController.swift b/Wikipedia/Code/ScrollableEducationPanelViewController.swift index 2a6ea08e6c6..e09be0b629e 100644 --- a/Wikipedia/Code/ScrollableEducationPanelViewController.swift +++ b/Wikipedia/Code/ScrollableEducationPanelViewController.swift @@ -219,7 +219,7 @@ class ScrollableEducationPanelViewController: UIViewController, Themeable { attributedText.addAttributes(attributes, range: NSRange(location: 0, length: attributedText.length)) subheadingTextView.attributedText = attributedText.removingRepetitiveNewlineCharacters() - subheadingTextView.tintColor = theme.colors.link + subheadingTextView.linkTextAttributes = [.foregroundColor: theme.colors.link] } var footerParagraphStyle: NSParagraphStyle? { From a87568f3cc975790af140715b872172d55555850 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Thu, 9 Feb 2023 16:33:37 -0600 Subject: [PATCH 14/17] PR Feedback - replace template placeholders with empty string earlier --- WMF Framework/Fetcher.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/WMF Framework/Fetcher.swift b/WMF Framework/Fetcher.swift index 7be37fdf4c9..edee9c11bf5 100644 --- a/WMF Framework/Fetcher.swift +++ b/WMF Framework/Fetcher.swift @@ -223,8 +223,8 @@ open class Fetcher: NSObject { // Replace encoded placeholders first, before replacing them with blocked text. templateHtml = templateHtml.replacingOccurrences(of: "%241", with: "$1") templateHtml = templateHtml.replacingOccurrences(of: "%242", with: "$2") - templateHtml = templateHtml.replacingOccurrences(of: "%243", with: "$3") - templateHtml = templateHtml.replacingOccurrences(of: "%244", with: "$4") + templateHtml = templateHtml.replacingOccurrences(of: "%243", with: "") // stripped out below + templateHtml = templateHtml.replacingOccurrences(of: "%244", with: "") // stripped out below templateHtml = templateHtml.replacingOccurrences(of: "%245", with: "$5") templateHtml = templateHtml.replacingOccurrences(of: "%246", with: "$6") templateHtml = templateHtml.replacingOccurrences(of: "%247", with: "$7") @@ -238,8 +238,7 @@ open class Fetcher: NSObject { } templateHtml = templateHtml.replacingOccurrences(of: "$3", with: "") // IP Address - - // $4 not used + templateHtml = templateHtml.replacingOccurrences(of: "$4", with: "") // unknown parameter (unused?) templateHtml = templateHtml.replacingOccurrences(of: "$5", with: String(blockInfo.blockid)) From 480f989bb8fed806225fc101c594cdc58c642bce Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Thu, 9 Feb 2023 16:35:33 -0600 Subject: [PATCH 15/17] PR Feedback - remove unused properties --- Wikipedia/Code/SectionFetcher.swift | 2 -- Wikipedia/Code/WikidataFetcher.swift | 2 -- 2 files changed, 4 deletions(-) diff --git a/Wikipedia/Code/SectionFetcher.swift b/Wikipedia/Code/SectionFetcher.swift index c252cf9d485..2215515c475 100644 --- a/Wikipedia/Code/SectionFetcher.swift +++ b/Wikipedia/Code/SectionFetcher.swift @@ -29,8 +29,6 @@ class SectionFetcher: Fetcher { let expiry: String? } - let pageid: Int? - let ns: Int? let title: String? let revisions: [Revision]? let protection: [Protection]? diff --git a/Wikipedia/Code/WikidataFetcher.swift b/Wikipedia/Code/WikidataFetcher.swift index 583ccfffdb5..095d8486247 100644 --- a/Wikipedia/Code/WikidataFetcher.swift +++ b/Wikipedia/Code/WikidataFetcher.swift @@ -23,8 +23,6 @@ public enum ArticleDescriptionSource: String { struct Query: Codable { struct Page: Codable { - let pageid: Int? - let ns: Int? let title: String? let actions: [String: [MediaWikiAPIError]]? } From f6458ef01329ba527e708f07d3deb0a528a9127b Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Thu, 9 Feb 2023 16:54:58 -0600 Subject: [PATCH 16/17] Prefer camel case in codable structs --- WMF Framework/Fetcher.swift | 16 +++++----- WMF Framework/MediaWikiApiErrors.swift | 43 +++++++++++++++++--------- Wikipedia/Code/SectionFetcher.swift | 19 +++++++++--- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/WMF Framework/Fetcher.swift b/WMF Framework/Fetcher.swift index edee9c11bf5..892804135a7 100644 --- a/WMF Framework/Fetcher.swift +++ b/WMF Framework/Fetcher.swift @@ -157,7 +157,7 @@ open class Fetcher: NSObject { public func resolveMediaWikiBlockedError(from apiErrors: [MediaWikiAPIError], siteURL: URL, completion: @escaping (MediaWikiAPIBlockedDisplayError?) -> Void) { let blockedApiErrors = apiErrors.filter { $0.code.contains("block") } - let firstApiErrorWithInfo = blockedApiErrors.first(where: { $0.data?.blockinfo != nil }) + let firstApiErrorWithInfo = blockedApiErrors.first(where: { $0.data?.blockInfo != nil }) let fallbackApiError = blockedApiErrors.first(where: { !$0.html.isEmpty }) let fallbackCompletion: () -> Void = { @@ -172,7 +172,7 @@ open class Fetcher: NSObject { } guard let blockedApiError = firstApiErrorWithInfo, - let blockedApiInfo = blockedApiError.data?.blockinfo else { + let blockedApiInfo = blockedApiError.data?.blockInfo else { fallbackCompletion() return @@ -199,13 +199,13 @@ open class Fetcher: NSObject { var templateSiteURL: URL? group.enter() - parseBlockReason(siteURL: siteURL, blockReason: blockInfo.blockreason) { text in + parseBlockReason(siteURL: siteURL, blockReason: blockInfo.blockReason) { text in blockReasonHtml = text group.leave() } group.enter() - fetchBlockedTextTemplate(isPartial: blockInfo.blockpartial, siteURL: siteURL) { text, siteURL in + fetchBlockedTextTemplate(isPartial: blockInfo.blockPartial, siteURL: siteURL) { text, siteURL in templateHtml = text templateSiteURL = siteURL group.leave() @@ -231,7 +231,7 @@ open class Fetcher: NSObject { templateHtml = templateHtml.replacingOccurrences(of: "%248", with: "$8") // Replace placeholders with blocked text - templateHtml = templateHtml.replacingOccurrences(of: "$1", with: blockInfo.blockedby) + templateHtml = templateHtml.replacingOccurrences(of: "$1", with: blockInfo.blockedBy) if let blockReasonHtml { templateHtml = templateHtml.replacingOccurrences(of: "$2", with: blockReasonHtml) @@ -240,15 +240,15 @@ open class Fetcher: NSObject { templateHtml = templateHtml.replacingOccurrences(of: "$3", with: "") // IP Address templateHtml = templateHtml.replacingOccurrences(of: "$4", with: "") // unknown parameter (unused?) - templateHtml = templateHtml.replacingOccurrences(of: "$5", with: String(blockInfo.blockid)) + templateHtml = templateHtml.replacingOccurrences(of: "$5", with: String(blockInfo.blockID)) - let blockExpiryDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockexpiry, siteURL: linkBaseURL) + let blockExpiryDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockExpiry, siteURL: linkBaseURL) templateHtml = templateHtml.replacingOccurrences(of: "$6", with: blockExpiryDisplayDate) let username = MWKDataStore.shared().authenticationManager.loggedInUsername ?? "" templateHtml = templateHtml.replacingOccurrences(of: "$7", with: username) - let blockedTimestampDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockedtimestamp, siteURL: linkBaseURL) + let blockedTimestampDisplayDate = self.blockedDateForDisplay(iso8601DateString: blockInfo.blockedTimestamp, siteURL: linkBaseURL) templateHtml = templateHtml.replacingOccurrences(of: "$8", with: blockedTimestampDisplayDate) let displayError = MediaWikiAPIBlockedDisplayError(messageHtml: templateHtml, linkBaseURL: linkBaseURL, code: code) diff --git a/WMF Framework/MediaWikiApiErrors.swift b/WMF Framework/MediaWikiApiErrors.swift index d45170669d0..83ea690e7de 100644 --- a/WMF Framework/MediaWikiApiErrors.swift +++ b/WMF Framework/MediaWikiApiErrors.swift @@ -26,12 +26,21 @@ public struct MediaWikiAPIError: Codable { public struct Data: Codable { public struct BlockInfo: Codable { - let blockreason: String - let blockpartial: Bool - let blockedby: String - let blockid: Int64 - let blockexpiry: String - let blockedtimestamp: String + let blockReason: String + let blockPartial: Bool + let blockedBy: String + let blockID: Int64 + let blockExpiry: String + let blockedTimestamp: String + + enum CodingKeys: String, CodingKey { + case blockReason = "blockreason" + case blockPartial = "blockpartial" + case blockedBy = "blockedby" + case blockID = "blockid" + case blockExpiry = "blockexpiry" + case blockedTimestamp = "blockedtimestamp" + } init?(dict: [String: Any]) { @@ -44,25 +53,29 @@ public struct MediaWikiAPIError: Codable { return nil } - self.blockreason = blockReason - self.blockpartial = blockPartial - self.blockedby = blockedBy - self.blockid = blockID - self.blockexpiry = blockExpiry - self.blockedtimestamp = blockedTimestamp + self.blockReason = blockReason + self.blockPartial = blockPartial + self.blockedBy = blockedBy + self.blockID = blockID + self.blockExpiry = blockExpiry + self.blockedTimestamp = blockedTimestamp } } - let blockinfo: BlockInfo? + let blockInfo: BlockInfo? + + enum CodingKeys: String, CodingKey { + case blockInfo = "blockinfo" + } init?(dict: [String: Any]) { guard let blockInfoDict = dict["blockinfo"] as? [String: Any] else { - self.blockinfo = nil + self.blockInfo = nil return } - self.blockinfo = BlockInfo(dict: blockInfoDict) + self.blockInfo = BlockInfo(dict: blockInfoDict) } } diff --git a/Wikipedia/Code/SectionFetcher.swift b/Wikipedia/Code/SectionFetcher.swift index 2215515c475..31f7142588f 100644 --- a/Wikipedia/Code/SectionFetcher.swift +++ b/Wikipedia/Code/SectionFetcher.swift @@ -9,12 +9,13 @@ class SectionFetcher: Fetcher { struct Page: Codable { struct Revision: Codable { struct Slot: Codable { - let contentmodel: String? - let contentformat: String? + let contentModel: String? + let contentFormat: String? let content: String? + enum CodingKeys: String, CodingKey { - case contentmodel - case contentformat + case contentModel = "contentmodel" + case contentFormat = "contentformat" case content } } @@ -32,8 +33,16 @@ class SectionFetcher: Fetcher { let title: String? let revisions: [Revision]? let protection: [Protection]? - let restrictiontypes: [String]? + let restrictionTypes: [String]? let actions: [String: [MediaWikiAPIError]]? + + enum CodingKeys: String, CodingKey { + case title + case revisions + case protection + case restrictionTypes = "restrictiontypes" + case actions + } } let pages: [Page]? From 151acf8bc785c734e07064a73b9c3ea6048ef004 Mon Sep 17 00:00:00 2001 From: Toni Sevener Date: Fri, 10 Feb 2023 15:15:39 -0600 Subject: [PATCH 17/17] If blocked, don't display edit notice automatically --- Wikipedia/Code/SectionEditorViewController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Wikipedia/Code/SectionEditorViewController.swift b/Wikipedia/Code/SectionEditorViewController.swift index 8d5092db3dc..7fef3f23c41 100644 --- a/Wikipedia/Code/SectionEditorViewController.swift +++ b/Wikipedia/Code/SectionEditorViewController.swift @@ -71,6 +71,7 @@ class SectionEditorViewController: ViewController { private let findAndReplaceHeaderTitle = WMFLocalizedString("find-replace-header", value: "Find and replace", comment: "Find and replace header title.") private var editConfirmationSavedData: EditSaveViewController.SaveData? = nil + private var lastBlockedDisplayError: MediaWikiAPIBlockedDisplayError? init(articleURL: URL, sectionID: Int, messagingController: SectionEditorWebViewMessagingController? = nil, dataStore: MWKDataStore, selectedTextEditInfo: SelectedTextEditInfo? = nil, theme: Theme = Theme.standard) { self.articleURL = articleURL @@ -149,7 +150,7 @@ class SectionEditorViewController: ViewController { } private func presentEditNoticesIfNecessary() { - guard UserDefaults.standard.wmf_alwaysDisplayEditNotices else { + guard UserDefaults.standard.wmf_alwaysDisplayEditNotices && lastBlockedDisplayError == nil else { return } @@ -427,13 +428,16 @@ class SectionEditorViewController: ViewController { case .success(let response): self.wikitext = response.wikitext self.handle(protection: response.protection) - self.initialFetchGroup.leave() if let blockedError = response.blockedError { + self.lastBlockedDisplayError = blockedError completion(blockedError) } else { + self.lastBlockedDisplayError = nil completion(nil) } + + self.initialFetchGroup.leave() } } }