Added Jira link parsing
parent
8ecbe39a32
commit
656f5249a0
|
|
@ -64,3 +64,4 @@ ImprovedRadar LGPL
|
|||
Resizable_Profiles LGPL
|
||||
Derender LGPL
|
||||
RezUnderLandGroup LGPL
|
||||
JiraLinkParsing LGPL
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
#include "lluicolortable.h"
|
||||
#include "message.h"
|
||||
|
||||
#include <boost/algorithm/string/find.hpp> //for boost::ifind_first -KC
|
||||
|
||||
#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))"
|
||||
|
||||
// Utility functions
|
||||
|
|
@ -1207,3 +1209,38 @@ std::string LLUrlEntryIcon::getIcon(const std::string &url)
|
|||
LLStringUtil::trim(mIcon);
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
//
|
||||
// LLUrlEntryJira Describes Jira issue names -KC
|
||||
//
|
||||
LLUrlEntryJira::LLUrlEntryJira()
|
||||
{
|
||||
mPattern = boost::regex("((?:ECC|SH|SOCIAL|LEAP|DN|MISC|SNOW|LLSD|CTS|PYO|STORM|PLAT|ER|VWR|SVC|WEB|SEC|ARVD|OPEN|SCR|PHOE|FIRE|SPOT)-\\d+)",
|
||||
boost::regex::perl|boost::regex::icase);
|
||||
mMenuName = "menu_url_http.xml";
|
||||
mTooltip = LLTrans::getString("TooltipHttpUrl");
|
||||
}
|
||||
|
||||
std::string LLUrlEntryJira::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
|
||||
{
|
||||
return unescapeUrl(url);
|
||||
}
|
||||
|
||||
std::string LLUrlEntryJira::getTooltip(const std::string &string) const
|
||||
{
|
||||
return getUrl(string);
|
||||
}
|
||||
|
||||
std::string LLUrlEntryJira::getUrl(const std::string &string) const
|
||||
{
|
||||
if (boost::ifind_first(string, "PHOE") ||
|
||||
boost::ifind_first(string, "FIRE") ||
|
||||
boost::ifind_first(string, "SPOT"))
|
||||
{
|
||||
return llformat("http://jira.phoenixviewer.com/browse/%s", string.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
return llformat("https://jira.secondlife.com/browse/%s", string.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -440,5 +440,16 @@ public:
|
|||
/*virtual*/ std::string getIcon(const std::string &url);
|
||||
};
|
||||
|
||||
///
|
||||
/// LLUrlEntryJira Describes Jira issue names -KC
|
||||
///
|
||||
class LLUrlEntryJira : public LLUrlEntryBase
|
||||
{
|
||||
public:
|
||||
LLUrlEntryJira();
|
||||
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
|
||||
/*virtual*/ std::string getTooltip(const std::string &string) const;
|
||||
/*virtual*/ std::string getUrl(const std::string &string) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "llurlregistry.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/find.hpp> //for boost::ifind_first -KC
|
||||
|
||||
// default dummy callback that ignores any label updates from the server
|
||||
void LLUrlRegistryNullCallback(const std::string &url, const std::string &label, const std::string& icon)
|
||||
|
|
@ -73,6 +74,8 @@ LLUrlRegistry::LLUrlRegistry()
|
|||
// most common pattern is a URL without any protocol,
|
||||
// e.g., "secondlife.com"
|
||||
registerUrl(new LLUrlEntryHTTPNoProtocol());
|
||||
// parse jira issue names to links -KC
|
||||
registerUrl(new LLUrlEntryJira());
|
||||
}
|
||||
|
||||
LLUrlRegistry::~LLUrlRegistry()
|
||||
|
|
@ -151,10 +154,38 @@ static bool stringHasUrl(const std::string &text)
|
|||
text.find("<icon") != std::string::npos);
|
||||
}
|
||||
|
||||
static bool stringHasJira(const std::string &text)
|
||||
{
|
||||
// same as above, but for jiras
|
||||
return (boost::ifind_first(text, "ECC") ||
|
||||
boost::ifind_first(text, "SH") ||
|
||||
boost::ifind_first(text, "SOCIAL") ||
|
||||
boost::ifind_first(text, "LEAP") ||
|
||||
boost::ifind_first(text, "DN") ||
|
||||
boost::ifind_first(text, "MISC") ||
|
||||
boost::ifind_first(text, "SNOW") ||
|
||||
boost::ifind_first(text, "LLSD") ||
|
||||
boost::ifind_first(text, "CTS") ||
|
||||
boost::ifind_first(text, "PYO") ||
|
||||
boost::ifind_first(text, "STORM") ||
|
||||
boost::ifind_first(text, "PLAT") ||
|
||||
boost::ifind_first(text, "ER") ||
|
||||
boost::ifind_first(text, "VWR") ||
|
||||
boost::ifind_first(text, "SVC") ||
|
||||
boost::ifind_first(text, "WEB") ||
|
||||
boost::ifind_first(text, "SEC") ||
|
||||
boost::ifind_first(text, "ARVD") ||
|
||||
boost::ifind_first(text, "OPEN") ||
|
||||
boost::ifind_first(text, "SCR") ||
|
||||
boost::ifind_first(text, "PHOE") ||
|
||||
boost::ifind_first(text, "FIRE") ||
|
||||
boost::ifind_first(text, "SPOT"));
|
||||
}
|
||||
|
||||
bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb)
|
||||
{
|
||||
// avoid costly regexes if there is clearly no URL in the text
|
||||
if (! stringHasUrl(text))
|
||||
if (! (stringHasUrl(text) || stringHasJira(text)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue