/// <inheritdoc /> /// <remarks> /// To logout the user, this override sends a POST request to <c>https://www.wikia.com/logout</c>. /// </remarks> protected override async Task SendLogoutRequestAsync() { string logoutUrl; if (SiteInfo.ServerUrl.EndsWith(".wikia.com", StringComparison.OrdinalIgnoreCase)) { logoutUrl = "https://www.wikia.com/logout"; } else if (SiteInfo.ServerUrl.EndsWith(".wikia.org", StringComparison.OrdinalIgnoreCase)) { logoutUrl = "https://www.wikia.org/logout"; } else if (SiteInfo.ServerUrl.EndsWith(".fandom.com", StringComparison.OrdinalIgnoreCase)) { logoutUrl = "https://www.fandom.com/logout"; } else { logoutUrl = MediaWikiHelper.MakeAbsoluteUrl(SiteInfo.ServerUrl, "logout"); // User is using WikiaSite instance outside Wikia… I wish you good luck. this.Logger.LogWarning("WikiaSite is instantiated with a non-FANDOM site URL: {Url}. Assuming logout URL as {LogoutUrl}.", SiteInfo.ServerUrl, logoutUrl); } await WikiClient.InvokeAsync(logoutUrl, new MediaWikiFormRequestMessage(new { redirect = "" }), DiscardingResponseMessageParser.Instance, CancellationToken.None); }
internal void ApplyBasePath(string basePath) { if (UserPageUrl != null) { UserPageUrl = MediaWikiHelper.MakeAbsoluteUrl(basePath, UserPageUrl); } if (AvatarUrl != null) { AvatarUrl = MediaWikiHelper.MakeAbsoluteUrl(basePath, AvatarUrl); } }
internal void ApplyBasePath(string basePath) { if (Url != null) { Url = MediaWikiHelper.MakeAbsoluteUrl(basePath, Url); } if (ImageUrl != null) { ImageUrl = MediaWikiHelper.MakeAbsoluteUrl(basePath, ImageUrl); } }
/// <summary>Initializes a new <see cref="WikiaSiteOptions"/> instance from the root URL of a Wikia site.</summary> /// <param name="siteRootUrl">Wikia site root URL, with the ending slash. e.g. <c>http://community.wikia.com/</c>.</param> /// <exception cref="ArgumentNullException"><paramref name="siteRootUrl"/> is <c>null</c>.</exception> public WikiaSiteOptions(string siteRootUrl) { if (siteRootUrl == null) { throw new ArgumentNullException(nameof(siteRootUrl)); } ApiEndpoint = MediaWikiHelper.MakeAbsoluteUrl(siteRootUrl, "api.php"); ScriptUrl = MediaWikiHelper.MakeAbsoluteUrl(siteRootUrl, "index.php"); NirvanaEndPointUrl = MediaWikiHelper.MakeAbsoluteUrl(siteRootUrl, "wikia.php"); WikiaApiRootUrl = MediaWikiHelper.MakeAbsoluteUrl(siteRootUrl, "api/v1"); }
/// <summary>Initializes a new <see cref="WikiaSiteOptions"/> instance from the information in <see cref="WikiSite"/>.</summary> /// <param name="site">The existing wiki site instance.</param> /// <exception cref="ArgumentNullException"><paramref name="site"/> is <c>null</c>.</exception> public WikiaSiteOptions(WikiSite site) { if (site == null) { throw new ArgumentNullException(nameof(site)); } ApiEndpoint = site.ApiEndpoint; var siteInfo = site.SiteInfo; ScriptUrl = MediaWikiHelper.MakeAbsoluteUrl(siteInfo.ServerUrl, siteInfo.ScriptFilePath); NirvanaEndPointUrl = MediaWikiHelper.MakeAbsoluteUrl(siteInfo.ServerUrl, "wikia.php"); WikiaApiRootUrl = MediaWikiHelper.MakeAbsoluteUrl(siteInfo.ServerUrl, "api/v1"); }
/// <summary> /// Makes the full URL to the page of specified title. /// </summary> /// <param name="title">The title of the article.</param> /// <param name="defaultProtocol"> /// For wiki sites whose <see cref="ServerUrl"/> is protocol-relative URL (e.g. <c>//en.wikipedia.org/</c>), /// specifies the default protocol to use. (e.g. <c>https</c>)</param> /// <exception cref="ArgumentNullException">Either <paramref name="title"/> or <paramref name="defaultProtocol"/> is <c>null</c>.</exception> /// <returns>The full URL of the article.</returns> /// <remarks> /// For wiki sites with specified-protocol <see cref="ServerUrl"/>, such as Wikia (which uses http), /// this overload respects the server-chosen protocol. /// </remarks> public string MakeArticleUrl(string title, string defaultProtocol) { if (title == null) { throw new ArgumentNullException(nameof(title)); } if (defaultProtocol == null) { throw new ArgumentNullException(nameof(defaultProtocol)); } var cache = articleUrlTemplateCache; if (cache == null || cache.Item1 != defaultProtocol) { var urlTemplate = MediaWikiHelper.MakeAbsoluteUrl(ServerUrl, ArticlePath, defaultProtocol); cache = new Tuple <string, string>(defaultProtocol, urlTemplate); Volatile.Write(ref articleUrlTemplateCache, cache); } return(cache.Item2.Replace("$1", Uri.EscapeUriString(title))); }